API Specification

Contributors: Alicia Wang, Conner Swenberg

Values wrapped in < > are placeholders for what the field values should be. Also be sure to read the request route carefully when you implement it.

The server should return an error response for:

  • POST requests, if the user does not supply one of the fields in the body (e.g. name, username, etc.) with a status code of 400 (bad request)

  • GET , POST and DELETE requests, if the requested resource in the URL does not exist, with a status code of 404 (not found)

Expected Functionality

Get all users

GET/api/users/

Response
<HTTP STATUS CODE 200>
{
    "users": [
        {
            "id" 1,
            "name": "Conner",
            "username": "cswenberg",
        },
        {
            "id": 2,
            "name": "Alicia",
            "username": "aawang",
        },
        ...
    ]
}

Create a user

POST/api/users/

You can give a default value of 0 for a key that does not exist for a dictionary like so: body.get("balance", 0)

Get a specific user

GET/api/user/{id}/

Delete a specific user

DELETE/api/user/{id}/

Send money from one user to another

POST/api/send/

If the client does not provide a sender_id, receiver_id, amount, or any combination of those, respond with a descriptive error message and a 400 status code.

When checking if the user actually sent in a sender_id, you should check if sender_id is not None, instead of not sender_id. This is because the number zero is a false-y value, which means not sender_id will return True, even though the user did supply an id, albeit a value of zero. If this is still confusing, consider using bool() in a Python shell:

Last updated

Was this helpful?