SlideShare une entreprise Scribd logo
1  sur  103
Télécharger pour lire hors ligne
REST API FOR HUMANS™eve
eve
nicolaiarocci
CoFounder and Lead Dev @C2K
Open Source • MongoDB Master • Speaking • CoderDojo • PSF
PHILOSOPHY
YOU HAVE DATA
STORED SOMEWHERE
YOU NEED
A FULL FEATURED REST API
TO EXPOSE YOUR DATA
PIP INSTALL EVE
TO GET A FEATURE RICH RESTFUL WEB API FOR FREE
POWERED BY
QUICKSTART
#1 run.py
from eve import Eve
app = Eve()
!
if __name__ == '__main__':
app.run()
#2 settings.py
# just a couple API endpoints with no custom
# schema or rules. Will just dump from people
# and books db collections
!
DOMAIN = {
‘people’: {}
‘books’: {}
}
#3 launch the API
$ python run.py
* Running on http://127.0.0.1:5000/
#4 enjoy
$ curl -i http://127.0.0.1:5000/people
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": "people" },
"parent": {
"href": "127.0.0.1:5000",
"title": "home"}
}
}
#4 enjoy
$ curl -i http://127.0.0.1:5000/people
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": “people" },
"parent": {
"href": "127.0.0.1:5000",
"title": “home"}
}
}
HATEOAS AT WORK HERE
#4 enjoy
$ curl -i http://127.0.0.1:5000/people
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": "people" },
"parent": {
"href": "127.0.0.1:5000",
"title": "home"}
}
}
CLIENTS CAN EXPLORE THE API PROGRAMMATICALLY
#4 enjoy
$ curl -i http://127.0.0.1:5000/people
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": "people" },
"parent": {
"href": "127.0.0.1:5000",
"title": "home"}
}
}
AND EVENTUALLY FILL THEIR UI
#4 enjoy
$ curl -i http://127.0.0.1:5000/people
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": "people" },
"parent": {
"href": "127.0.0.1:5000",
"title": "home"}
}
}
EMTPY RESOURCE AS WE DIDN’T CONNECT ANY DATASOURCE
settings.py
# let’s connect to a mongo instance
!
MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_USERNAME = 'user'
MONGO_PASSWORD = 'user'
MONGO_DBNAME = ‘apitest'
settings.py
# let’s also add some validation rules
!
DOMAIN['people']['schema'] = {
'name': {
'type': 'string',
'maxlength': 50,
'unique': True}
'email': {
'type': 'string',
'regex': '^S+@S+$'},
'location': {
'type': 'dict',
'schema': {
'address': {'type': 'string'},
'city': {'type': 'string'}}},
'born': {'type': ‘datetime'}}
settings.py
# let’s also add some validation rules
!
DOMAIN['people']['schema'] = {
'name': {
'type': 'string',
'maxlength': 50,
'unique': True}
'email': {
'type': 'string',
'regex': '^S+@S+$'},
'location': {
'type': 'dict',
'schema': {
'address': {'type': 'string'},
'city': {'type': 'string'}}},
'born': {'type': ‘datetime'}}
THIS REGEX SUCKS. DON’T USE IN PRODUCTION
settings.py
# allow write access to API endpoints
# (default is [‘GET’] for both settings)
!
# /people
RESOURCE_METHODS = ['GET','POST']
!
# /people/<id>
ITEM_METHODS = ['GET','PATCH','PUT','DELETE']
settings.py
# allow write access to API endpoints
# (default is [‘GET’] for both settings)
!
# /people
RESOURCE_METHODS = ['GET','POST']
!
# /people/<id>
ITEM_METHODS = ['GET','PATCH','PUT','DELETE']
ADD/CREATE ONE OR MORE ITEMS
settings.py
# allow write access to API endpoints
# (default is [‘GET’] for both settings)
!
# /people
RESOURCE_METHODS = ['GET', 'POST']
!
# /people/<id>
ITEM_METHODS = ['GET','PATCH','PUT','DELETE']
EDIT ITEM
settings.py
# allow write access to API endpoints
# (default is [‘GET’] for both settings)
!
# /people
RESOURCE_METHODS = ['GET', 'POST']
!
# /people/<id>
ITEM_METHODS = ['GET','PATCH','PUT','DELETE']
REPLACE ITEM
settings.py
# allow write access to API endpoints
# (default is [‘GET’] for both settings)
!
# /people
RESOURCE_METHODS = ['GET', 'POST']
!
# /people/<id>
ITEM_METHODS = ['GET','PATCH','PUT','DELETE']
YOU GUESSED IT
settings.py
# a few more config options
!
DOMAIN[‘people’].update(
{
‘item_title’: ‘person’,
‘cache_control’: ‘max-age=10,must-revalidate,
‘cache_expires’: 10,
‘additional_lookup’: {
‘url’: ‘regex)”[w]+”)’,
‘field’: ‘name’
}
)
FEATURES
MONGO FILTERS
?where={“lastname”: “Doe”}
PYTHON FILTERS
?where=lastname==“Doe”
SORTING
?sort=[(“total”: -1)]
SORT BY ‘TOTAL’, DESCENDING ORDER
PAGINATION
?max_results=20&page=2
MAX 20 RESULTS/PAGE; PAGE 2
PROJECTIONS
?projection={"avatar": 0}
RETURN ALL FIELDS BUT ‘AVATAR’
PROJECTIONS
?projection={"lastname": 1}
ONLY RETURN ‘LASTNAME’
EMBEDDED RESOURCES
?embedded={"author": 1}
NOT EMBEDDED
$ curl -i <url>
!
HTTP/1.1 200 OK
{

"title": "Book Title",

"description": "book description",

"author": “52da465a5610320002660f94"

}
RAW FOREIGN KEY
(DEFAULT)
EMBEDDED
$ curl -i <url>?embedded={“author”: 1}
!
HTTP/1.1 200 OK
{

"title": "Book Title",

"description": "book description",

"author": {

“firstname”: “Mark”,

“lastname”: “Green”,

}

}
REQUEST EMBEDDED AUTHOR
EMBEDDED
$ curl -i <url>?embedded={“author”: 1}
!
HTTP/1.1 200 OK
{

"title": "Book Title",

"description": "book description",

"author": {

“firstname”: “Mark”,

“lastname”: “Green”,

}

}
EMBEDDED DOCUMENT
JSON AND XML
BUILT-IN FOR ALL RESPONSES
APPLICATION/JSON
[
{
"firstname": "Mark",
"lastname": "Green",
"born": "Sat, 23 Feb 1985 12:00:00 GMT",
"role": ["copy", "author"],
"location": {"city": "New York", "address": "4925 Lacross Road"},
"_id": "50bf198338345b1c604faf31",
"_updated": "Wed, 05 Dec 2012 09:53:07 GMT",
"_created": "Wed, 05 Dec 2012 09:53:07 GMT",
"_etag": "ec5e8200b8fa0596afe9ca71a87f23e71ca30e2d",
},
{
"firstname": "John",
...
},
]
APPLICATION/JSON
[
{
"firstname": "Mark",
"lastname": "Green",
"born": "Sat, 23 Feb 1985 12:00:00 GMT",
"role": ["copy", "author"],
"location": {"city": "New York", "address": "4925 Lacross Road"},
"_id": "50bf198338345b1c604faf31",
"_updated": "Wed, 05 Dec 2012 09:53:07 GMT",
"_created": "Wed, 05 Dec 2012 09:53:07 GMT",
"_etag": "ec5e8200b8fa0596afe9ca71a87f23e71ca30e2d",
},
{
"firstname": "John",
...
},
]
METAFIELDS ARE CONFIGURABLE
APPLICATION/XML
<resource href=“localhost:5000/people" title="people">
<resource href="localhost:5000/people/<id>" title="person">
<lastname>Green</lastname>
<firstname>Mark</firstname>
<born>Wed, 05 Dec 2012 09:53:07 GMT</born>
<role>author</role>
<role>copy</role>
<location>
<address>4925 Lacross Road</address>
<city>New York</city>
</location>
<_id>50bf198338345b1c604faf31</_id>
<created>Wed, 05 Dec 2012 09:53:07 GMT</created>
<updated>Sat, 18 Jan 2014 09:16:10 GMT</updated>
<etag>ec5e8200b8fa0596afe9ca71a87f23e71ca30e2d</etag>
</resource>
...
<resource>
HATEOAS
HYPERMEDIA AS THE ENGINE OF APPLICATION STATE
HATEOAS
{
“_links”: {
“self”: {
“href”: “/people”,
“title”: “people”},
“parent”: {
“href”: “/”,
“title”: “home”},
“next”: {
“href”: “/people?page=2”,
“title”: “next page”},
“last”: {
“href: “/people?page=10”,
“title”: “last page”}
}
}
DOCUMENT VERSIONS
?version=3
?version=all
?version=diffs
FILE STORAGE
FILES ARE STORED IN GRIDFS BY DEFAULT
FILE STORAGE / SETTINGS
accounts = {

'name': {'type': 'string'},

'pic': {'type': 'media'},

…

}
FILE STORAGE
$ curl F “name=doe” —F “pic=@profile.jpg" <url>
HTTP/1.1 200 OK
!
$ curl -i <url>
HTTP/1.1 200 OK
{

"name": "john",

"pic": "/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAA…"

}
MULTIPART/DATA-FORM POST
FILE STORAGE
$ curl F “name=doe” —F “pic=@profile.jpg" <url>
HTTP/1.1 200 OK
!
$ curl -i <url>
HTTP/1.1 200 OK
{

"name": "john",

"pic": "/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAA…"

}
FILES RETURNED AS BASE64 STRINGS
FILE STORAGE (WITH META)
$ curl -i <url>
HTTP/1.1 200 OK
{

"name": "john",

"pic": {
“file”: ”/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAA”,
“content_type”: “image/jpeg”,
“name”: “profile.jpg”,
“length”: 8129
}

}
EXTENDED_MEDIA_INFO: TRUE
RATE LIMITING
POWERED
RATE LIMITING / SETTINGS
# Rate limit on GET requests:
# 1 requests 1 minute window (per client)
!
RATE_LIMIT_GET = (1, 60)
RATE LIMITING / GET #1
$ curl -i <url>
!
HTTP/1.1 200 OK
X-RateLimit-Limit: 1
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1390486659
RATE LIMITING / GET #2
$ curl -i <url>
!
HTTP/1.1 429 TOO MANY REQUESTS
CONDITIONAL REQUESTS
ALLOW CLIENTS TO ONLY REQUEST
NON-CACHED CONTENT
IF-MODIFIED-SINCE
If-Modified-Since: Wed, 05 Dec 2012 09:53:07 GMT
“Please return modified data since <date> or 304”
IF-NONE-MATCH
If-None-Match:1234567890123456789012345678901234567890
“Please return data if it has changed or 304”
>
BULK INSERTS
INSERT MULTIPLE DOCUMENTS WITH A SINGLE REQUEST
BULK INSERTS / REQUEST
$ curl -d ‘
[
{
"firstname": "barack",
"lastname": “obama"
},
{
"firstname": "mitt",
"lastname": “romney”
}
]'
-H 'Content-Type: application/json’ <url>
BULK INSERTS / RESPONSE
[
{
"_status": "OK",
"_updated": "Thu, 22 Nov 2012 15:22:27 GMT",
"_id": "50ae43339fa12500024def5b",
"_etag": "749093d334ebd05cf7f2b7dbfb7868605578db2c"
"_links": {"self": {"href": “<url>”, "title": "person"}}
},
{
"_status": "OK",
"_updated": "Thu, 22 Nov 2012 15:22:27 GMT",
"_id": "50ae43339fa12500024def5c",
"_etag": "62d356f623c7d9dc864ffa5facc47dced4ba6907"
"_links": {"self": {"href": “<url>", "title": "person"}}
}
]
COHERENCE MODE OFF: ONLY META FIELDS ARE RETURNED
BULK INSERTS / RESPONSE
[
{
"_status": "OK",
"_updated": "Thu, 22 Nov 2012 15:22:27 GMT",
"_id": "50ae43339fa12500024def5b",
"_etag": "749093d334ebd05cf7f2b7dbfb7868605578db2c"
"_links": {"self": {"href": “<url>”, "title": “person”}},
"firstname": "barack",
"lastname": "obama",
!
},
{
"_status": "OK",
"_updated": "Thu, 22 Nov 2012 15:22:27 GMT",
"_id": "50ae43339fa12500024def5c",
"_etag": "62d356f623c7d9dc864ffa5facc47dced4ba6907"
"_links": {"self": {"href": “<url>", "title": "person"}}
"firstname": "mitt",
"lastname": "romney",
}
]
COHERENCE MODE ON: ALL FIELDS RETURNED
DATA INTEGRITY
CONCURRENCY CONTROL
NO OVERWRITING DOCUMENTS
WITH OBSOLETE VERSIONS
DATA INTEGRITY / CONCURRENCY
$ curl -X PATCH -i <url> 

-d '{"firstname": "ronald"}'

HTTP/1.1 403 FORBIDDEN
IF-MATCH MISSING
DATA INTEGRITY / CONCURRENCY
$ curl -X PATCH -i <url>

-H "If-Match: <obsolete_etag>”

-d '{"firstname": “ronald”}'
!
HTTP/1.1 412 PRECONDITION FAILED

ETAG MISMATCH
DATA INTEGRITY / CONCURRENCY
$ curl -X PATCH -i <url>

-H “If-Match: 206fb4a39815cc0ebf48b2b52d7…”

-d '{"firstname": “ronald"}'
!
HTTP/1.1 200 OK
UPDATE ALLOWED IF CLIENT AND SERVER ETAG MATCH
DATA VALIDATION
[
{
"_status": "ERR",
"_issues": {“name”: “value ‘clinton’ not unique”}
},
{
"_status": “OK",
"_updated": "Thu, 22 Nov 2012 15:22:27 GMT”,
"_id": “50ae43339fa12500024def5c",
"_etag": “62d356f623c7d9dc864ffa5facc47dced4ba6907"
"_links": {
"self": {
"href": “<url>”,
"title": “person"
}
}
}
]
AUTHENTICATION
AND AUTHORIZATION
BASIC, TOKEN AND HMAC AUTH SUPPORTED
RUNS ON ALL PYTHONS
2.6 / 2.7 / 3.3 / 3.4 and PyPy
AND MORE
CORS. CACHE CONTROL. VERSONING AND MORE.
BSD LICENSED
TEAR IT APART
DEVELOPERS
CUSTOM DATA LAYERS
BUILD YOUR OWN DATA LAYER
SQL ALCHEMY (WIP)
SQLALCHEMY (WIP)
@registerSchema('invoices')
class Invoices(CommonColumns):
__tablename__ = 'invoices'
number = db.Column(db.Integer)
people = db.Column(db.Integer,
db.ForeignKey('people._id'))
ELASTICSERCH
MONGODB (DEFAULT)
AUTHENTICATION
BASIC | TOKEN | HMAC
SECURITY AT A GLANCE
• global authentication
• custom endpoint auth
• public enpoints and methods
• role based access control
• user restricted resource access
three steps
Auth
tutorial
#1
IMPORT BASE AUTH CLASS
#2
OVERRIDE CHECK_AUTH() METHOD
#3
PASS CUSTOM CLASS TO THE EVE APP
Done
CUSTOM VALIDATION
EXTEND THE BUILT-IN VALIDATION SYSTEM
CUSTOM VALIDATION
• add custom data types
• add custom validation logic
EVENT HOOKS
PLUG CUSTOM ACTIONS INTO THE API LOOP
EVENT HOOKS AT A GLANCE
• POST on_insert/on_inserted
• GET on_fetch/on_fetched
• PATCH on_update/on_updated
• PUT on_replace/on_replaced
• DELETE on_delete/on_deteled
• on_pre_<method>; on_post_<method>
TRANSFORM INCOMING DOCUMENTS
CUSTOM FILE STORAGE
custom MediaStorage subclasses to S3, File System, you name it
COMMUNITY
EVE-DOCS
GENERATES DOCUMENTATION FOR EVE APIS IN HTML AND JSON FORMATS
CHARLES FLYNN
EVE-DOCS
EVE-MONGOENGINE
ENABLES MONGOENGINE ORM MODELS TO BE USED AS EVE SCHEMA
STANISLAV HELLER
EVE-ELASTIC
ELASTICSEARCH DATA LAYER FOR EVE REST FRAMEWORK
PETR JASEK
EVE-MOCKER
MOCKING TOOL FOR EVE POWERED REST APIS
THOMAS SILEO
{48: <you name here>}
Bryan Cattle Christoph Witzany Daniele Pizzolli
dccrazyboy Dong Wei Ming Florian Rathgeber Francisco
Corrales Morales Garrin Kimmell Gianfranco Palumbo Jaroslav
Semančík Jean Boussier John Deng Jorge Puente Sarrín
Josh Villbrandt Julien Barbot Ken Carpenter Kevin
Bowrin Kracekumar Nicolas Bazire Nicolas Carlier Ondrej
Slinták Petr Jašek Paul Doucet Robert Wlodarczyk Roberto Pasini
Ronan Delacroix Roy Smith Ryan Shea Samuel Sutch
Stanislav Heller Thomas Sileo Tomasz Jezierski Xavi Cubillas
NOW COOKING
GeoJSON
Support and validation for GeoJSON types
!
Point, LineString, Polygon, MultiPoint,
MultiLineString, MultiPolygon, GeometricalCollection
JSONP*
IN CASE YOUR BROWSER/JS FRAMEWORK CANT HANDLE C.O.R.S.
* PENDING SECURITY REVIEW
JSON-LD / HAL / SIREN*
CURSTOM RENDER CLASSES
* MAYBE (UNDER CONSIDERATION)
python-eve.org
JOIN US
eve
nicolaiarocci
Thank you!

Contenu connexe

Tendances

Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDBMongoDB
 
Redis for your boss 2.0
Redis for your boss 2.0Redis for your boss 2.0
Redis for your boss 2.0Elena Kolevska
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4DEVCON
 
Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4DEVCON
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIsRemy Sharp
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPMariano Iglesias
 
When RSS Fails: Web Scraping with HTTP
When RSS Fails: Web Scraping with HTTPWhen RSS Fails: Web Scraping with HTTP
When RSS Fails: Web Scraping with HTTPMatthew Turland
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparisonHiroshi Nakamura
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webclkao
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJSSylvain Zimmer
 

Tendances (20)

Rest in flask
Rest in flaskRest in flask
Rest in flask
 
Redis for your boss
Redis for your bossRedis for your boss
Redis for your boss
 
Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDB
 
Redis for your boss 2.0
Redis for your boss 2.0Redis for your boss 2.0
Redis for your boss 2.0
 
Beyond Phoenix
Beyond PhoenixBeyond Phoenix
Beyond Phoenix
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
 
Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4Python Code Camp for Professionals 4/4
Python Code Camp for Professionals 4/4
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
Fun with Python
Fun with PythonFun with Python
Fun with Python
 
HTML5 JavaScript APIs
HTML5 JavaScript APIsHTML5 JavaScript APIs
HTML5 JavaScript APIs
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHP
 
When RSS Fails: Web Scraping with HTTP
When RSS Fails: Web Scraping with HTTPWhen RSS Fails: Web Scraping with HTTP
When RSS Fails: Web Scraping with HTTP
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
Ruby gems
Ruby gemsRuby gems
Ruby gems
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
Lies, Damn Lies, and Benchmarks
Lies, Damn Lies, and BenchmarksLies, Damn Lies, and Benchmarks
Lies, Damn Lies, and Benchmarks
 

En vedette

Building Automated REST APIs with Python
Building Automated REST APIs with PythonBuilding Automated REST APIs with Python
Building Automated REST APIs with PythonJeff Knupp
 
Developing RESTful Web APIs with Python, Flask and MongoDB
Developing RESTful Web APIs with Python, Flask and MongoDBDeveloping RESTful Web APIs with Python, Flask and MongoDB
Developing RESTful Web APIs with Python, Flask and MongoDBNicola Iarocci
 
Build REST API clients for AngularJS
Build REST API clients for AngularJSBuild REST API clients for AngularJS
Build REST API clients for AngularJSAlmog Baku
 
Writing Idiomatic Python: PyCon PH 2017 Keynote
Writing Idiomatic Python: PyCon PH 2017 KeynoteWriting Idiomatic Python: PyCon PH 2017 Keynote
Writing Idiomatic Python: PyCon PH 2017 KeynoteJeff Knupp
 
Fuga dalla Comfort Zone
Fuga dalla Comfort ZoneFuga dalla Comfort Zone
Fuga dalla Comfort ZoneNicola Iarocci
 
Hands on django part 1
Hands on django part 1Hands on django part 1
Hands on django part 1MicroPyramid .
 
Quattro passi tra le nuvole (e non scordate il paracadute)
Quattro passi tra le nuvole (e non scordate il paracadute)Quattro passi tra le nuvole (e non scordate il paracadute)
Quattro passi tra le nuvole (e non scordate il paracadute)Nicola Iarocci
 
Diabetes and Me: My Journey So Far
Diabetes and Me: My Journey So FarDiabetes and Me: My Journey So Far
Diabetes and Me: My Journey So FarJason Myers
 
Intro python-object-protocol
Intro python-object-protocolIntro python-object-protocol
Intro python-object-protocolShiyao Ma
 
Filling the flask
Filling the flaskFilling the flask
Filling the flaskJason Myers
 
Python Static Analysis Tools
Python Static Analysis ToolsPython Static Analysis Tools
Python Static Analysis ToolsJason Myers
 
Introduction to SQLAlchemy and Alembic Migrations
Introduction to SQLAlchemy and Alembic MigrationsIntroduction to SQLAlchemy and Alembic Migrations
Introduction to SQLAlchemy and Alembic MigrationsJason Myers
 
Coderfaire Data Networking for Developers
Coderfaire Data Networking for DevelopersCoderfaire Data Networking for Developers
Coderfaire Data Networking for DevelopersJason Myers
 
Flask - Python microframework
Flask - Python microframeworkFlask - Python microframework
Flask - Python microframeworkAndré Mayer
 
Introduction to SQLAlchemy ORM
Introduction to SQLAlchemy ORMIntroduction to SQLAlchemy ORM
Introduction to SQLAlchemy ORMJason Myers
 
We Are All Remote Workers
We Are All Remote WorkersWe Are All Remote Workers
We Are All Remote WorkersNicola Iarocci
 
Impact of Restful Web Architecture on Performance and Scalability
Impact of Restful Web Architecture on Performance and ScalabilityImpact of Restful Web Architecture on Performance and Scalability
Impact of Restful Web Architecture on Performance and ScalabilitySanchit Gera
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flaskJim Yeh
 

En vedette (20)

Building Automated REST APIs with Python
Building Automated REST APIs with PythonBuilding Automated REST APIs with Python
Building Automated REST APIs with Python
 
Developing RESTful Web APIs with Python, Flask and MongoDB
Developing RESTful Web APIs with Python, Flask and MongoDBDeveloping RESTful Web APIs with Python, Flask and MongoDB
Developing RESTful Web APIs with Python, Flask and MongoDB
 
Build REST API clients for AngularJS
Build REST API clients for AngularJSBuild REST API clients for AngularJS
Build REST API clients for AngularJS
 
Writing Idiomatic Python: PyCon PH 2017 Keynote
Writing Idiomatic Python: PyCon PH 2017 KeynoteWriting Idiomatic Python: PyCon PH 2017 Keynote
Writing Idiomatic Python: PyCon PH 2017 Keynote
 
CoderDojo Romagna
CoderDojo RomagnaCoderDojo Romagna
CoderDojo Romagna
 
Fuga dalla Comfort Zone
Fuga dalla Comfort ZoneFuga dalla Comfort Zone
Fuga dalla Comfort Zone
 
Hands on django part 1
Hands on django part 1Hands on django part 1
Hands on django part 1
 
Quattro passi tra le nuvole (e non scordate il paracadute)
Quattro passi tra le nuvole (e non scordate il paracadute)Quattro passi tra le nuvole (e non scordate il paracadute)
Quattro passi tra le nuvole (e non scordate il paracadute)
 
Diabetes and Me: My Journey So Far
Diabetes and Me: My Journey So FarDiabetes and Me: My Journey So Far
Diabetes and Me: My Journey So Far
 
Intro python-object-protocol
Intro python-object-protocolIntro python-object-protocol
Intro python-object-protocol
 
Filling the flask
Filling the flaskFilling the flask
Filling the flask
 
Python Static Analysis Tools
Python Static Analysis ToolsPython Static Analysis Tools
Python Static Analysis Tools
 
Online / Offline
Online / OfflineOnline / Offline
Online / Offline
 
Introduction to SQLAlchemy and Alembic Migrations
Introduction to SQLAlchemy and Alembic MigrationsIntroduction to SQLAlchemy and Alembic Migrations
Introduction to SQLAlchemy and Alembic Migrations
 
Coderfaire Data Networking for Developers
Coderfaire Data Networking for DevelopersCoderfaire Data Networking for Developers
Coderfaire Data Networking for Developers
 
Flask - Python microframework
Flask - Python microframeworkFlask - Python microframework
Flask - Python microframework
 
Introduction to SQLAlchemy ORM
Introduction to SQLAlchemy ORMIntroduction to SQLAlchemy ORM
Introduction to SQLAlchemy ORM
 
We Are All Remote Workers
We Are All Remote WorkersWe Are All Remote Workers
We Are All Remote Workers
 
Impact of Restful Web Architecture on Performance and Scalability
Impact of Restful Web Architecture on Performance and ScalabilityImpact of Restful Web Architecture on Performance and Scalability
Impact of Restful Web Architecture on Performance and Scalability
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 

Similaire à Eve - REST API for Humans™

CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourPeter Friese
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsMongoDB
 
Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 MinutesKarel Minarik
 
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016Luigi Dell'Aquila
 
Elasticsearch sur Azure : Make sense of your (BIG) data !
Elasticsearch sur Azure : Make sense of your (BIG) data !Elasticsearch sur Azure : Make sense of your (BIG) data !
Elasticsearch sur Azure : Make sense of your (BIG) data !Microsoft
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchAppsBradley Holt
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responsesdarrelmiller71
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010Alex Sharp
 
Real-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @MoldcampReal-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @MoldcampAlexei Gorobets
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaGuido Schmutz
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...confluent
 
LinkRest at JeeConf 2017
LinkRest at JeeConf 2017LinkRest at JeeConf 2017
LinkRest at JeeConf 2017Andrus Adamchik
 
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache KafkaSolutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache KafkaGuido Schmutz
 
Introduction to CouchDB
Introduction to CouchDBIntroduction to CouchDB
Introduction to CouchDBBogdan Sabău
 

Similaire à Eve - REST API for Humans™ (20)

CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
 
Elasticsearch in 15 Minutes
Elasticsearch in 15 MinutesElasticsearch in 15 Minutes
Elasticsearch in 15 Minutes
 
Intro to Sail.js
Intro to Sail.jsIntro to Sail.js
Intro to Sail.js
 
Couchdb
CouchdbCouchdb
Couchdb
 
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
 
Elasticsearch sur Azure : Make sense of your (BIG) data !
Elasticsearch sur Azure : Make sense of your (BIG) data !Elasticsearch sur Azure : Make sense of your (BIG) data !
Elasticsearch sur Azure : Make sense of your (BIG) data !
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
Practical Ruby Projects with MongoDB - Ruby Kaigi 2010
 
Os Pruett
Os PruettOs Pruett
Os Pruett
 
Php summary
Php summaryPhp summary
Php summary
 
Real-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @MoldcampReal-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @Moldcamp
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
 
JSON and the APInauts
JSON and the APInautsJSON and the APInauts
JSON and the APInauts
 
LinkRest at JeeConf 2017
LinkRest at JeeConf 2017LinkRest at JeeConf 2017
LinkRest at JeeConf 2017
 
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache KafkaSolutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
 
Introduction to CouchDB
Introduction to CouchDBIntroduction to CouchDB
Introduction to CouchDB
 

Dernier

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Dernier (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Eve - REST API for Humans™

  • 1. REST API FOR HUMANS™eve eve
  • 2. nicolaiarocci CoFounder and Lead Dev @C2K Open Source • MongoDB Master • Speaking • CoderDojo • PSF
  • 5. YOU NEED A FULL FEATURED REST API TO EXPOSE YOUR DATA
  • 6. PIP INSTALL EVE TO GET A FEATURE RICH RESTFUL WEB API FOR FREE
  • 8.
  • 9.
  • 10.
  • 12. #1 run.py from eve import Eve app = Eve() ! if __name__ == '__main__': app.run()
  • 13. #2 settings.py # just a couple API endpoints with no custom # schema or rules. Will just dump from people # and books db collections ! DOMAIN = { ‘people’: {} ‘books’: {} }
  • 14. #3 launch the API $ python run.py * Running on http://127.0.0.1:5000/
  • 15. #4 enjoy $ curl -i http://127.0.0.1:5000/people { "_items": [], "_links": { "self": { "href": "127.0.0.1:5000/people", "title": "people" }, "parent": { "href": "127.0.0.1:5000", "title": "home"} } }
  • 16. #4 enjoy $ curl -i http://127.0.0.1:5000/people { "_items": [], "_links": { "self": { "href": "127.0.0.1:5000/people", "title": “people" }, "parent": { "href": "127.0.0.1:5000", "title": “home"} } } HATEOAS AT WORK HERE
  • 17. #4 enjoy $ curl -i http://127.0.0.1:5000/people { "_items": [], "_links": { "self": { "href": "127.0.0.1:5000/people", "title": "people" }, "parent": { "href": "127.0.0.1:5000", "title": "home"} } } CLIENTS CAN EXPLORE THE API PROGRAMMATICALLY
  • 18. #4 enjoy $ curl -i http://127.0.0.1:5000/people { "_items": [], "_links": { "self": { "href": "127.0.0.1:5000/people", "title": "people" }, "parent": { "href": "127.0.0.1:5000", "title": "home"} } } AND EVENTUALLY FILL THEIR UI
  • 19. #4 enjoy $ curl -i http://127.0.0.1:5000/people { "_items": [], "_links": { "self": { "href": "127.0.0.1:5000/people", "title": "people" }, "parent": { "href": "127.0.0.1:5000", "title": "home"} } } EMTPY RESOURCE AS WE DIDN’T CONNECT ANY DATASOURCE
  • 20. settings.py # let’s connect to a mongo instance ! MONGO_HOST = 'localhost' MONGO_PORT = 27017 MONGO_USERNAME = 'user' MONGO_PASSWORD = 'user' MONGO_DBNAME = ‘apitest'
  • 21. settings.py # let’s also add some validation rules ! DOMAIN['people']['schema'] = { 'name': { 'type': 'string', 'maxlength': 50, 'unique': True} 'email': { 'type': 'string', 'regex': '^S+@S+$'}, 'location': { 'type': 'dict', 'schema': { 'address': {'type': 'string'}, 'city': {'type': 'string'}}}, 'born': {'type': ‘datetime'}}
  • 22. settings.py # let’s also add some validation rules ! DOMAIN['people']['schema'] = { 'name': { 'type': 'string', 'maxlength': 50, 'unique': True} 'email': { 'type': 'string', 'regex': '^S+@S+$'}, 'location': { 'type': 'dict', 'schema': { 'address': {'type': 'string'}, 'city': {'type': 'string'}}}, 'born': {'type': ‘datetime'}} THIS REGEX SUCKS. DON’T USE IN PRODUCTION
  • 23. settings.py # allow write access to API endpoints # (default is [‘GET’] for both settings) ! # /people RESOURCE_METHODS = ['GET','POST'] ! # /people/<id> ITEM_METHODS = ['GET','PATCH','PUT','DELETE']
  • 24. settings.py # allow write access to API endpoints # (default is [‘GET’] for both settings) ! # /people RESOURCE_METHODS = ['GET','POST'] ! # /people/<id> ITEM_METHODS = ['GET','PATCH','PUT','DELETE'] ADD/CREATE ONE OR MORE ITEMS
  • 25. settings.py # allow write access to API endpoints # (default is [‘GET’] for both settings) ! # /people RESOURCE_METHODS = ['GET', 'POST'] ! # /people/<id> ITEM_METHODS = ['GET','PATCH','PUT','DELETE'] EDIT ITEM
  • 26. settings.py # allow write access to API endpoints # (default is [‘GET’] for both settings) ! # /people RESOURCE_METHODS = ['GET', 'POST'] ! # /people/<id> ITEM_METHODS = ['GET','PATCH','PUT','DELETE'] REPLACE ITEM
  • 27. settings.py # allow write access to API endpoints # (default is [‘GET’] for both settings) ! # /people RESOURCE_METHODS = ['GET', 'POST'] ! # /people/<id> ITEM_METHODS = ['GET','PATCH','PUT','DELETE'] YOU GUESSED IT
  • 28. settings.py # a few more config options ! DOMAIN[‘people’].update( { ‘item_title’: ‘person’, ‘cache_control’: ‘max-age=10,must-revalidate, ‘cache_expires’: 10, ‘additional_lookup’: { ‘url’: ‘regex)”[w]+”)’, ‘field’: ‘name’ } )
  • 32. SORTING ?sort=[(“total”: -1)] SORT BY ‘TOTAL’, DESCENDING ORDER
  • 37. NOT EMBEDDED $ curl -i <url> ! HTTP/1.1 200 OK {
 "title": "Book Title",
 "description": "book description",
 "author": “52da465a5610320002660f94"
 } RAW FOREIGN KEY (DEFAULT)
  • 38. EMBEDDED $ curl -i <url>?embedded={“author”: 1} ! HTTP/1.1 200 OK {
 "title": "Book Title",
 "description": "book description",
 "author": {
 “firstname”: “Mark”,
 “lastname”: “Green”,
 }
 } REQUEST EMBEDDED AUTHOR
  • 39. EMBEDDED $ curl -i <url>?embedded={“author”: 1} ! HTTP/1.1 200 OK {
 "title": "Book Title",
 "description": "book description",
 "author": {
 “firstname”: “Mark”,
 “lastname”: “Green”,
 }
 } EMBEDDED DOCUMENT
  • 40. JSON AND XML BUILT-IN FOR ALL RESPONSES
  • 41. APPLICATION/JSON [ { "firstname": "Mark", "lastname": "Green", "born": "Sat, 23 Feb 1985 12:00:00 GMT", "role": ["copy", "author"], "location": {"city": "New York", "address": "4925 Lacross Road"}, "_id": "50bf198338345b1c604faf31", "_updated": "Wed, 05 Dec 2012 09:53:07 GMT", "_created": "Wed, 05 Dec 2012 09:53:07 GMT", "_etag": "ec5e8200b8fa0596afe9ca71a87f23e71ca30e2d", }, { "firstname": "John", ... }, ]
  • 42. APPLICATION/JSON [ { "firstname": "Mark", "lastname": "Green", "born": "Sat, 23 Feb 1985 12:00:00 GMT", "role": ["copy", "author"], "location": {"city": "New York", "address": "4925 Lacross Road"}, "_id": "50bf198338345b1c604faf31", "_updated": "Wed, 05 Dec 2012 09:53:07 GMT", "_created": "Wed, 05 Dec 2012 09:53:07 GMT", "_etag": "ec5e8200b8fa0596afe9ca71a87f23e71ca30e2d", }, { "firstname": "John", ... }, ] METAFIELDS ARE CONFIGURABLE
  • 43. APPLICATION/XML <resource href=“localhost:5000/people" title="people"> <resource href="localhost:5000/people/<id>" title="person"> <lastname>Green</lastname> <firstname>Mark</firstname> <born>Wed, 05 Dec 2012 09:53:07 GMT</born> <role>author</role> <role>copy</role> <location> <address>4925 Lacross Road</address> <city>New York</city> </location> <_id>50bf198338345b1c604faf31</_id> <created>Wed, 05 Dec 2012 09:53:07 GMT</created> <updated>Sat, 18 Jan 2014 09:16:10 GMT</updated> <etag>ec5e8200b8fa0596afe9ca71a87f23e71ca30e2d</etag> </resource> ... <resource>
  • 44. HATEOAS HYPERMEDIA AS THE ENGINE OF APPLICATION STATE
  • 45. HATEOAS { “_links”: { “self”: { “href”: “/people”, “title”: “people”}, “parent”: { “href”: “/”, “title”: “home”}, “next”: { “href”: “/people?page=2”, “title”: “next page”}, “last”: { “href: “/people?page=10”, “title”: “last page”} } }
  • 47. FILE STORAGE FILES ARE STORED IN GRIDFS BY DEFAULT
  • 48. FILE STORAGE / SETTINGS accounts = {
 'name': {'type': 'string'},
 'pic': {'type': 'media'},
 …
 }
  • 49. FILE STORAGE $ curl F “name=doe” —F “pic=@profile.jpg" <url> HTTP/1.1 200 OK ! $ curl -i <url> HTTP/1.1 200 OK {
 "name": "john",
 "pic": "/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAA…"
 } MULTIPART/DATA-FORM POST
  • 50. FILE STORAGE $ curl F “name=doe” —F “pic=@profile.jpg" <url> HTTP/1.1 200 OK ! $ curl -i <url> HTTP/1.1 200 OK {
 "name": "john",
 "pic": "/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAA…"
 } FILES RETURNED AS BASE64 STRINGS
  • 51. FILE STORAGE (WITH META) $ curl -i <url> HTTP/1.1 200 OK {
 "name": "john",
 "pic": { “file”: ”/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAA”, “content_type”: “image/jpeg”, “name”: “profile.jpg”, “length”: 8129 }
 } EXTENDED_MEDIA_INFO: TRUE
  • 53. RATE LIMITING / SETTINGS # Rate limit on GET requests: # 1 requests 1 minute window (per client) ! RATE_LIMIT_GET = (1, 60)
  • 54. RATE LIMITING / GET #1 $ curl -i <url> ! HTTP/1.1 200 OK X-RateLimit-Limit: 1 X-RateLimit-Remaining: 0 X-RateLimit-Reset: 1390486659
  • 55. RATE LIMITING / GET #2 $ curl -i <url> ! HTTP/1.1 429 TOO MANY REQUESTS
  • 56. CONDITIONAL REQUESTS ALLOW CLIENTS TO ONLY REQUEST NON-CACHED CONTENT
  • 57. IF-MODIFIED-SINCE If-Modified-Since: Wed, 05 Dec 2012 09:53:07 GMT “Please return modified data since <date> or 304”
  • 59. BULK INSERTS INSERT MULTIPLE DOCUMENTS WITH A SINGLE REQUEST
  • 60. BULK INSERTS / REQUEST $ curl -d ‘ [ { "firstname": "barack", "lastname": “obama" }, { "firstname": "mitt", "lastname": “romney” } ]' -H 'Content-Type: application/json’ <url>
  • 61. BULK INSERTS / RESPONSE [ { "_status": "OK", "_updated": "Thu, 22 Nov 2012 15:22:27 GMT", "_id": "50ae43339fa12500024def5b", "_etag": "749093d334ebd05cf7f2b7dbfb7868605578db2c" "_links": {"self": {"href": “<url>”, "title": "person"}} }, { "_status": "OK", "_updated": "Thu, 22 Nov 2012 15:22:27 GMT", "_id": "50ae43339fa12500024def5c", "_etag": "62d356f623c7d9dc864ffa5facc47dced4ba6907" "_links": {"self": {"href": “<url>", "title": "person"}} } ] COHERENCE MODE OFF: ONLY META FIELDS ARE RETURNED
  • 62. BULK INSERTS / RESPONSE [ { "_status": "OK", "_updated": "Thu, 22 Nov 2012 15:22:27 GMT", "_id": "50ae43339fa12500024def5b", "_etag": "749093d334ebd05cf7f2b7dbfb7868605578db2c" "_links": {"self": {"href": “<url>”, "title": “person”}}, "firstname": "barack", "lastname": "obama", ! }, { "_status": "OK", "_updated": "Thu, 22 Nov 2012 15:22:27 GMT", "_id": "50ae43339fa12500024def5c", "_etag": "62d356f623c7d9dc864ffa5facc47dced4ba6907" "_links": {"self": {"href": “<url>", "title": "person"}} "firstname": "mitt", "lastname": "romney", } ] COHERENCE MODE ON: ALL FIELDS RETURNED
  • 63. DATA INTEGRITY CONCURRENCY CONTROL NO OVERWRITING DOCUMENTS WITH OBSOLETE VERSIONS
  • 64. DATA INTEGRITY / CONCURRENCY $ curl -X PATCH -i <url> 
 -d '{"firstname": "ronald"}'
 HTTP/1.1 403 FORBIDDEN IF-MATCH MISSING
  • 65. DATA INTEGRITY / CONCURRENCY $ curl -X PATCH -i <url>
 -H "If-Match: <obsolete_etag>”
 -d '{"firstname": “ronald”}' ! HTTP/1.1 412 PRECONDITION FAILED
 ETAG MISMATCH
  • 66. DATA INTEGRITY / CONCURRENCY $ curl -X PATCH -i <url>
 -H “If-Match: 206fb4a39815cc0ebf48b2b52d7…”
 -d '{"firstname": “ronald"}' ! HTTP/1.1 200 OK UPDATE ALLOWED IF CLIENT AND SERVER ETAG MATCH
  • 67. DATA VALIDATION [ { "_status": "ERR", "_issues": {“name”: “value ‘clinton’ not unique”} }, { "_status": “OK", "_updated": "Thu, 22 Nov 2012 15:22:27 GMT”, "_id": “50ae43339fa12500024def5c", "_etag": “62d356f623c7d9dc864ffa5facc47dced4ba6907" "_links": { "self": { "href": “<url>”, "title": “person" } } } ]
  • 69. RUNS ON ALL PYTHONS 2.6 / 2.7 / 3.3 / 3.4 and PyPy
  • 70. AND MORE CORS. CACHE CONTROL. VERSONING AND MORE.
  • 73. CUSTOM DATA LAYERS BUILD YOUR OWN DATA LAYER
  • 75. SQLALCHEMY (WIP) @registerSchema('invoices') class Invoices(CommonColumns): __tablename__ = 'invoices' number = db.Column(db.Integer) people = db.Column(db.Integer, db.ForeignKey('people._id'))
  • 79. SECURITY AT A GLANCE • global authentication • custom endpoint auth • public enpoints and methods • role based access control • user restricted resource access
  • 83. #3 PASS CUSTOM CLASS TO THE EVE APP
  • 84. Done
  • 85. CUSTOM VALIDATION EXTEND THE BUILT-IN VALIDATION SYSTEM
  • 86. CUSTOM VALIDATION • add custom data types • add custom validation logic
  • 87. EVENT HOOKS PLUG CUSTOM ACTIONS INTO THE API LOOP
  • 88. EVENT HOOKS AT A GLANCE • POST on_insert/on_inserted • GET on_fetch/on_fetched • PATCH on_update/on_updated • PUT on_replace/on_replaced • DELETE on_delete/on_deteled • on_pre_<method>; on_post_<method>
  • 90. CUSTOM FILE STORAGE custom MediaStorage subclasses to S3, File System, you name it
  • 92. EVE-DOCS GENERATES DOCUMENTATION FOR EVE APIS IN HTML AND JSON FORMATS CHARLES FLYNN
  • 94. EVE-MONGOENGINE ENABLES MONGOENGINE ORM MODELS TO BE USED AS EVE SCHEMA STANISLAV HELLER
  • 95. EVE-ELASTIC ELASTICSEARCH DATA LAYER FOR EVE REST FRAMEWORK PETR JASEK
  • 96. EVE-MOCKER MOCKING TOOL FOR EVE POWERED REST APIS THOMAS SILEO
  • 97. {48: <you name here>} Bryan Cattle Christoph Witzany Daniele Pizzolli dccrazyboy Dong Wei Ming Florian Rathgeber Francisco Corrales Morales Garrin Kimmell Gianfranco Palumbo Jaroslav Semančík Jean Boussier John Deng Jorge Puente Sarrín Josh Villbrandt Julien Barbot Ken Carpenter Kevin Bowrin Kracekumar Nicolas Bazire Nicolas Carlier Ondrej Slinták Petr Jašek Paul Doucet Robert Wlodarczyk Roberto Pasini Ronan Delacroix Roy Smith Ryan Shea Samuel Sutch Stanislav Heller Thomas Sileo Tomasz Jezierski Xavi Cubillas
  • 99. GeoJSON Support and validation for GeoJSON types ! Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometricalCollection
  • 100. JSONP* IN CASE YOUR BROWSER/JS FRAMEWORK CANT HANDLE C.O.R.S. * PENDING SECURITY REVIEW
  • 101. JSON-LD / HAL / SIREN* CURSTOM RENDER CLASSES * MAYBE (UNDER CONSIDERATION)