API Usage Guide
This guide covers best practices and common patterns for using the XD Soba API efficiently.
Request Patterns
Pagination
Most listing endpoints support pagination using the following parameters:
?page=1&pageSize=20
page: The page number (starts at 1)pageSize: Number of items per page (default: 20, maximum: 100)
Example response:
{
"items": [...],
"totalCount": 100,
"pageSize": 20,
"currentPage": 1,
"totalPages": 5
}
Filters
Many endpoints support filters 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
Create Resources
Most creation endpoints follow this pattern:
POST /{resource}
Content-Type: application/json
{
"name": "Example",
"description": "Optional description",
"status": "active"
}
Update Resources
Update operations typically use PUT or PATCH:
PUT /{resource}/{id}
Content-Type: application/json
{
"name": "Updated Name",
"status": "inactive"
}
Delete Resources
Deletion is usually done with the DELETE method:
DELETE /{resource}/{id}
Best Practices
Error Handling
- Always check the response status code
- Analyze 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 when 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/entity
{
"name": "New Entity",
"entityType": "0"
}
Delivery Regions
# Create delivery region
POST /gateway/delivery-region
{
"id": "1",
"description": "Region Name"
}
Items
# Create item
POST /gateway/item
{
"keyId": "IT01",
"description": "Item Name"
}
Testing
- Use the sandbox environment for testing
- Test error scenarios
- Verify rate limiting behavior
- Test with different data volumes
Support
If you need help:
- Consult the Troubleshooting Guide
- Review the API Reference