Plio uses the Django REST framework package to provide the REST API to it's consumers.
This guide aims to provide details on how Plio is using the REST framework and pre-requisites for someone contributing to the code.
- Clone the project and start the Django server as mentioned in our installation guide.
- Navigate to
0.0.0.0:8001/api/v1/docs
in your browser and you should see the Plio's detailed API documentation.
- Create a super user for your backend application. It will ask to set the super user credentials.
docker-compose exec web python manage.py createsuperuser
- Login to Django admin dashboard from
http://0.0.0.0:8001/admin
and enter your credentials. - Add a new Application using the Add button next to
Applications
underDJANGO OAUTH TOOLKIT
with the following configuration:client_id
andclient_secret
should be left unchanged- user should be your superuser ID
redirect_uris
should be left blankclient_type
should be set to confidentialauthorization_grant_type
should be set to 'Resource owner password-based'- name should be "plio" (all lowercase)
- Use the client id and client secret in your frontend application or Postman app to make API calls.
Plio considers every entity in the models (or in database) as a resource. A resource can have the following operations (LCRUD) that can be run at corresponding route format & request method.
Action | Route format | Method |
---|---|---|
List | /{resource}/ |
GET |
Create | /{resource}/ |
POST |
Retrieve | /{resource}/{id} |
GET |
Update | /{resource}/{id} |
PUT |
Partial update | /{resource}/{id} |
PATCH |
Delete | /{resource}/{id} |
DELETE |
In this codebase, resources are users, organizations, plio, items, events, tags, experiments etc. So for user, replace {resource}
with user
and {id}
by the user id.
For more details on routing, visit Django REST Framework's official documentation.
The codebase uses various Django's concepts to provide a rich and meaningful REST API: