3
Regarding the REST API maturity model, level 2 consists of "HTTP + Resources + Verbs". What are the advantages over level 1 and zero? In addition to organizing the API.
3
Regarding the REST API maturity model, level 2 consists of "HTTP + Resources + Verbs". What are the advantages over level 1 and zero? In addition to organizing the API.
2
I will quote some advantages below:
Some examples related to the points mentioned above. For the first case, we can apply standardization as follows:
* https://minhaapi.com/getCar?id=2
* https://minhaapi.com/getCustomer?id=5&name=nullptr
* https://minhaapi.com/getManufacturer?id=5
Separando por recursos teremos:
* https://minhaapi.com/cars/{id}
* https://minhaapi.com/customers/{id}?name=nullptr
* https://minhaapi.com/manufacturers/{id}
Still taking advantage of the hook for item 2, with the best use of resources we will have the following scenario:
* GET https://minhaapi.com/getCars
* GET https://minhaapi.com/getCar?id=2
* POST https://minhaapi.com/createCar
* POST https://minhaapi.com/updateCar
* POST https://minhaapi.com/deleteCar
Utilizando os verbos HTTP
* POST https://minhaapi.com/cars
* GET https://minhaapi.com/cars
* GET https://minhaapi.com/cars/{id}
* PUT/PATCH https://minhaapi.com/cars/{id}
* DELETE https://minhaapi.com/cars/{id}
And now applying HATEOAS in the return of resources, we would have the possibility to implement navigability to our content of Sponse:
* GET https://minhaapi.com/cars/5
HTTP 200
{
"car": {
"id": "5"
"model": "Fusca",
"manufactor": "VW"
},
"links": {
"_self": { "href": "https://minhaapi.com/cars/5" }
"manufacturer": { "href": "https://minhaapi.com/manufactors/56" }
"similar": { "href": "https://minhaapi.com/cars?related=fusca" }
}
}
You can also include links to help with paging, when a listing endpoint query is paginated, an example can be seen in this call of the Juno API.
Browser other questions tagged api rest restful
You are not signed in. Login or sign up in order to post.