[ADP-111] GET
Overview
The HTTP GET method is used to request data from a specified resource. Requests using GET should only retrieve data and should not have any other effect on the data.
Guidance
- GET requests SHOULD NOT change the state of the resource. They can be repeated without causing different outcomes.
- GET requests SHOULD NOT cause any side effects for which the user is held responsible.
- Responses to GET requests SHOULD be cacheable to improve performance and reduce server load. See Cache Control.
- MAY use query parameters to filter, sort, or paginate the data being requested. See Pagination, Sorting, Filtering.
- MUST NOT add request body in GET requests.
Usage
- Keep GET requests idempotent
- Avoid using GET for operations that modify data
- Use meaningful and RESTful URL structures
- Implement proper error handling for GET requests
- Consider rate limiting for public GET endpoints
Example 1: Retrieve a list of users
Request:
http
GET /users
Response:
http
HTTP/1.1 200 OK
[
{
"id": 1,
"name": "Alice"
},
{
"id": 2,
"name": "Bob"
}
]
Example 2: Retrieve a single user by ID
Request:
http
GET /users/1 HTTP/1.1
Response:
http
HTTP/1.1 200 OK
{
"id": 1,
"name": "Alice"
}