-
Notifications
You must be signed in to change notification settings - Fork 0
LEGACY: Phase #1 API Docs (old)
This document serves as the official API documentation for the Inma Clubs Management System. It defines the standard patterns and structures that all API endpoints must follow to ensure consistency across the system.
/api/v1
[Authentication endpoints will be documented here]
All list endpoints support pagination with the following parameters:
-
page: Page number (default: 1) -
limit: Items per page (default: 10, max: 50)
Filtering is supported through query parameters. Each resource has its specific filterable fields, but the pattern remains consistent:
?fieldName=value
?fieldName[operator]=value
Supported operators:
-
eq: Equal to (default if no operator specified) -
ne: Not equal to -
gt: Greater than -
gte: Greater than or equal to -
lt: Less than -
lte: Less than or equal to -
in: Value is in array -
nin: Value is not in array
Example:
?status=active
?hours[gt]=10
?category[in]=CLUB_PROGRAMS,UNIVERSITY_PARTICIPATION
?startDate[gte]=2024-01-01&endDate[lte]=2024-12-31
Search is available for primary identifiers:
- Clubs:
namefield only - Users:
name,email,uniId,nationalIdfields - Tasks:
titlefield only
?search=term
Sort results using the sort parameter:
?sort=field1,-field2
Prefix with - for descending order.
Select specific fields to return:
?fields=field1,field2,field3
Include related resources:
?include=relation1,relation2
{
"status": "success",
"data": {
// Resource data or array of resources
},
"meta": {
"page": 1,
"limit": 10,
"total": 100,
"totalPages": 10
}
}{
"status": "error",
"error": {
"code": "ERROR_CODE",
"message": "Error description",
"details": {
// Optional additional error details
}
}
}-
200 OK: Request successful (GET, PATCH) -
201 Created: Resource created successfully (POST) -
204 No Content: Request successful, no content returned (DELETE)
-
400 Bad Request: Invalid request parameters or validation failed -
401 Unauthorized: Missing or invalid authentication token -
403 Forbidden: Valid token but insufficient permissions -
404 Not Found: Requested resource doesn't exist -
422 Unprocessable Entity: Validation error -
429 Too Many Requests: Rate limit exceeded
-
500 Internal Server Error: Unexpected server error
Query Parameters:
- All common parameters (pagination, filtering, search, sort, fields, include)
Example:
GET /api/v1/clubs?page=1&limit=10&sort=-createdAt&fields=id,name,description&include=events
Query Parameters:
-
fields: Select specific fields -
include: Include related resources
Example:
GET /api/v1/clubs/123?include=events,members&fields=id,name,description
Request Body:
{
"field1": "value1",
"field2": "value2"
}Request Body:
{
"field1": "newValue1",
"field2": "newValue2"
}Returns 204 No Content on success.
- Search:
namefield only - Include:
events,members,stats - Filter by:
-
status: Club status (active/inactive) -
createdAt: Creation date range
-
- Include:
events,members,stats,achievements
- Search:
titlefield only - Include:
clubMembership - Filter by:
-
clubMembershipId: Associated membership -
status: Task status (accepted/pending/denied) -
category: Task category (CLUB_PROGRAMS/UNIVERSITY_PARTICIPATION/EXTERNAL_PARTICIPATION/CLUB_INITIATIVES/INTERNAL_ACTIVITIES/COMMUNITY_SERVICE) -
volunteeredSeconds: Hours range -
createdAt: Creation date range
-
- Include:
clubMembership
- Search:
name,email,uniId,nationalIdfields - Include:
clubs,stats - Filter by:
-
globalRole: User role (inmaAdmin/uniAdmin/user) -
status: Account status -
createdAt: Account creation date range
-
- Include:
user,club - Filter by:
-
clubId: Associated club -
userId: Associated user -
role: Membership role (clubAdmin/hr/member) -
joinedAt: Join date range
-
- 100 requests per minute per IP
- 1000 requests per hour per user
- Supported formats: PDF, DOCX, XLSX, PNG, JPG
- Max file size: 10MB
- Max files per request: 5
The API version is included in the URL path. Current version is v1.
- All endpoints must support the common query parameters where applicable
- Response formats must be consistent across all endpoints
- Error responses must follow the standard error format
- Filtering, sorting, and searching should be implemented consistently
- Include proper validation for all input parameters
- Document all available filters, includes, and sortable fields for each endpoint
- Use proper HTTP status codes
- Implement proper error handling and validation
- Follow RESTful principles for endpoint design
- Maintain consistent naming conventions across all endpoints
- Get first page of clubs with basic info:
const response = await fetch(
'/api/v1/clubs?page=1&limit=10&fields=id,name,description',
);- Search for clubs with specific name:
const response = await fetch('/api/v1/clubs?search=tech');- Get clubs with specific status:
const response = await fetch('/api/v1/clubs?status=active');- Filter tasks by date range and category:
const response = await fetch(
'/api/v1/tasks?createdAt[gte]=2024-01-01&createdAt[lte]=2024-01-31&category=CLUB_PROGRAMS',
);- Get user with specific role and include their clubs:
const response = await fetch(
'/api/v1/users?globalRole=inmaAdmin&include=clubs',
);- Advanced filtering with multiple conditions:
const response = await fetch(
'/api/v1/tasks?status[in]=accepted,pending&volunteeredSeconds[gt]=3600&sort=-createdAt',
);You can combine multiple parameters to build complex queries:
const queryParams = new URLSearchParams({
page: '1',
limit: '20',
sort: '-createdAt',
fields: 'id,name,description',
include: 'members',
'status[in]': 'active,pending',
'createdAt[gte]': '2024-01-01',
});
const response = await fetch(`/api/v1/clubs?${queryParams.toString()}`);async function fetchPaginatedData(endpoint, page = 1, limit = 10) {
const response = await fetch(`${endpoint}?page=${page}&limit=${limit}`);
const data = await response.json();
return {
items: data.data,
pagination: data.meta,
};
}