Skip to content

getSnapshotInfo

The getSnapshotInfo function returns the meta block of the content snapshot the client has on disk.

It works on any client regardless of its mode, so even an 'api'-mode client pointed at a snapshotPath can report on the snapshot it has on disk. This is handy for freshness checks — for example, logging when the snapshot was generated during a build.

Example:

import { createClient } from '@content-island/api-client';
const client = createClient({
accessToken: 'YOUR_ACCESS_TOKEN',
mode: 'snapshot',
});
const info = await client.getSnapshotInfo();
console.log(info);
/*
{
schemaVersion: 1,
exportedAt: '2026-06-18T09:12:43.000Z',
projectId: '1',
view: 'published',
}
*/

Interface

The getSnapshotInfo function does not accept any parameters. It returns a promise that resolves with the snapshot’s meta block.

export interface ApiClient {
getSnapshotInfo: () => Promise<SnapshotMeta>;
// ... other methods
}

It lazily loads the snapshot if it has not been read yet. On a client without an explicit snapshotPath, it loads the default snapshot at './content-island-snapshot.json' (resolved relative to the current working directory).

Output

The getSnapshotInfo function returns the snapshot’s meta block, which has the following structure:

interface SnapshotMeta {
schemaVersion: number; // current supported snapshot schema version (e.g. 1)
exportedAt: string; // ISO-8601 timestamp of when the snapshot was generated
projectId: string;
view: 'published' | 'preview';
}

If no readable, valid snapshot exists at the resolved path — the file is missing, unreadable, contains invalid JSON, or has an unsupported schemaVersion — the call rejects with a typed ApiClientError whose message names the path it tried to read.