The User API contains a number of endpoints that are useful for providing basic profile and user mangement features
Used to create a new user account
URL : /v1/user/register
Methods : POST
Auth required : NO
Data constraints
{
"username": "[8 < length < 19]",
"password": "[8 < length < 19]",
"email": "[valid email address]""
}
Data example
{
"username": "pedrobabon",
"password": "1849Sicily",
"email": "[email protected]",
"first_name": "Pedro",
"last_name": "Babon"
}
Code : 200 OK
Content example
{
"username": "pedrobabon",
"email": "[email protected]"
}
Condition : If 'username'/'password'/etc invalid.
Code : 400 BAD REQUEST
Content :
{
"error": "Invalid username/password"
}
Condition : If 'username'/'email' already exist in account.
Code : 400 BAD REQUEST
Content :
{
"error": "account with supplied username/email already exists"
}
Used to log a user in via username-password authentication
URL : /v1/user/login
Methods : GET/POST
Auth required : NO
Data example
{
"username": "pedrobabon",
"password": "1849Sicily"
}
Code : 200 OK
Content example
{
"username": "pedrobabon",
"email": "[email protected]"
}
Condition : If 'username'/'password'/etc does not exist.
Code : 400 BAD REQUEST
Content :
{
"error": "supplied username does not exist"
}
Condition : If 'username'/'email' already exist in account.
Code : 400 BAD REQUEST
Content :
{
"error": "unauthorized"
}
Used to update a user's profile (not including password). Note that any desired fields can be passed in JSON, API figures out updates needed.
URL : /v1/user/update/<username>
Methods : PUT
Auth required : NO
Data example
{
"username": "PEDROBABON",
"password": "1880China"
}
Code : 200 OK
Content example
{
"data_updated": {
"username": "PEDROBABON",
"password": "1880China"
}
}
Condition : If 'username' path parameter does not exist.
Code : 400 BAD REQUEST
Content :
{
"error": "supplied username does not exist"
}
Condition : If update unsucessful already exist in account.
Code : 400 BAD REQUEST
Content :
{
"error": "Update Unsucessful"
}
Used to change a user's password associated with their account
URL : /v1/user/password/<username>
Methods : PUT
Auth required : NO
Data example
{
"password": "18NewEngland"
}
Code : 200 OK
Content example
{
"username": "PEDROBABON"
}
Condition : If password change unsucessful
Code : 400 BAD REQUEST
Content :
{
"error": "Invalid username/password"
}
Fetches all information associated with a user's profile
URL : /v1/user/<username>
Methods : GET
Auth required : NO
Code : 200 OK
Content example
{
"_id": {
"$oid": "doc_id"
},
"first_name": "Pedro",
"last_name": "Babon",
"email": "[email protected]",
"username": "pedrobabon",
"hash": "random_hash",
"salt": "salt_digits",
"pantry": {
"$oid": "pantry_id"
}
}
Condition : If username supplied in path does not exist
Code : 400 BAD REQUEST
Content :
{
"error": "supplied username does not exist"
}
Checks if account corresponding to username exists
URL : /v1/user/<username>
Methods : HEAD
Auth required : NO
Code : 200 OK
Code : 400 BAD REQUEST