Notifications API
The Notifications API allows you to manage user notifications and real-time updates.
Get Notifications
Get all notifications for the authenticated user.
Endpoint: GET /notifications
Headers:
X-F-Authorization: Client token (required)X-F-Authentication: User token (required)
Query Parameters:
limit(optional): Number of results to return (default: 50)offset(optional): Number of results to skip (default: 0)unread(optional): Filter by read status (true/false)
Response:
[
{
"id": "notification-id",
"title": "New Festival",
"message": "A new festival has been added",
"type": "festival",
"read": false,
"createdAt": "2024-01-01T00:00:00Z"
}
]
Mark Notification as Read
Mark a notification as read.
Endpoint: PUT /notifications/:id/read
Headers:
X-F-Authorization: Client token (required)X-F-Authentication: User token (required)
Response:
{
"id": "notification-id",
"read": true
}
Mark All as Read
Mark all notifications as read for the authenticated user.
Endpoint: PUT /notifications/read-all
Headers:
X-F-Authorization: Client token (required)X-F-Authentication: User token (required)
Response:
{
"message": "All notifications marked as read",
"count": 10
}
Server-Sent Events (SSE)
Subscribe to real-time notifications using Server-Sent Events.
Endpoint: GET /notifications/sse
Headers:
X-F-Authorization: Client token (required)X-F-Authentication: User token (required)
Response: Event stream with notification updates
Example (JavaScript):
const eventSource = new EventSource('/notifications/sse', {
headers: {
'X-F-Authorization': 'client-token',
'X-F-Authentication': 'user-token'
}
});
eventSource.onmessage = (event) => {
const notification = JSON.parse(event.data);
console.log('New notification:', notification);
};