API Usage Guide
This guide covers best practices and common patterns for using the XD Soba API effectively.
Request Patterns
Pagination
Most list endpoints support pagination using the following query parameters:
?page=1&pageSize=20
page: The page number (starts at 1)pageSize: Number of items per page (default: 20, max: 100)
Example response:
{
"items": [...],
"totalCount": 100,
"pageSize": 20,
"currentPage": 1,
"totalPages": 5
}
Filtering
Many endpoints support filtering using query parameters:
# Filter by date range
?startDate=2024-01-01&endDate=2024-12-31
# Filter by status
?status=active
# Search by text
?search=query
Sorting
Sort results using the sortBy and sortDirection parameters:
?sortBy=createdAt&sortDirection=desc
Common Operations
Creating Resources
Most creation endpoints follow this pattern:
POST /gateway/{resource}
Content-Type: application/json
{
"name": "Example",
"description": "Optional description",
"status": "active"
}
Updating Resources
Update operations typically use PUT or PATCH:
PUT /gateway/{resource}/{id}
Content-Type: application/json
{
"name": "Updated Name",
"status": "inactive"
}
Deleting Resources
Deletion is usually done with DELETE method:
DELETE /gateway/{resource}/{id}
Best Practices
Error Handling
- Always check the response status code
- Parse error responses for detailed information
- Implement retry logic for 5xx errors
- Handle rate limiting (429) appropriately
Performance
- Use pagination to limit response size
- Implement client-side caching where appropriate
- Use compression (gzip) for large responses
- Batch operations when possible
Security
- Never store tokens in client-side code
- Rotate API keys regularly
- Use HTTPS for all requests
- Validate all input data
Common Use Cases
Entity Management
# Create a new entity
POST /gateway/entities
{
"name": "New Entity",
"type": "customer"
}
# List entities with filters
GET /gateway/entities?type=customer&status=active
# Update entity
PUT /gateway/entities/{id}
{
"status": "inactive"
}
Delivery Regions
# Create delivery region
POST /gateway/delivery-regions
{
"name": "Region Name",
"boundaries": [...]
}
# List regions
GET /gateway/delivery-regions?active=true
Items and Groups
# Create item
POST /gateway/items
{
"name": "Item Name",
"groupId": "group-id"
}
# List items in group
GET /gateway/items?groupId=group-id
Testing
- Use the sandbox environment for testing
- Test error scenarios
- Verify rate limiting behavior
- Test with different data volumes
Support
If you need help:
- Check the Troubleshooting Guide
- Review the API Reference
- Contact support at support@xdsoba.com