The idea behind this project was to build an API that could complete the basic CRUD operations on 'longboard' objects that are stored in a Shelve database. The following is the base 'longboard' object:
{
"id": "XXX",
"name": "XXXXX",
"length": "XX",
"width": "XX"
}The project is divided into two sections:
- Java
On the Java side is the swift GUI and the HTTP methods using Unirest that are used by the GUI. - Python
On the Python side is the API itself. It is built with Flask and Flask-RESTful. In order to run the Java GUI, the Flask application is run locally.
The following are the possible endpoints and their possible requests:
-
To all longboards-
GET /longboards
POST /longboards
OPTIONS /longboards
DELETE /longboards -
To a specific longboard-
GET /longboard/{identifier}
HEAD /longboard/{identifier}
DELETE /longboard/{identifier}
PUT /longboard/{identifier}
PATCH /longboard/{identifier}
OPTIONS /longboard/{identifier}
I determined which status code to return based on the following information provided here.
200OK
Standard response for successful HTTP requests.201Created
The request has been fulfilled, resulting in the creation of a new resource.204No Content
The server successfully processed the request and is not returning any content.400Bad Request
The server cannot or will not process the request due to an apparent client error404Not Found
The requested resource could not be found but may be available in the future.
There are two main sources of information that helped me incredibly: Jake Wright and Assertible. Thanks for helping me learn more about APIs!
Links to images:
Links to sounds: