Open endpoints require no Authentication.
Register : POST /api/register/
Get the details of the currently Authenticated User along with basic subscription information.
URL : /api/register/
Method : POST
Auth required : NO
Permissions required : None
Data constraints
Email must be unique.
{
"email": "[unicode 255 chars max]"
}
Data example
All fields must be sent.
{
"first_name": "Peter",
"last_name": "Griffin",
"email": "BirdIsTheWord@quahog.com",
"password": "Tom Brady"
}
Code : 201 CREATED
Content examples
{
"id": 5,
"first_name": "Peter",
"last_name": "Griffin",
"email": "BirdIsTheWord@quahog.com",
"password": "$2a$10$vncwoY0avJfBxYCCBv3wDeSZw51hrqhXCDkfJA22m6zckcyGjoVY6"
}
Condition : If Account already exists for User.
Code : 500 SEE OTHER
Headers : Location: http://testserver/api/accounts/123/
Content : {}
Condition : If fields are missed.
Code : 400 BAD REQUEST
Content example
{
"first_name": [
"This field is required."
]
}
Login : POST /api/login/
Used to collect a Token for a registered User.
URL : /api/login/
Method : POST
Auth required : NO
Data constraints
{
"username": "[valid email address]",
"password": "[password in plain text]"
}
Data example
{
"username": "iloveauth@example.com",
"password": "abcd1234"
}
Code : 200 OK
Content example
{
"token": "93144b288eb1fdccbe46d6fc0f241a51766ecd3d"
}
Condition : If 'username' and 'password' combination is wrong.
Code : 400 BAD REQUEST
Content :
{
"non_field_errors": [
"Unable to login with provided credentials."
]
}
Closed endpoints require a valid Token to be included in the header of the request. A Token can be acquired from the Login view above.
Each endpoint manipulates or displays information related to the User whose Token is provided with the request:
- Show user info :
GET /api/user/
- Update user info :
PUT /api/user/
Get User Settings : GET /api/user/settings
Get the settings for the currently authenticated user.
URL : /api/user/settings
Method : GET
Auth required : YES
Permissions required : Authentication Token
Data constraints Authentication token must be valid and match current user id.
Code : 200 OK
Content examples
{
"id": 99,
"settings": {
"mood": {
"Indicative": true,
"Subjunctive": false,
"Imperative Affirmative": true,
"Imperative Negative": true
},
"tense": {
"Present": true,
"Future": true,
"Imperfect": true,
"Preterite": true,
"Conditional": true,
"Present Perfect": false,
"Future Perfect": true,
"Past Perfect": true,
"Preterite (Archaic)": true,
"Conditional Perfect": true
},
"vosotros": false
}
}
Condition : Server error, likely could not user in db.
Code : 500 INTERNAL SERVER ERROR
Content example
{
"err": {},
"message": "Ay dios mio!"
}
Update User Settings : PUT /api/user/settings
Update the settings for the currently authenticated user.
URL : /api/user/settings
Method : PUT
Auth required : YES
Permissions required : Authentication Token
Data constraints None
Data example
Must contain settings object with all required fields.
{
"mood": {
"Indicative": false,
"Subjunctive": false,
"Imperative Affirmative": true,
"Imperative Negative": true
},
"tense": {
"Present": true,
"Future": true,
"Imperfect": true,
"Preterite": true,
"Conditional": true,
"Present Perfect": true,
"Future Perfect": true,
"Past Perfect": true,
"Preterite (Archaic)": true,
"Conditional Perfect": true
},
"vosotros": false
}
Code : 200 OK
Content examples
{
"success": true,
"records_updated": 1,
"message": "Hurra! Bueno! Peter, your settings have been updated."
}
Condition : Server error, likely could not user in db.
Code : 500 INTERNAL SERVER ERROR
Content example
{
"err": {},
"message": "Ay dios mio!"
}
Endpoints for viewing and manipulating the Accounts that the Authenticated Admin User has permissions to access.
- Master user list :
GET /api/admin/users
field | data type | metadata |
---|---|---|
id | unsigned integer | primary key, auto-increments, generated by database |
first_name | string | required |
last_name | string | required |
string | required | |
password | string | required |