Please enable JavaScript.
Coggle requires JavaScript to display documents.
Restful Api Design (Best Practice (Paging (Links to the next or previous…
Restful Api Design
Best Practice
-
Provide filtering, sorting, field selection and paging for collections
Use a unique query parameter for all fields or a query language for filtering.
GET /cars?color=red Returns a list of red cars
GET /cars?seats<=2 Returns a list of cars with a maximum of 2 seats
Allow ascending and descending sorting over multiple fields.
GET /cars?sort=-manufactorer,+model
-
Field selection
Mobile clients display just a few attributes in a list. They don’t need all attributes of a resource. Give the API consumer the ability to choose returned fields. This will also reduce the network traffic and speed up the usage of the API.
GET /cars?fields=manufacturer,model,id,color
-
Paging
Use limit and offset. It is flexible for the user and common in leading databases. The default should be limit=20 and offset=0
GET /cars?offset=10&limit=5
Links to the next or previous page should be provided in the HTTP header link as well. It is important to follow this link header values instead of constructing your own URLs.
-
-
-
-
-
-
-
-
-
-