API
Mate Academy has a public API that you can practice with by downloading, for example, Postman, and making requests from the application. https://mate-academy.github.io/fe-students-api/goods.html
Endpoints are URLs through which clients can access and process data. When creating endpoints, several rules should be followed:
- The URL should always end with a noun, for example,
/api/users. A bad example would be/api?type=users; - HTTP methods are used to identify actions, for example,
GETfor retrieving data; - a developer should be able to understand what operation is being performed just by looking at the endpoint and the HTTP method. For example:
| Endpoint | HTTP Method | Description |
|---|---|---|
api/users |
GET |
get all users |
api/users/new |
GET |
show the form for adding a new user |
api/users |
POST |
add a user |
api/users/1 |
PUT |
update the user with id = 1 |
api/users/1/edit |
GET |
show the update form for the user with id = 1 |
api/users/1 |
DELETE |
delete the user with id = 1 |
api/users/1 |
GET |
get the user with id = 1 |