REST API
REST API URI Patterns
| URI Pattern | HTTP Method | Description |
|---|---|---|
/products |
GET | Retrieve a list of all products. |
/products/{productId} |
GET | Retrieve details of a specific product by its ID. |
/products |
POST | Create a new product. |
/products/{productId} |
PUT | Update an existing product by its ID. |
/products/{productId} |
DELETE | Delete a specific product by its ID. |
/users/{userId}/products |
GET | Retrieve products associated with a specific user. |
/users/{userId}/products/{productId} |
GET | Retrieve details of a specific product associated with a user. |
/products/{productId}/related |
GET | Retrieve related products for a specific product. |
This table outlines common URI patterns for managing products in a REST API, along with the corresponding HTTP methods that define the actions that can be performed on those URIs. Each URI is designed to clearly represent the resource it interacts with, following best practices for RESTful API design.
Citations:
[1] https://stackoverflow.com/questions/44415000/rest-api-url-pattern-design
[2] https://learn.microsoft.com/en-us/azure/architecture/best-practices/api-design
[3] https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API
[4] https://restfulapi.net/resource-naming/
[5] https://www.ibm.com/docs/en/was/8.5.5?topic=applications-defining-uri-patterns-resources-in-restful
- URI also support query string for filtering and paging

- To make it easier to understand API’s we need to document them, There are two open standards
- OpenAPI
- Swagger
- To test API’s, two popular options are
- PostMan
- Thunderclient
How to build REST APIs
- APIs run on Web or APP servers accepting http(s) connections
-
Depending on which language we are using there are different frameworks
- Java => Spring boot
- dotnet => asp.net core web api
- node => express
- Python => dJango-restful, flask, Fastapi
- Findout what asynchronous is ?
- Findout the difference between parallel vs concurent
Fast API
- Fast API support asynchronous api’s and it automatically generates API documentation.
- fast api documentation

Lets build a simple Math Calculator REST API
- Resource (Noun) => Calculator
- Actions (Verbs) => Add, sub, mul, div,mod
- versioning: tbd
- Steps:
- Create a new folder called
calculator - Create and activate virtual environment
- Install the dependencies
- Create a new folder called
- Refer Here for changes
