API design
You will work with your web application team for this assignment.
Goals
- Prepare a first draft design for the API that will provide the data your web application needs.
- Practice using a few simple API design principles.
Rubric
Where the API fits in your overall project
For this project, we will use an organization in which sometimes the user's browser asks your application for pages for the user to view, and sometimes the user's browser asks your API for data, which gets incorporated into the browser display.
How all this works is coming up over the next few weeks. But for now, we want to focus our attention on the data you have chosen for your project.
- What questions will your application and its user want to ask of your dataset?
- How can those questions be articulated in the form of API endpoints?
Some example endpoints
Example 1: Olympic sports
Suppose I want to populate a drop-down list with the alphabetized list of Olympic sports. Then I might want my API to include an endpoint like this:
(By the way, using an API endpoint to populate a drop-down list is preferable to hard-coding the list of sports in a web page, because the application would adapt automatically if the 2026 winter games added a new sport, like "Below-Freezing Flagpole-Licking".)
Example 2: books and authors
Suppose my application includes a Search button to let me search for all the books whose titles contain my search string. Then my browser may want to ask my API a question like this:
or, depending on your preference and your other endpoints:
Either way, you will want to describe the API response format like so:
Here's another example endpoint for this dataset with a more thorough demonstration of the documentation style I would like you to use. (The pros use web-based documentation like Swagger/APIHub or PortSwigger, but for now, let's try to keep the number of new tools for you to learn capped at "about a million" instead of "about a billion".)
Of course, this API would have many different endpoints,
not just /books.
Your tasks
For this assignment you're going to decide, based on your user stories and wireframes, what endpoints your API will probably require. You'll then document those endpoints.
More specifically, create a file called api-design.txt
in your doc directory. This file should contain:
- Your names
- Documentation for a list of API endpoints. Use REQUEST and RESPONSE descriptions like those above. Shoot for the neighborhood of 2-5 endpoints, depending on the nature of your dataset.
By the way...
If we were a startup and I were your manager, at this stage of the project I would also require you to write a suite of unit tests for the API. For this project, I am not going to require unit tests yet, but we'll get there.