Api
API Datasource Structure
This documentation explains how to structure your API endpoint to be compatible with our datasource integration system.
Base Requirements
Your API endpoint must:
- Accept POST requests
- Return JSON responses
- Support pagination, ordering, and date-based filtering
- Return items in a consistent format
API Response Format
Your API must return responses in the following format:
Required Fields
Each item in the response must have these required fields:
Field | Type | Description | Example |
---|---|---|---|
id | string or number | Unique identifier for the item | "123" or 456 |
title | string | Title or name of the item | "Product Name" |
date_modified | string | Last modification date in ISO 8601 UTC format with milliseconds | "2024-03-20T15:30:45.000Z" |
Optional Fields
You can include additional fields in your items:
Field | Type | Description |
---|---|---|
description | string | Detailed description of the item |
price | number | Current price |
regular_price | number | Regular price before any discounts |
sale_price | number | Sale price if applicable |
stock_status | string | Stock status indicator |
currency | string | Currency code |
variations | array | Product variations if applicable |
Query Parameters
Your API must support the following query parameters:
Parameter | Type | Description | Example |
---|---|---|---|
take | number | Number of items to return | ?take=10 |
skip | number | Number of items to skip (for pagination) | ?skip=20 |
order | string | Sort order (ASC or DESC ) | ?order=DESC |
order_by | string | Fields to sort by, comma-separated | ?order_by=date_modified,id |
modified_after | string | Filter items modified after this date (ISO 8601) | ?modified_after=2024-03-20T15:30:45.000Z |
Authentication
The API supports three authentication methods:
No Authentication
No additional headers required. Your API endpoint will be called without any authentication headers.
API Key Authentication
Add your API key in a custom header:
You can customize the header name during datasource configuration (e.g., Authorization
, X-Custom-Key
, etc.).
Bearer Token Authentication
Use the standard Bearer token format in the Authorization header:
Example Requests
Basic Request with API Key
Paginated Request with Bearer Token
Filtered Request without Authentication
Validation Rules
Your API must follow these validation rules:
- Date format must be exact ISO 8601 with UTC timezone and milliseconds (e.g.,
"2024-03-20T15:30:45.000Z"
) - Pagination must be exact (e.g.,
skip=1
must return the second item) - Ordering must work correctly for both ascending and descending orders
- Date filtering must be precise and exclude the exact match date
- Empty results must return an empty items array, not null or undefined
Error Handling
Your API should return appropriate HTTP status codes and error messages:
- 200: Successful response
- 400: Bad request (invalid parameters)
- 401: Unauthorized (invalid authentication)
- 403: Forbidden (insufficient permissions)
- 500: Server error
Best Practices
- Always include the total count for proper pagination handling
- Use consistent date formats across all endpoints
- Implement proper caching headers
- Rate limit your API to prevent abuse
- Document any additional fields or features specific to your implementation
Testing Your API
Before integrating, ensure your API:
- Returns consistent results for the same query parameters
- Handles pagination correctly
- Processes date filters accurately
- Sorts results properly
- Authenticates requests correctly
- Returns proper error messages for invalid requests