A well-designed API is the foundation of any modern application. Here are the principles we follow at QorLogics.
Naming Conventions
- Use plural nouns for resources:
/users,/orders,/invoices - Use lowercase and hyphens:
/order-items, not/orderItems - Version your API from day one:
/api/v1/users - Use query parameters for filtering, sorting, and pagination:
?status=active&sort=created_at&page=2
Consistent Response Structure
Every response follows the same envelope:
{
"data": { ... },
"message": "User created successfully",
"meta": {
"current_page": 1,
"per_page": 20,
"total": 150
}
}
Error Handling
Use standard HTTP status codes consistently. Include a machine-readable error code alongside the human-readable message:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "The given data was invalid.",
"details": {
"email": ["The email field is required."]
}
}
}
API Design is Product Design
Your first consumers are your own frontend and mobile apps. If your API is painful to use, your products will be too. Invest in good design from the start.