https://djangoproject-straycattle.herokuapp.com/
The server will respond to the listed API endpoints with the appropriate response. For other endpoints, unlisted or incorrectly used, the server will respond with a INVALID_ROUTE
response.
Endpoint | Purpose |
---|---|
auth/ |
Handles user authentication (register, login) |
reports/ |
Handles reports uploaded by citizens (CRUD) |
geocoding/ |
Handles geocoding operations |
For other URLs, you may receive a INVALID_ROUTE
response.
User-specific actions will require JWT Authorization. To pass JWT to the request, send the JWT token in the request's header, like this:
'authorization': 'Bearer <---jwt---->'
Example:
{
"authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoyfQ.j7fLGPF4VOS4uGUP6hgKTPkAHPcEz3WrVvg1RYNWZI4"
}
(in the request's header)
Endpoints:
Endpoint | Purpose |
---|---|
auth/register |
Create a new account |
auth/login |
Login to an account |
Endpoint: POST /auth/register
Parameters (in POST body):
-
phone
(required) - User's phone number -
password
(required) - User's password -
account_type
(optional) - Can be eithercitizen
orauthority
Example:
POST https://djangoproject-straycattle.herokuapp.com/auth/register
with phone=123
, password=123
(creates a user with phone number 123, and password 123)
Response:
{
"data": {
"jwt": "---jwt_token---",
"phone": "123",
"account_type": "citizen"
},
"error": null
}
Endpoint: POST /auth/login
Parameters (in POST body):
-
phone
(required) - User's phone number -
password
(required) - User's password
Example:
POST https://djangoproject-straycattle.herokuapp.com/auth/login
with phone=123
, password=123
(returns user details w/ jwt if user exists)
Response:
{
"data": {
"jwt": "---jwt_token---",
"phone": "123",
"account_type": "citizen"
},
"error": null
}
Endpoint: POST /reports/add
(User must be authenticated with JWT)
Parameters (in POST body):
-
latitude
(required) - Latitude in decimal -
longitude
(required) - Longitude in decimal -
images
(required) - List (array) of URLs (in JSON-encoded string format) - Pass it through a JSON validator to check if it is right
Example:
POST https://djangoproject-straycattle.herokuapp.com/reports/add
with:
Header containing:
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXlsb2FkIjoyfQ.j7fLGPF4VOS4uGUP6hgKTPkAHPcEz3WrVvg1RYNWZI4
Body containing:
latitude=0
& longitude=0
& images=["http://images.gg.com/445.jpg","http://example.image.org/2334.jpg"]
(returns success message if report is added)
Response:
{
"data": {
"success": true,
"action_name": "ADD_REPORT"
},
"error": null
}