What has happened on the boards an account can see — a comment, a card created
or moved, an invitation, a due date coming up — and marking those as read.
Notifications belong to the account the key authenticates as. There is no
parameter for whose notifications to read: it is always the key's own.
Without limit the whole history comes back, which is what a client wants when
it means to look at all of it. Pass limit to read it a page at a time, and
before to carry on from where the last page ended.
The page, newest first. Each carries id, type, boardId, cardId, message, isRead, createdAt, and the actor's actorName, actorImage and actorType where one is recorded.
hasMore
boolean
Whether anything older exists past this page. Always false when no limit was given.
unreadCount
integer
Unread notifications on the whole account, not on this page — so a badge stays right while a page is held.
Paging is anchored to a notification rather than to a count of rows. A
notification arriving while somebody reads therefore cannot shift the window and
make a page repeat itself or skip an entry, which an offset would.
curl -X GET "https://boards.example.com/api/data/notifications?limit=25" \
-H "X-API-Key: $LOKALBOARDS_KEY"
# the next page, carrying on from the last id of the previous one
curl -X GET "https://boards.example.com/api/data/notifications?limit=25&before=418" \
-H "X-API-Key: $LOKALBOARDS_KEY"
async function page(before) {
const url = new URL("https://boards.example.com/api/data/notifications");
url.searchParams.set("limit", "25");
if (before) url.searchParams.set("before", before);
const response = await fetch(url, { headers: { "X-API-Key": apiKey } });
if (!response.ok) throw new Error(await response.text());
return response.json();
}
// Walk the whole history a page at a time.
const all = [];
let cursor;
let more = true;
while (more) {
const data = await page(cursor);
all.push(...data.notifications);
more = data.hasMore;
cursor = data.notifications.at(-1)?.id;
}
<?php
$ch = curl_init('https://boards.example.com/api/data/notifications?limit=25');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $apiKey,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
// The next page starts after the last notification of this one.
$cursor = end($response['notifications'])['id'];
unreadCards answers a narrower question: which cards still have an unread
notification on them. It is what a board view needs to mark its tiles, and it
sends a handful of ids rather than every message and avatar in the history.
Add boardId to ask about one board. The answer is { "cardIds": [...] };
notifications, hasMore and unreadCount are not part of it, and limit and
before do not apply.
curl -X GET "https://boards.example.com/api/data/notifications?unreadCards=1&boardId=123" \
-H "X-API-Key: $LOKALBOARDS_KEY"