Skip to main content

SD - REST APIs

· 3 min read

GET Search Requests

ExampleSearch QueriesUse Case
/events?name=bollywood& date=xx-xxQuery ParametersSimple, common searches with 1-2 specific filters.
/events/search?keyword=partyDedicated EndpointAdvanced search. same keyword "party" is matched against multiple fields (title, description, tags) on backend
/events/search with a request bodyPOST with BodyComplex, nested, or structured search criteria
Sample Example
POST /events/search  // POST for complex search
{
"keyword": "bollywood",
"location": "Delhi",
"dateRange": {
"from": "2025-01-01",
"to": "2025-01-31"
},
"maxParticipants": 100
}

POST Requests

ExampleRequest TypeUse Case
/eventsSimple CreateBasic resource creation with a single object
/events/batchBatch CreateCreate multiple resources in a single request to reduce API calls
/events/{id}/duplicateAction EndpointPerform specific actions that don't fit CRUD operations
Sample Example
// Simple Create
POST /events
{
"title": "Summer Music Festival",
"date": "2025-07-15",
"location": "Central Park"
}

// Batch Create
POST /events/batch
{
"events": [
{
"title": "Workshop 1",
"date": "2025-08-01"
},
{
"title": "Workshop 2",
"date": "2025-08-02"
}
]
}

// Action Endpoint
POST /events/123/duplicate
{
"newDate": "2025-09-15",
"preserveAttendees": false
}

Resource Relationships (Comments on Events)

ExampleRequest TypeUse Case
/events/{id}/commentsNested ResourceCreate a comment directly related to a specific event
/events/{id}/comments/batchBatch NestedAdd multiple comments to an event in a single request
/commentsIndependent ResourceCreate comments with flexible relationships, useful when commenting on multiple types of content
/comments/reply/{parentId}Threaded CommentsCreate nested/reply comments, supporting comment threads
Sample Example
// Simple Comment Creation
POST /events/123/comments
{
"content": "Great event! Looking forward to it.",
"userId": "456"
}

// Independent Comment Creation
POST /comments
{
"content": "Can't wait!",
"userId": "456",
"resourceType": "event",
"resourceId": "123"
}

// Batch Comment Creation
POST /events/123/comments/batch
{
"comments": [
{
"content": "Is parking available?",
"userId": "456"
},
{
"content": "What's the dress code?",
"userId": "789"
}
]
}

// Threaded Comment Reply
POST /comments/reply/789
{
"content": "Yes, there's a parking garage next door",
"userId": "101",
"eventId": "123"
}

GET Details Requests

ExampleUse Case
/events/{id}Retrieve detailed information about a specific event
/events/{id}/commentsGet all comments related to a specific event
/events/{id}/comments/{commentId}Retrieve a specific comment related to an event
/comments/{commentId}Retrieve a specific comment without requiring event context
/files/{fileId}/presigned-urlRetrieve a presigned URL to access a specific file. GET as it's a read only operation
Sample Example
// Get Event Details
GET /events/123

// Get Event Comments
GET /events/123/comments

// Get Specific Comment (Event Context)
GET /events/123/comments/456
// This pattern may be appropriate in cases where the parent-child relationship needs to be explicitly validated or enforced.

// Get Specific Comment (Independent Access)
GET /comments/456

// Get Presigned URL for a File
GET /files/789/presigned-url
// Use this pattern when the file is a standalone entity, and a temporary URL is required to access it.