virtualenv env
source env/bin/activate
pip install django
pip install djangorestframework
pip install django-filter
pip install drf-nested-routers
Add in INSTALED_APPS :
- rest_framework
- favorite
- create model Favorite
- create FavoriteSerializer
- create ModelSerializer
- create list favorite view
- create detail favorite view
- create urls favorite
- includes urls in tutorial
- using api_view decorator
- add format_suffix_patterns
- create FavoriteList
- create FavoriteDetail
- change urls.py
- change FavoriteList
- change FavoriteDetail
- change FavoriteList
- change FavoriteDetail
- add field owner in model
- add permissions IsOwnerOrReadOnly
- add field owner in FavoriteSerializer
- add UserSerializer
- change favorite/urls.py
- add UserList and UserDetail
- add permission_classes in FavoriteList and FavoriteDetail
- add method perform_create
- change tutorial/urls.py
- creating an endpoint for the root of our API
- hyperlinking our API
- URL patterns are named
- refactoring to use ViewSets
- binding ViewSets to URLs explicitly
- using Routers
- change serializer
- change favorite/urls.py
- change views
- change serializer
- change views
-
Use nouns but no verbs
-
GET method and query parameters should not alter the state
-
Use plural nouns
-
Use sub-resources for relations
-
Use HTTP headers for serialization formats
-
Use HATEOAS
-
Provide filtering, sorting, field selection and paging for collections
-
Version your API
-
Handle Errors with HTTP status codes
-
Allow overriding HTTP method
10 Best Practices for Better RESTful API
The first is the main API providers: Facebook, Instagran, Twitter, Google ...
Facebook example:
Clicking on facebook provider, takes you to a kind of simple documentation, which is listed all the features of the Facebook API.
Click any of the resources takes you to a console where you can do testing.
In this console there is a dropdown where it listed all the APIs provided in this site.
The second is a kind of journal of APIs.