SDKs
Call the Analytics Server API from your application.
Use an official SDK to query playback reports, export data, and manage your Analytics Server from your backend. SDKs are available for TypeScript, Python, PHP, and Go, for both hosted and self-hosted servers.
To collect playback events in the browser, use the player analytics tracker. To manage Chunkify Assets or saved analytics connections, use the Chunkify API SDKs.
Connect to your server
Create a Read-only API key in your hosted Analytics Server's Keys tab. For a self-hosted server, follow Setup to create a read-only key.
Set CHUNKIFY_ANALYTICS_SECRET_KEY in your backend environment to this key. All four SDKs read it automatically. Keep private keys on your backend and return only the results your frontend needs.
The examples use https://analytics.chunkify.dev. For a self-hosted server, replace it with your server's base URL, without /v1. The SDK adds the API path to each request.
Install and query a report
Each example reads a summary for one video. Replace the example ID with the videoId sent by your player. Omit the video filter to read totals for the whole analytics project.
The SDK also supports server-side JavaScript. See the runtime requirements.
npm install @chunkify/analytics
Save this as example.mjs:
import ChunkifyAnalytics from '@chunkify/analytics';
const client = new ChunkifyAnalytics({
baseURL: 'https://analytics.chunkify.dev',
});
const summary = await client.summary.retrieve({
video_id: 'ast_3Ljtoej7c3Y1plabZoElbQwdwLh',
});
console.log(summary);
node example.mjs
The summary returns views, unique_viewers, and total_playing_time_ms.
Credentials for other operations
The SDKs cover the full Analytics Server API. Choose credentials for the operations your application needs:
| Operation | Credential |
|---|---|
| Read reports, events, and sessions; create CSV exports | Private read-only key. |
| Send events | Public ingestion key. Use the player analytics tracker for browser playback. |
| Manage an analytics project's settings and keys | Full-access private key for that analytics project. |
| Create analytics projects or recover their keys | Installation admin key for a self-hosted server. |
Chunkify Project and Team access tokens belong to the main Chunkify API and cannot authenticate Analytics Server requests. See Administration for key management.
Next steps
- Query reports: understand results, apply filters, and export CSV data.
- API reference: check the reference status and access the OpenAPI specification.
- Connect with MCP: explore reports with an AI client.