-
Notifications
You must be signed in to change notification settings - Fork 0
API v1
Russel Mahmud edited this page Dec 19, 2015
·
17 revisions
-
Login (POST)
- Permission
Public
- Headers
- Authorization - "Basic base64-user-pass(user:pass)"
- Permission
- LogOut (DELETE)
-
-
Collection (GET)
- Permission
Authenticated User
- Example Request :
curl -H "Authorization: Basic cnVzc2VsOmFkbWluYWRtaW4=" localhost:8000/api/v1/customers/
- Example Response :
{ "count": 1, "next": null, "previous": null, "results": [ { "id": 2, "username": "russel", "first_name": "Russel", "last_name": "Mahmud", "email": "[email protected]" } ] }
- Permission
Staff
- Example Response :
{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "username": "admin", "first_name": "Admin", "last_name": "User", "email": "[email protected]" },{ "id": 2, "username": "russel", "first_name": "Russel", "last_name": "Mahmud", "email": "[email protected]" } ] }
- Permission
-
Collection (GET)
-
Create (POST)
- Permission
Public
- Fields :
- username
- first_name (optional)
- last_name (optional)
- password
- Example Request :
curl -X POST -H "Content-Type: application/json" -d '{"username":"test1","password":"test1test1","email":"[email protected]"}' localhost:8000/api/v1/customers/
- Example Response :
status_code : 201 { "id": 9, "username": "russel", "first_name": "Russel", "last_name": "Mahmud", "email": "[email protected]" }
- Permission
-
-
Read (GET)
- Permission
Authenticated User
- Example Request :
curl -H "Authorization: Basic dGVzdDE6dGVzdDF0ZXN0MQ==" localhost:8000/api/v1/customers/11/
- Example Response :
{ "id": 9, "username": "russel", "first_name": "Russel", "last_name": "Mahmud", "email": "[email protected]" }
- Permission
-
Partial Update (PATCH)
- Permission
Authenticated User
- Permission
-
-
-
Collection (GET)
- Permission
Public
- Example Request :
curl localhost:8000/api/v1/products/
- Example Response :
{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "name": "iPad", "quantity": 5, "unit_price": "350.00" },{ "id": 1, "name": "iPad", "quantity": 5, "unit_price": "350.00" } ] }
- Permission
-
Collection (GET)
-
-
Read (GET)
- Permission
Public
- Example Request :
curl localhost:8000/api/v1/products/2/
- Example Response :
{ "id": 1, "name": "iPad", "quantity": 5, "unit_price": "350.00" }
- Permission
-
Read (GET)
It will work only browser based session authentication.
-
Read (GET)
- Permission
Authenticated User
- Example Response :
{ "checked_out": false, "total_price": "1800.00", "items": [ { "product": 4, "quantity": 1, "unit_price": "300.00", "total_price": "300.00" }, { "product": 2, "quantity": 2, "unit_price": "750.00", "total_price": "1500.00" } ] }
- Permission
-
Add (POST)
- Permission
Authenticated User
- Fields :
- product
- quantity (optional)
- Permission
-
Update (PUT)
- Permission
Authenticated User
- Fields :
- product
- quantity (optional)
- Permission
-
Remove (DELETE)
- Permission
Authenticated User
- Body Fields:
- product
- Permission