🧪 Basic Features
🧪 Advanced Features
Projection (fields, fields!)
The projection feature allows clients to include or exclude specific fields from the API response using query parameters. This helps optimize payload size and gives frontend consumers more control over the data they receive.
Include Specific Fields
Request
GET /api/users?fields=id,name,email
Where id, name, and email are the fields to include in the response.
Query Parameters
| Name | Type | Description |
|---|---|---|
| fields | string | Comma-separated list of fields to include. |
Response
[
{
"id": 1,
"name": "Benjamin Heidenreich",
"email": "quinton42@example.net"
},
{
"id": 2,
"name": "Jairo Armstrong",
"email": "damian83@example.org"
}
]
Exclude Specific Fields
Request
GET /api/users?fields!=created_at,updated_at
Where created_at and updated_at are the fields to exclude from the response.
Query Parameters
| Name | Type | Description |
|---|---|---|
| fields! | string | Comma-separated list of fields to exclude. |
Response
[
{
"id": 1,
"name": "Benjamin Heidenreich",
"email": "quinton42@example.net",
"email_verified_at": "2025-04-17T01:19:49.000000Z"
},
{
"id": 2,
"name": "Jairo Armstrong",
"email": "damian83@example.org",
"email_verified_at": "2025-04-17T01:19:49.000000Z"
}
]