Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

API Design Using django/tastypie/mongoDB

No description
by

Tayfun Sen

on 31 March 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of API Design Using django/tastypie/mongoDB

django
Tastypie / MongoDB API Design Tayfun Sen
31 March 2013 A bit about me Worked at Markafoni
Worked at JotForm
Studied at METU @tayfunsen http://blog.tayfunsen.com Plan Prezi in English, talking in Turkish
Some basics about APIs
Where does tastypie/mongoDB fit in?
Questions / Answers What's an API? Program using other programs
In line with the rise of JavaScript
nodejs, backbone.js ...
One page (web) applications
Mobile, interoperability etc. Application Programming Interface
[1] [1] See http://thediagram.com/12_6/rev_reitz.html SOAP Simple Object Access Protocol
Simple, yeah right!
WSDL, XML, XSD, UDDI ... REST Representational State Transfer
Say what? vs GET and POST methods
XML data format
Functions are the key SOAP REST Utilizes all HTTP methods:
GET, POST; but also PUT, DELETE,
and even PATCH
One endpoint for each "resource"
Different than RPC's function oriented view
JSON preferred over XML REST Each method has a meaning.
POST -> create a new resource
DELETE -> delete a resource
PUT -> replace the whole resource
PATCH -> change some part of resource
GET -> view a resource REST List vs Detail URLs:
/product/ -> List URL
/product/1/ -> Detail URL There's more! Requirements Versioning
Pagination
Authentication
Authorization
Filtering/Sorting
Validation
Caching
JSON vs XML?
Throttling? Simple REST API run standalone or using uWSGI etc.
/usr/local/bin/uwsgi --http :9090 --wsgi-file simple_server.py You need more help! Django - batteries incl. Two main contenders:
django-rest-framework and tastypie
Used tastypie in two projects
They solve requirements outlined previously versioning: just add a name to urls.py
pagination: handled by default through the meta header
authentication and authorization hooks are there
filtering and sorting similar to django ORM
validation done through django forms
data format could be JSON or XML, configurable Caching DB will be the bottleneck
Cache relentlessly
redis and MongoDB could be used
Sorting/filtering capabilities of MongoDB is delightful How to? Two methods:
Add a new/custom MongoResource to default resources provided by tastypie
Use mongoengine which provides an API similar to django ORM and tastypie_mongoengine for using it through tastypie Gotchas Cache invalidation is hard!
Authorization (fine grained) could be complicated - mostly because permissions implementation by django does not map directly. view permissions for example [1] Example Q & A Thanks for coming :-)
I hope you have seen how easy it is to start
Some advanced stuff could take time though! Let me know: ts@tayfunsen.com Lego minecraft photo by Dunechaser: http://www.flickr.com/photos/dunechaser/6884829633/ by-nc-sa licenced. [1] https://docs.djangoproject.com/en/dev/topics/auth/default/#topic-authorization @tayfunsen http://blog.tayfunsen.com
Full transcript