Routes
Products
The following API routes are available under the products prefix. These routes are cached with public headers and a max age of 60 seconds .
The following API routes are available under the products prefix.
These routes are cached with public headers and a max age of 60 seconds .
List of API end-points prefix content
- GET:
/products/_ping - GET:
/products/{code} - POST:
/products/getProducts - GET:
/products/{productCode}/delivery
Middleware
- Cache Headers: All routes under this prefix have caching headers set to
publicwith amax_ageof 60 seconds.
Routes Prefix /products
1. Health Check
GET /products/_ping- Controller:
PingController - Description: Checks if the API is alive and responsive.
- Request:
- Method:
GET - URL:
/products/_ping - Parameters: None
- Method:
- Response:
{ data: { "status": "ok" } }
- Controller:
2. GET: ../{code}
- Namespace and Imports: The controller is part of the
App\Http\Controllers\Apinamespace - Service Dependencies: Utilizes
ProductServiceto fetch product details and handle data retrieval. - Description: Retrieves product information by its unique code.
- Request:
- Method:
GET - URL:
/products/{code} - Parameters:
code(string): The unique identifier for the product.
- Method:
- Response:
- Status:
200 OK - Response:
Example GET -> https://base_url/ecom/v1/products/xyz { "data": { "code": "xyz", "name": "CV buis dunwandig", "full_name": "CV buis dunwandig 15x1,2mm 2m", "slug": "cv-buis-dunwandig", "locales": { "EN": {} }, "prices": { raw:{}, formatted:{}, } "description": "This is an example product.", "images": {}, "available": true, // other product fields... } }
- Status:
- Error Response:
- Status:
404 Not Found- Reason: Product with the specified code was not found.
{ "error": "Product not found" }
- Reason: Product with the specified code was not found.
Notes:
- The response will be in JSON format with product details.
- If
config('ecom.use_ecom_product_resources_db_for_product_endpoint')is enabled, the system will attempt to fetch the product from the ECOM product resources database. If the product is not found, it will fall back to fetching via a cache.
3. POST: ../getProducts
- Namespace and Imports:
ProductController(Namespace: App\Http\Controllers\Api) - Service Dependencies: Uses
ProductServiceto retrieve a list of products. - Resource Response: Returns a collection of products based on the provided filters and relationships.
- Description: Retrieves a list of products based on provided filters and relationships.
- Request:
- Method:
POST - URL:
/products/getProducts - Parameters:
filters(object): Filters to apply on the product list.relationships(array): Relationships to include in the response.
- Example Request
POST /products/getProducts Content-Type: application/json { "products":["58123","96988"] }
- Method:
- Response:
- Status:
200 OK - Response:
"code": "58123", "name": "CV buis dunwandig", "full_name": "CV buis dunwandig 15x1,2mm 2m", "slug": "cv-buis-dunwandig", "description": "Volgens DIN 2394, uitwendig elektrolitisch verzinkt.", "locales": { "EN": {} }, "prices": { "raw": {}, "formatted": { },}, "image": "https://cdn.toolstation.nl/images/140211-NL/250/58123.jpg", "images": { }, "videos": [], "brand": null, "pack_size": "15x1,2mm 2m", "pack_quantity": "Stuk", "sub_department_id": 3014, "channel": 2, "click_and_collect": true, "next_day_delivery": false, "next_business_day_collection": false, "weekday_delivery_only": false, "direct_ship": false, "latest_catalogue": "Catalogue 78", "cat_page_no": 459, "is_free_gift": false, "variations": [], "groups": [], "taxonomies": [ ], "technical_spec_attributes": [], "documents_and_manuals_attributes": [], "other_attributes": [ ], "promo_messages": [], // other product fields... }, }
- Status:
Notes:
- The
filtersparameter can include various criteria to narrow down the product list. - The
relationshipsparameter allows for including related entities like manufacturers or reviews in the response.
4. GET: ../{productCode}/delivery
- Namespace and Imports: The controller is part of the
App\Http\Controllers\Apinamespace. - Service Dependencies: Utilizes
ProductServiceto fetch product details,DeliveryMethodsServiceto get delivery estimates, andStockServiceto check stock levels. - Resource Response:
cut_off_message: A message regarding order cutoff times and other delivery conditions.channels: Delivery options, including estimated dates and stock levels for different delivery channels (e.g., delivery, collection, direct ship).
- Description: Retrieves estimated delivery information for a product based on its unique code.
- Request:
- Method:
GET - URL:
/products/{productCode}/delivery - Parameters:
productCode(string): The unique code of the product.Query Parameters:site(string, optional): The site for which to fetch estimated delivery details.
- Example Request
GET /products/123456/delivery?site=example-site
- Method:
- Response:
- Status:
200 OK - Response:
"data": { "cut_off_message": "product.order.delivery.nextdaycutoff", "channels": [] }
- Status:
- Error Response:
- Status:
404 Not Found- Reason: Product with the specified code was not found.
{ "error": "Product not found" }
- Reason: Product with the specified code was not found.
- Status:
400 Bad Request- Reason: Invalid or missing site parameter.
{ "error": "Invalid site parameter" }
- Reason: Invalid or missing site parameter.
Notes:
- Cut Off Message: Provides information about order processing times and conditions (e.g., weekday delivery only).
- Channels: Information is provided for various delivery channels.
delivery: Regular delivery channel.collection: In-store collection channel.directship: Direct shipping channel.
- Stock Levels: Displayed stock levels are subject to masking based on configuration settings.
- The
sitequery parameter allows specifying a site for more accurate delivery estimates.