Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Django Rest Framework

Django Rest Framework

Derek Stegelman

September 15, 2015
Tweet

More Decks by Derek Stegelman

Other Decks in Technology

Transcript

  1. DJANGO REST DJANGO REST FRAMEWORK FRAMEWORK BUILDING BEAUTIFUL APIS BUILDING

    BEAUTIFUL APIS / Derek Stegelman @derekstegelman Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 1 of 26 9/14/15, 8:14 PM
  2. DEREK STEGELMAN DEREK STEGELMAN Sr. Web Application Developer at Kansas

    State University Python/Django for 5 years GitHub Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 2 of 26 9/14/15, 8:14 PM
  3. GOALS GOALS Understand the what and why of Web APIs

    Basics of REST Basics of building APIs with Django and DRF Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 3 of 26 9/14/15, 8:14 PM
  4. WHAT IS AN API? WHAT IS AN API? Django Rest

    Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 4 of 26 9/14/15, 8:14 PM
  5. API API Application Programming Interface Allows communication between components and

    systems. A web based API is simply one example of an API. Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 5 of 26 9/14/15, 8:14 PM
  6. WHY DO I NEED AN API? WHY DO I NEED

    AN API? Allow other websites/apps to interact with your data Build "microsites" with tools like AngularJS (front end frameworks) Build apps for Phones or other devices for your core product Web becomes a platform like Desktop, Phone, etc Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 6 of 26 9/14/15, 8:14 PM
  7. WHAT EXACTLY IS A WHAT EXACTLY IS A RESTFUL API?

    RESTFUL API? Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 7 of 26 9/14/15, 8:14 PM
  8. REPRESENTATIONAL STATE TRANSFER (REST) REPRESENTATIONAL STATE TRANSFER (REST) High performance,

    sacalable web services Focus on HTTP verbs Using the web as intended Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 8 of 26 9/14/15, 8:14 PM
  9. HTTP VERBS/CRUD HTTP VERBS/CRUD Create: POST Read: GET Update: PUT

    or PATCH Delete: DELETE Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 9 of 26 9/14/15, 8:14 PM
  10. OKAY, SO... OKAY, SO... WHAT'S SO AWESOME ABOUT REST? WHAT'S

    SO AWESOME ABOUT REST? Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 10 of 26 9/14/15, 8:14 PM
  11. RESTFUL APIS RESTFUL APIS It's simple, its just HTTP Easy

    integration, just make a HTTP request Easily predictable Easy standard to get behind, has wide adoption Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 11 of 26 9/14/15, 8:14 PM
  12. CONCLUSION: THESE ARE BUILT INTO THE WEB, CONCLUSION: THESE ARE

    BUILT INTO THE WEB, LET'S USE THEM! LET'S USE THEM! Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 12 of 26 9/14/15, 8:14 PM
  13. LET'S BUILD AN API LET'S BUILD AN API (WITH DJANGO)

    (WITH DJANGO) Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 13 of 26 9/14/15, 8:14 PM
  14. LOTS OF FRAMEWORKS TO CHOOSE FROM LOTS OF FRAMEWORKS TO

    CHOOSE FROM Piston (originally written for Bitbucket) Tastypie (old standard, good solid development, lacks easy customization) Django Rest Framework (accepted standard way in Django, easy to use, browseable API, Kickstater funding) Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 14 of 26 9/14/15, 8:14 PM
  15. DJANGO REST FRAMEWORK DJANGO REST FRAMEWORK Django REST framework is

    a powerful and flexible toolkit that makes it easy to build Web APIs. Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 15 of 26 9/14/15, 8:14 PM
  16. WHY USE IT? WHY USE IT? Django Rest Framework Talk

    file:///Users/derekst/Developer/code/github/rest-framework/pres... 16 of 26 9/14/15, 8:14 PM
  17. DJANGO REST FRAMEWORK DJANGO REST FRAMEWORK Browsebale API Authentication and

    Authorization Policies Serialization that supports both ORM and non-ORM data sources. Customizable/Extensible Extensive documentation, and great community support. Used and trusted by large companies such as Mozilla and Eventbrite. Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 17 of 26 9/14/15, 8:14 PM
  18. BROWSEABLE API BROWSEABLE API WHAT AND WHY? WHAT AND WHY?

    A browsebale API allows users to view and make calls to your API through a web interface Gathers buy in for your product Makes life easier for those consuming the API, and cuts down on support time for developers Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 18 of 26 9/14/15, 8:14 PM
  19. BROWSEBALE API DEMO BROWSEBALE API DEMO Django Rest Framework Talk

    file:///Users/derekst/Developer/code/github/rest-framework/pres... 19 of 26 9/14/15, 8:14 PM
  20. AUTHENTICATION AND AUTHORIZATION AUTHENTICATION AND AUTHORIZATION Django Rest Framework Talk

    file:///Users/derekst/Developer/code/github/rest-framework/pres... 20 of 26 9/14/15, 8:14 PM
  21. AUTHENTICATION AUTHENTICATION Built in support for Token, Basic and Session.

    Community packages for Oauth, Oauth2, JSON Web Token, others Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 21 of 26 9/14/15, 8:14 PM
  22. AUTHORIZATION AUTHORIZATION Built in ORM based permissions (actions on Django

    models) Easy to build in custom permissions per view, etc Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 22 of 26 9/14/15, 8:14 PM
  23. SERIALIZATION SERIALIZATION Built in serialization of Django/ORM objects Easy customization

    and extension of serializers Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 23 of 26 9/14/15, 8:14 PM
  24. SERIALIZERS SERIALIZERS class AreaSerializer(serializers.ModelSerializer): campus_organization = serializers.SerializerMethodField() def get_campus_organization(self, obj):

    return obj.student_organization class Meta: model = Area fields = ('name', 'slug', 'url', 'campus_organization') Django Rest Framework Talk file:///Users/derekst/Developer/code/github/rest-framework/pres... 24 of 26 9/14/15, 8:14 PM