What conventions does the API use?
Attribute Conventions
- Keys generally match the attribute name on their respective models.
- Exception: Attributes ending in "_code" should omit the suffix when passed to the API, e.g.
currency_code=>currency
Relationship Conventions
- Nested data should use a snake_case version of the relationship method name where present, e.g.:
shippingMethod=>shipping_method
Price Conventions
- Prices retrieved from the API are mostly in the currency's smallest unit, e.g.
1000=10 GBP - Prices should generally be provided in the currency’s standard unit, e.g.
10=10 GBP(unless otherwise stated) - Prices should generally be passed as an object, e.g.:
{ "price": { "amount": 400, // Excluding tax "tax": 80 } }Exception: Some endpoints support passing a single tax-inclusive value:
See the relevant endpoint docs to see if this is supported for an endpoint{ "price": 480 // Including tax }
Date Conventions
- Dates must be Carbon-parseable, supported formats include:
- 2023-09-01T09:29:41.000000Z
- 2023-09-01 09:29:41
- 2023-09-01 (defaults to midnight if no time is provided)
Pagination Conventions
| Parameter |
Description |
Example |
page |
The page number (default: 1) | ?page=2 |
per_page |
The number of results per page (default: 24, max: 96) | ?per_page=48 |
ids |
Comma-separated list of IDs to fetch | ?ids=1,2,5 |
min_updated_at |
The min updated at for a product | ?min_updated_at=2023-08-30%2010:35:05 |
max_updated_at |
The max updated at for a product | ?max_updated_at=2023-08-30%2010:35:05 |
The min_updated_at and max_updated_at parameters are only supported by index endpoints.
Responses follow Laravel's pagination format, e.g.:
{
"current_page": 1,
"data": [
//...
],
"first_page_url": "http://aero.test/api/products?page=1",
"from": 1,
"last_page": 2,
"last_page_url": "http://aero.test/api/products?page=2",
"next_page_url": "http://aero.test/api/products?page=2",
"path": "http://aero.test/api/products",
"per_page": 24,
"prev_page_url": null,
"to": 24,
"total": 29
}
Scope Conventions
- Index endpoints support a scope parameter, which is a comma-separated list of scopes.
- Supported scopes are endpoint-specific and documented in endpoint-specific example docs.
Image Factory Conventions
| Parameter |
Description |
Example |
image_factory_width |
Output image width | ?image_factory_width=200 |
image_factory_height |
Output image height | ?image_factory_height=200 |
image_factory_options |
Comma-seperated options | ?image_factory_options=flip,greyscale |
If any of these query parameters are present in the GET requests, Image Factory will be applied.