Overview#
The show
query parameter allows clients to specify which fields should be included in the API response for a given resource. By using this parameter, you can customize the response to include only the fields you need, improving efficiency and reducing payload size.Usage#
Selecting Single Fields#
To include a specific field in the response, provide the field name as the value of the show
query parameter. For example:GET /api/resource?show=name
{
"id": 1,
"name": "Example Name"
}
Selecting Multiple Fields#
To include multiple fields, you can:1.
Use a comma-separated list:
GET /api/resource?show=name,description
{
"id": 1,
"name": "Example Name",
"description": "This is an example description."
}
2.
Use an array-style query:
GET /api/resource?show[]=name&show[]=description
{
"id": 1,
"name": "Example Name",
"description": "This is an example description."
}
To include fields from related resources, use dot notation to specify nested fields. This will automatically eager-load the related resources. For example:GET /api/resource?show=name,company.name
{
"id": 1,
"name": "Example Name",
"company_id": 2,
"company": {
"id": 2,
"name": "Example Company"
}
}
Behavior Notes#
The id
field of the resource is always included in the response, even if it is not explicitly specified in the show
parameter.
Related resources are automatically eager-loaded when their fields are specified using dot notation, ensuring efficient database queries. Modified at 2025-01-26 13:30:23