Keep a local mirror in sync
Want your own database to always reflect what's in a Dib home? You've got two ways to stay current plus a way to catch up after downtime. Pick based on how fresh you need the data.
Option 1: Poll the change feed
The change feed is an append-only log of everything that happens in a team. Each event has a monotonically increasing id; you track a cursor and ask for everything after it. This is the simplest reliable approach and it survives restarts.
// Resume from the cursor you stored last run (or omit for a full backfill).
let cursor = await loadCursor(); // your storage
while (true) {
const url = new URL("https://dib.io/api/v1/events");
if (cursor) url.searchParams.set("cursor", cursor);
url.searchParams.set("limit", "100");
const res = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.DIB_API_KEY}` },
});
const { data, meta } = await res.json();
for (const event of data) {
// event.type is "created" | "updated" | "deleted"
// event.payload is the post-image of the resource (null on delete)
await applyToMirror(event);
}
if (meta.page.next_cursor) {
cursor = meta.page.next_cursor;
await saveCursor(cursor); // persist so a crash resumes cleanly
}
if (!meta.page.has_more) break; // caught up β sleep, then poll again
}Each event looks like this:
{
"data": [
{
"id": 1042,
"type": "updated",
"resource_type": "inventory",
"resource_id": "6f1c2e2a-1b3c-4d5e-8f90-1a2b3c4d5e6f",
"api_version": "2026-06-01",
"payload": { "id": "6f1c...", "name": "Bosch Dishwasher", "room_id": "..." },
"created_at": "2026-06-17T22:14:03.000Z"
}
],
"meta": {
"request_id": "req_abc123",
"page": { "has_more": true, "next_cursor": "eyJ2IjoxLCJpZCI6MTA0Mn0" }
}
}A few things worth knowing: type is created, updated, or deleted; payload is the full post-image of the resource (and is null for deletes, so lean on resource_id there). Store next_cursor after each batch so a crash picks up exactly where it left off. Filter to what you care about with ?types=inventory,task.
Option 2: Stream over SSE
Need changes the instant they happen? Open a Server-Sent Events connection and Dib pushes events as they land, with a 60-second heartbeat. Reconnect with your last cursor and you won't miss a thing.
curl -N -H "Authorization: Bearer $DIB_API_KEY" \
"https://dib.io/api/v1/events/stream"Catching up after downtime
If your consumer was offline longer than the feed's retention, do a reconciliation pass per collection using updated_since with sort=updated_at. Page through with the cursor until has_more is false, then resume the live feed.
# Pull everything changed since your last sync, oldest-first, per resource.
curl -H "Authorization: Bearer $DIB_API_KEY" \
"https://dib.io/api/v1/inventory?updated_since=2026-06-01T00:00:00Z&sort=updated_at&order=asc&limit=100"Next steps
- See every list parameter on the API reference.
- New here? Start with Getting started.