[ADP-318] Query Parameter Convention
Guidance
SHOULD use query parameters for GET requests
MAY use query parameters for POST requests
TIP
This is a convention rather than a hard and fast rule. For further discussion, refer to this and this.
In my opinion, using both payload and query parameters simultaneously in a POST request can lead to fragmented input. From another perspective, being consistent with using payload means you need to move the common query parameters into payload and may need to design a new property/value pairing for them.
SHOULD use payload (body) for POST requests
SHOULD follow common query parameters:
- [DEAFT] q: for general search queries
- sort: See Sorting
- filter: See Filtering
- fields: See Partial Response
- embed: See Resource Expansion
- offset: See Pagination
- cursor: See Pagination
MUST use camelCase for query parameters; use CamelCase to delimit combined words in query parameters.
DO:
rawproductId, articleNumber, loginId, lId etc.
DON'T:
rawproduct_id, Articlenumber, login-id, LID
Example
DO
http
GET /events?occuredAt=2024-07-09T18:00:00Z
POST /search
{
"occuredAt": "2024-07-09T18:00:00Z"
}
DON’T
http
POST /search?occuredAt=2024-07-09T18:00:00Z
GET /events
{
"occuredAt": "2024-07-09T18:00:00Z"
}
Reference
Design Reference
Changelog
2024.10.30
: add query parameter tip for POST