On this page
Choosing query parameter names is an API design decision that becomes harder to reverse once clients depend on it. These API query parameter naming best practices will help you make filtering, sorting, pagination, and field selection predictable without treating any one convention as an HTTP requirement.
Key Takeaways
- Pick a naming style and apply it consistently across endpoints.
- Give filtering, sorting, pagination, and field selection distinct, documented meanings.
- Specify value syntax, defaults, duplicate handling, and error behavior—not just names.
- Treat published parameter names and semantics as compatibility commitments.
- Reserve names and prefixes deliberately; HTTP does not define a universal set of API query parameters.
Start with a coherent vocabulary
For a fictional product API, one possible convention is lowercase snake_case for multiword names:
GET /products?filter_status=active&sort=-created_at%2Cid&page_size=25&fields=id%2Cname%2Ccreated_at HTTP/1.1
Host: api.example.com
This example assumes that filter_status filters by status, sort accepts a comma-separated list, a leading minus means descending order, and fields selects returned fields. %2C encodes a comma. Those meanings are choices made by this API, not rules imposed by HTTP.
Another API might consistently use camelCase, such as pageSize, or bracketed names, such as filter[status]. Choose a style that fits your existing API and client ecosystem. Consistency across endpoints generally matters more than which of these styles you choose.
What established conventions illustrate
Different API design guidance takes different approaches. Google's API Improvement Proposals use names such as page_size and page_token for pagination. JSON:API defines conventions including sort and sparse fieldsets using fields[TYPE], and reserves query parameter families such as filter and page. These are different design contexts, not competing HTTP rules. In particular, use the relevant specification rather than adapting examples loosely if your API claims conformance to it.
The external guidance could not be retrieved for this article, so check the current specifications before adopting their requirements. The examples below describe an independent API convention, not a claim of conformance to either one.
Advertisement
Compare names by operation
| Operation | Possible names | Trade-off |
|---|---|---|
| Filtering | status, filter_status, filter[status] | Short names are convenient; a prefix or namespace separates filters from control parameters. Brackets can require encoding and careful parser configuration. |
| Sorting | sort, order_by | sort is concise; order_by can make the purpose more explicit. Either still needs a defined direction and multi-field syntax. |
| Pagination | page and page_size; offset and limit; or page_token and page_size | The names should reveal whether the client is navigating by page number, offset, or opaque continuation token. |
| Field selection | fields, fields[products] | One fields parameter is simple for a single resource type; a type-qualified form can help when a response contains multiple resource types. |
The vocabulary is only the start. Document which parameters each endpoint supports and how their values affect the response.
Filtering
A prefixed filter keeps resource properties separate from controls such as sort:
GET /products?filter_status=active&filter_category=books HTTP/1.1
Host: api.example.com
For this API, document whether the two filters are combined with AND or OR, whether values are case-sensitive, and what happens when a field or value is unsupported. If multiple values for one filter are allowed, choose and describe a representation, such as repeated keys or a comma-separated list. Do not assume every framework interprets either form identically.
A bracketed alternative, filter[status]=active, groups filter names visually, but clients and server frameworks may encode or parse brackets differently. Define the wire format and test it through your actual server stack.
Sorting
A compact multi-field convention can use a leading minus for descending order:
GET /products?sort=-created_at%2Cid HTTP/1.1
Host: api.example.com
Here, the intended order is newest created_at first, then id ascending. List sortable fields, define the default direction and default order, and reject or otherwise explicitly handle unsupported fields. A unique tie-breaker such as id helps make ordering deterministic when primary sort values are equal.
Alternatively, separate parameters such as sort_by=created_at&sort_direction=desc can be easier to explain for a single sort field, but become less convenient when each of several fields needs its own direction. Avoid leaving the relationship between multiple fields and directions implicit.
Pagination
Pick names that match the mechanism rather than using page for every kind of continuation:
GET /products?page_size=25&page_token=opaque-token HTTP/1.1
Host: api.example.com
In this design, the first request omits page_token; a later request supplies a continuation token returned by the API. Define the default and maximum page_size, whether a token expires, and whether changing filters or sorting invalidates it. Treat the token as opaque on the client; do not place secrets in it, and do not treat possession of it as authorization.
Page-number or offset pagination can be straightforward for clients that need to jump to a position. Continuation tokens can be useful for sequential traversal, but both approaches need a stable, documented order. Concurrent changes can still cause missing or repeated items unless the service provides appropriate snapshot or consistency guarantees; a token alone does not promise a snapshot.
Field selection
GET /products?fields=id%2Cname%2Cprice HTTP/1.1
Host: api.example.com
If this endpoint supports fields, specify whether omitted fields are excluded, what happens when fields is absent or empty, and whether unknown field names cause an error. Explain how selection interacts with nested objects and fields required by the response format.
Field selection shapes a response; it does not grant access to a field. Apply authorization independently, regardless of what a client requests.
Advertisement
Define the query contract
Document more than the parameter spelling. For each parameter, record:
- Scope and type: which endpoints accept it and whether its value is a string, integer, list, or another representation.
- Allowed values and limits: for example, permitted sort fields and the maximum page size.
- Absence and emptiness: whether an omitted value differs from
fields=orpage_token=. - Duplicates: what happens with
page_size=10&page_size=20. Rejecting ambiguous duplicates is one defensible choice, especially when intermediaries and application frameworks may interpret them differently. - Errors: the status and response shape for unknown parameters, malformed values, or unsupported combinations.
- Encoding: how clients encode values containing characters with special meaning in URLs or in the API's own list syntax.
Query strings are URL data; HTTP does not automatically assign application meanings to names such as sort or page. Characters such as &, = and # can have structural meaning, so clients should use their language's URL-building tools rather than concatenate untrusted values. Form-style query parsers can also interpret + as a space; use an encoded literal plus when needed and document the expected parsing behavior.
Avoid putting credentials or sensitive personal data in query parameters: URLs can appear in logs, browser history, and intermediary records. Also account for practical URL-length limits across clients, proxies, and servers; for complex searches, a separately designed request body may be more appropriate.
Reserve names and manage compatibility
Maintain an API-wide registry of control names and any reserved prefixes. For example, if filter_ identifies filters, decide whether a resource field may itself start with that prefix and how collisions are resolved. Consider future needs such as pagination and versioning before using short, generic names for unrelated endpoint-specific behavior.
There is no universal list of reserved API query names. However, frameworks, gateways, protocols, and specifications used in your deployment can have their own conventions or reserved parameters. Check those constraints before publishing a name, especially if a gateway consumes a parameter before the request reaches your application.
Once published, renaming page_size to limit can break clients even if both names seem reasonable. If a change is necessary:
- Introduce the new name as an alias if the old and new behavior can be equivalent.
- Define what happens when both names appear; rejecting conflicting values avoids silent ambiguity.
- Document the transition, measure usage where feasible, and give clients a clear migration path.
- Remove the old name only under your published compatibility or versioning policy.
Changing defaults, accepted values, duplicate handling, or ordering can also break clients without changing a name. Treat those semantics as part of the public contract.
Common Mistakes
- Mixing styles, such as
pageSize,sort_by, andFilterStatus, without a documented reason. - Using the same name with different meanings on different endpoints.
- Naming a parameter without defining its value syntax, default, or error behavior.
- Assuming repeated keys, brackets, commas, or plus signs are parsed the same way by every component.
- Changing an established parameter or its default without a compatibility plan.
- Assuming an opaque pagination token provides authorization or snapshot consistency.
Best Practices
Create a short naming guide with examples for every supported operation. Review new parameters against it and against your gateway and framework behavior. Add contract tests for omitted, empty, repeated, malformed, and encoded values through the deployed request path—not just against a local parser. Publish the resulting rules alongside endpoint documentation and keep them stable across versions.
Conclusion
Choose names that make each operation recognizable, then define their semantics precisely. A consistent vocabulary and a deliberate compatibility policy will serve public API clients better than treating any particular spelling as a universal standard.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.