-
Notifications
You must be signed in to change notification settings - Fork 0
Requests
These requests will be written in this way (click words for info on that subject):
VERB /path/to/resource HTTP/1.1
Header1: HeaderValue
Header2: HeaderValue
Header3: HeaderValueRequest Body
Things that you need to replace with your own values with have '%' symbols around them (Eg. %username%)
All valid paths support an OPTIONS request
This request creates an account on the server
POST /api/users HTTP/1.1
Authorization: Basic %credentials%
%credentials% should be replaced with the registration details in the format username:password
encoded in base64
Responses:
201 Created: Registration was successful
409 Conflict: Username is taken
This request obtains a bearer token which is used to perform all other requests
GET /auth HTTP/1.1
Authorization: Basic %credentials%
%credentials% should be replaced with the login details in the format username:password
encoded in base64
Responses:
200 Ok: Login was successful and the response body will contain the bearer token
401 Unauthorized: The provided credentials were invalid
This requests gets all of a users tasks
GET /api/tasks HTTP/1.1
Authorization: Bearer %token%
%token% should be replaced will the bearer token obtained from sending a login request
Responses:
200 Ok: Request was successful and the body will contain a JSON list containing all of the users tasks
401 Unauthorized: The provided token was invalid
Gets a specific task
GET /api/tasks/%task_id% HTTP/1.1
Authorization: Bearer %token%
%token% should be replaced will the bearer token obtained from sending a login request
%task_id% should be replaced with the id of the task you would like to get.
Responses:
200 Ok: Request was successful and the response body will contain the JSON of the requested task
204 No Content: The requested task doesn't exist
401 Unauthorized: The provided token was invalid
Creates a task or overwrites an existing task
PUT /api/tasks HTTP/1.1
Authorization: Bearer %token%%task_json%
%token% should be replaced will the bearer token obtained from sending a login request
%task_json% should be replaced with a JSON object of a task. To overwrite a task add the id
key with a value of the task you want to overwrite's id to the JSON
Responses:
201 Created: Request was successful and the task was created/overwritten
400 Bad Request: Some of the information you submited was rejected, the response body will contain information regarding what went wrong
401 Unauthorized: The provided token was invalid
Deletes the specified task
DELETE /api/tasks/%task_id% HTTP/1.1
Authorization: Bearer %token%
%token% should be replaced will the bearer token obtained from sending a login request
%task_id% should be replaced by the id of the task you would like to delete
Responses:
204 No Content: Request was successful and the task was deleted
404 Not Found: The specified task was not found
401 Unauthorized: The provided token was invalid
403 Forbidden: You don't have permission to access that task
Edits the specified task
PATCH /api/tasks/%task_id% HTTP/1.1
Authorization: Bearer %token%%patch_data%
%token% should be replaced will the bearer token obtained from sending a login request
%patch_data% should be replaced by instructions on how to modify the data. Example: [{"op":"replace", "path":"class", "value":"New class name"}]
, in this example the class value of the task will be modified to be New class name
Responses:
200 Ok: Request was successful and the task was edited
404 Not Found: The specified task was not found
400 Bad Request: Some of the information you submited was rejected, the response body will contain information regarding what went wrong
401 Unauthorized: The provided token was invalid
403 Forbidden: You don't have permission to access that task
Gets the JSON data for a user from their username (you must have a valid token for that user still)
GET /api/users?username=%username% HTTP/1.1
Authorization: Bearer %token%
%token% should be replaced will the bearer token obtained from sending a login request
%username% should be replaced with the username of the user you wish to get information from, you MUST have a valid authentication token for that user
Responses:
200 Ok: Request was successful and the response body will contain the JSON user object that was requested
204 No Content: The specified user was not found
401 Unauthorized: The provided token was invalid or you don't have access to that user
Deletes the specified user
DELETE /api/tasks/%user_id% HTTP/1.1
Authorization: Bearer %token%
%token% should be replaced will the bearer token obtained from sending a login request
%user_id% should be replaced with the id of the user who the bearer token belongs to
Responses:
200 No Content: Request was successful and the task was edited
401 Unauthorized: The provided token was invalid
Edits the specified user
PATCH /api/tasks/%user_id% HTTP/1.1
Authorization: Bearer %token%%patch_data%
%token% should be replaced will the bearer token obtained from sending a login request
%user_id% should be replaced with the id of the user who the bearer token belongs to
%patch_data% should be replaced by instructions on how to modify the data. Example: [{"op":"replace", "path":"username", "value":"myFancyNewUsername"}]
, in this example the username of the user will be modified to be myFancyNewUsername
Responses:
200 Ok: Request was successful and the user details were edited
409 Conflict: The specified username is taken
400 Bad Request: The patch data is invalid
401 Unauthorized: The provided token was invalid