Skip to content

Commit 8516a97

Browse files
committed
✨ (What is REST API) Add final REST API endpoints
1 parent 5d81043 commit 8516a97

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

docs/docs/01_course_intro/04_what_is_rest_api/README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,55 @@ The main characteristics (or constraints) of a REST API are:
110110
4. **Cacheable**. The client or server must be able to cache the resources returned by the API. This is a very general constraint, but it's an important one.
111111
5. **Layered system**. REST APIs may be developed as multiple layers, where each layer interacts [only with the layer above and below it](https://excalidraw.com/#json=or3Umoigss4yIeuKg3cO8,qH6uDDCXc7DSjweqNvlmzw).
112112

113-
If you'd like to read a very complete and exhaustive guide about everything that a REST API is, check out [this guide](https://restfulapi.net/).
113+
If you'd like to read a very complete and exhaustive guide about everything that a REST API is, check out [this guide](https://restfulapi.net/).
114+
115+
## The API we'll build in this course
116+
117+
In this course we'll build a REST API to expose interactions with stores, items, tags, and users. The API will allow clients to:
118+
119+
- Create and retrieve information about stores.
120+
- Create, retrieve, search for, update, and delete items in those stores.
121+
- Create tags and link them to items; and search for items with specific tags.
122+
- Add user authentication to the client apps using the API.
123+
124+
The API will have these endpoints:
125+
126+
- Users
127+
- `POST /register` to create user accounts given an `email` and `password`.
128+
- `POST /login` to get a JWT given an `email` and `password`.
129+
- `POST /logout` to revoke a JWT.
130+
- `POST /refresh` to get a fresh JWT given a refresh JWT.
131+
- `GET /user/{user_id}` (dev-only) to get info about a user given their ID.
132+
- `DELETE /user/{user_id}` (dev-only) to delete a user given their ID.
133+
- Stores
134+
- `GET /stores` to get a list of all stores.
135+
- `POST /stores` to create a store.
136+
- `GET /stores/{id}` to get a single store, given its unique id.
137+
- `DELETE /stores/{id}` to delete a store, given its unique id.
138+
- Items
139+
- `GET /items` to get a list of all items in all stores.
140+
- `POST /items` to create a new item, given its name and price in the body of the request.
141+
- `GET /items/{id}` to get information about a specific item, given its unique id.
142+
- `PUT /items/{id}` to update an item given its unique id. The item name or price can be given in the body of the request.
143+
- `DELETE /items/{id}` to delete an item given its unique id.
144+
- Tags
145+
- `GET /stores/{id}/tags` to get a list of tags in a store.
146+
- `POST /stores/{id}/tags` to create a new tag.
147+
- `POST /items/{id}/tags` to link an item in a store with a tag from the same store. This will take a list of tags in the body of the request so clients can link one or more tags at the same time.
148+
- `DELETE /items/{item_id}/tags/{tag_id}` to unlink a tag from an item.
149+
- `GET /tags/{id}` to get information about a tag given its unique id.
150+
- `DELETE /tags/{id}` to delete a tag, which must have no associated items.
151+
152+
As you can see, we've got a lot to build!
153+
154+
We'll start building REST APIs in section 3, "Your first REST API". Here we'll create a simpler version of the REST API detailed above, without tags or user authentication.
155+
156+
Then, over the following sections, we'll improve on this REST API. We'll add:
157+
158+
- Flask extensions to simplify our code.
159+
- Use Docker to run the API more reliably.
160+
- Use PostgreSQL for data storage.
161+
- Add user authentication.
162+
- Add item tagging.
163+
- Add an admin panel so changing data manually is a bit easier.
164+
- And much more!

docs/src/css/custom.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
--ifm-color-primary-light: #33925d;
1414
--ifm-color-primary-lighter: #359962;
1515
--ifm-color-primary-lightest: #3cad6e;
16-
--ifm-code-font-size: 95%;
16+
--ifm-code-font-size: 90%;
17+
--ifm-code-padding-horizontal: 0.3rem;
18+
--ifm-code-padding-vertical: 0.15rem;
19+
--ifm-code-border-radius: 5px;
1720
}
1821

1922
/* For readability concerns, you should choose a lighter palette in dark mode. */
@@ -36,4 +39,4 @@
3639

3740
[data-theme='dark'] .docusaurus-highlight-code-line {
3841
background-color: rgba(0, 0, 0, 0.3);
39-
}
42+
}

0 commit comments

Comments
 (0)