The with
parameter allows you to include related data with the primary resource in a single API call. This reduces the need for multiple requests, improving performance.Usage:#
Comma-separated list: ?with=relation1,relation2
Array-style query: ?with[]=relation1&with[]=relation2
Examples:#
GET /api/user?with=company
GET /api/user?with[]=company&with[]=role
Nested Relations:#
Use dot notation: ?with=relation.nested_relation
The show
parameter allows clients to specify the fields they want to include in the response. This is useful for reducing payload size and focusing on necessary data.Usage:#
Comma-separated list: ?show=field1,field2
Array-style query: ?show[]=field1&show[]=field2
Examples:#
GET /api/resource?show=name,description
GET /api/resource?show[]=name&show[]=description
Nested Fields:#
Use dot notation: ?show=field.nested_field
The count
parameter allows clients to include the count of related resources for one-to-many or many-to-many relationships. Counts are returned as {relation_name}_count
fields.Usage:#
Comma-separated list: ?count=relation1,relation2
Array-style query: ?count[]=relation1&count[]=relation2
Examples:#
GET /api/customer?count=assignments
GET /api/customer?count=assignments,contracts
GET /api/customer?count[]=assignments&count[]=contracts
Pagination parameters allow you to retrieve data in smaller chunks, improving performance and making it easier to manage large datasets.Parameters:#
offset
: The offset to retrieve items at. Default is 0
.
limit
: The number of items per page. Default value is 100
.
Examples:#
GET /api/resource?offset=40&per_page=20
The filter
parameter enables clients to narrow down the results based on specific conditions.Multiple filters can be combined with and
/or
logic.
Examples:#
GET /api/resource?filter=field:operator:value
GET /api/resource?filter=field:eq:value,another_field:gt:10
Nested logic: ?filter=field:eq:value,and,(field2:gt:5,or,field3:lt:10)
The order_by
parameter allows clients to sort the response based on one or more fields.Usage:#
Comma-separated list: ?order_by=field:asc,another_field:desc
Array-style query: ?order_by[]=field:asc&order_by[]=another_field:desc
Examples:#
GET /api/resource?order_by=name:asc
GET /api/resource?order_by=name:asc,description:desc
GET /api/resource?order_by[]=name:asc&order_by[]=description:desc
Summary#
By combining these parameters, you can:Optimize performance with eager loading and partial data selection.
Retrieve aggregated information with relation counts.
Paginate, filter, and sort results to tailor the response to your needs.
Modified at 2025-01-26 14:35:32