Members APINotifications
Get Unread Count
Get count of unread notifications
GET
/members/me/notifications/unread-countOverview
Returns the count of unread notifications for the authenticated member. Useful for displaying notification badges and indicators in the UI.
Authentication
Requires a valid Clerk JWT token in the Authorization header.
Query Parameters
walletquerybooleanCount only wallet-related notifications (points, transactions, etc.)
Request
curl -X GET "http://localhost:3000/v1/members/me/notifications/unread-count" \
-H "Authorization: Bearer YOUR_CLERK_JWT"Response
totalnumberrequiredTotal count of unread notifications matching the filter criteria
Response
{
"total": 5
}Use Cases
UI Badge Display
// Display notification badge
const getNotificationBadge = async () => {
const response = await fetch('/api/members/me/notifications/unread-count');
const { total } = await response.json();
// Update UI badge
if (total > 0) {
setBadgeCount(total > 99 ? '99+' : total.toString());
setBadgeVisible(true);
} else {
setBadgeVisible(false);
}
};Separate Counters
// Show different counters for different notification types
const getNotificationCounts = async () => {
const [allResponse, walletResponse] = await Promise.all([
fetch('/api/members/me/notifications/unread-count'),
fetch('/api/members/me/notifications/unread-count?wallet=true')
]);
const allCount = await allResponse.json();
const walletCount = await walletResponse.json();
setGeneralNotificationCount(allCount.total - walletCount.total);
setWalletNotificationCount(walletCount.total);
};Real-time Updates
// Poll for updates (or use websockets)
const pollUnreadCount = () => {
setInterval(async () => {
const response = await fetch('/api/members/me/notifications/unread-count');
const { total } = await response.json();
updateNotificationBadge(total);
}, 30000); // Poll every 30 seconds
};Filtering
All Notifications
- No wallet parameter: Counts all unread notifications
- Use case: Main notification badge
Wallet Only
- wallet=true: Counts only wallet-related unread notifications
- Use case: Separate wallet notification indicator
Non-Wallet
// Calculate non-wallet count
const allResponse = await fetch('/api/unread-count');
const walletResponse = await fetch('/api/unread-count?wallet=true');
const nonWalletCount = allResponse.total - walletResponse.total;Performance Notes
Caching
- Fast Response: Optimized for frequent polling
- Cache-Safe: Results can be cached briefly for UI responsiveness
- Invalidation: Cache should be invalidated when notifications are read/created
Rate Limits
- Frequent Calls: Safe to call frequently for real-time updates
- Efficient: Designed for high-frequency badge updates
Related Endpoints
- Get Notifications - Get full notification list
- Mark as Read - Mark notification as read (decreases count)
- Mark as Unread - Mark notification as unread (increases count)