Aller au contenu principal
7 min de lecture

Getting Started with the Zenovay API

This guide walks you through generating an API key, making your first request, and understanding the response format so you can start building integrations with Zenovay analytics data.


Prerequisites

Before you begin, you need:

  1. A Zenovay account with at least one tracked website
  2. A website with the Zenovay tracking script installed and receiving data
  3. cURL or any HTTP client (Postman, Insomnia, or your language of choice)

Optionnel : utiliser la collection Bruno

Tu préfères un client graphique ? Zenovay fournit une collection Bruno open-source qui couvre tous les endpoints publics, avec des exemples de requêtes, des schémas de réponse et une authentification pré-configurée.

Télécharger + ouvrirBash
curl -O https://docs.zenovay.com/downloads/bruno-zenovay-collection.zip
unzip bruno-zenovay-collection.zip
# Ouvre le dossier bruno-zenovay-collection/ dans l'app Bruno.
# Choisis l'environnement "production", renseigne ta clé API dans le
# fichier local .env (gitignored — jamais commité), et tu peux appeler
# n'importe quel endpoint.

Step 1: Generate an API Key

API keys are managed from your Zenovay dashboard.

  1. Log in at app.zenovay.com
  2. Navigate to Settings > API Keys
  3. Click Create New Key
  4. Give your key a descriptive name (e.g., "Custom Dashboard" or "Data Pipeline")
  5. Select the permission level:
    • Full Access -- access all websites in your team
    • Site Access -- access a single specific website
  6. Click Generate and copy your key immediately

Your API key is shown only once. Store it securely -- you cannot retrieve it later. If you lose a key, revoke it and generate a new one.


Step 2: Make Your First API Call

The simplest endpoint to test with is GET /usage, which returns your account usage and limits.

Base URL

All External API requests use:

https://api.zenovay.com/api/external/v1

Authentication

Pass your API key in the X-API-Key header:

Your first API callBash
curl -X GET 'https://api.zenovay.com/api/external/v1/usage' \
-H 'X-API-Key: YOUR_API_KEY'

You should receive a response like this:

Response (200 OK)JSON
{
"success": true,
"data": {
  "api_key": {
    "id": "key_abc123",
    "name": "Custom Dashboard",
    "permission": "full_access",
    "website_id": null
  },
  "usage": {
    "monthly_requests": 42,
    "monthly_limit": 10000,
    "monthly_remaining": 9958,
    "monthly_reset_at": "2026-03-01T00:00:00.000Z",
    "total_requests": 1250
  },
  "rate_limits": {
    "requests_per_minute": 30
  },
  "subscription": {
    "tier": "pro"
  }
},
"timestamp": "2026-02-07T12:00:00.000Z"
}

Step 3: Understand the Response Envelope

Every External API response follows the same envelope structure:

Response envelopeJSON
{
"success": true,
"data": { ... },
"timestamp": "2026-02-07T12:00:00.000Z"
}
FieldTypeDescription
successbooleantrue for successful requests, false for errors
dataobjectThe response payload -- varies by endpoint
timestampstringISO 8601 timestamp of the response

Error responses include an error field instead of data:

Error responseJSON
{
"success": false,
"error": {
  "code": "unauthorized",
  "message": "Invalid API key provided"
},
"timestamp": "2026-02-07T12:00:00.000Z"
}

Step 4: List Your Websites

Now fetch the websites accessible with your API key:

List websitesBash
curl -X GET 'https://api.zenovay.com/api/external/v1/websites' \
-H 'X-API-Key: YOUR_API_KEY'
ResponseJSON
{
"success": true,
"data": {
  "websites": [
    {
      "id": "ws_abc123",
      "domain": "example.com",
      "name": "Example Website",
      "tracking_code": "ZV_XXXXXXXXXXX",
      "is_active": true,
      "created_at": "2026-01-01T00:00:00Z",
      "team_id": "team_xyz"
    }
  ],
  "total": 1
},
"timestamp": "2026-02-07T12:00:00.000Z"
}

Copy the id field (e.g., ws_abc123) -- you will use it in analytics endpoints.


Step 5: Fetch Analytics Data

Use the website ID to get an analytics overview:

Get analytics overviewBash
curl -X GET 'https://api.zenovay.com/api/external/v1/analytics/ws_abc123?range=7d' \
-H 'X-API-Key: YOUR_API_KEY'

The range query parameter controls the time window:

ValuePeriod
24hLast 24 hours
7dLast 7 days (default)
30dLast 30 days
90dLast 90 days
1yLast year
Analytics responseJSON
{
"success": true,
"data": {
  "website": {
    "id": "ws_abc123",
    "domain": "example.com",
    "name": "Example Website"
  },
  "time_range": "7d",
  "date_range": {
    "start": "2026-01-31",
    "end": "2026-02-07"
  },
  "summary": {
    "total_visitors": 12543,
    "total_page_views": 45231,
    "unique_visitors": 8920
  },
  "daily_stats": [
    {
      "date": "2026-01-31",
      "total_visitors": 1823,
      "page_views": 6542,
      "unique_visitors": 1290
    }
  ]
},
"timestamp": "2026-02-07T12:00:00.000Z"
}

Authentication Methods

The primary authentication method is the X-API-Key header:

X-API-Key header (recommended)Bash
curl -H 'X-API-Key: YOUR_API_KEY' \
'https://api.zenovay.com/api/external/v1/websites'

Always use the X-API-Key header. Never expose your API key in client-side JavaScript -- use a server-side proxy instead.


Rate Limits

Rate limits vary by subscription plan:

PlanRequests/MinuteMonthly Requests
Free101,000
Pro3010,000
Scale60100,000
Enterprise1201,000,000

When you exceed the rate limit, you receive a 429 Too Many Requests response. The response includes a Retry-After header indicating how many seconds to wait.

Handling rate limitsJavaScript
async function fetchWithRetry(url, headers, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
  const response = await fetch(url, { headers });

  if (response.status === 429) {
    const retryAfter = parseInt(response.headers.get('Retry-After') || '60', 10);
    console.log(`Rate limited. Retrying in ${retryAfter}s...`);
    await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
    continue;
  }

  return response.json();
}

throw new Error('Max retries exceeded');
}

Error Handling

Common error codes and how to handle them:

StatusCodeMeaningAction
400bad_requestInvalid parametersCheck query parameters and request body
401unauthorizedInvalid or missing API keyVerify your API key is correct and active
403forbiddenKey does not have accessUse a key with the correct scope/permission
404not_foundWebsite not foundCheck the website ID is correct
429rate_limitedToo many requestsWait and retry with backoff
500internal_errorServer errorRetry after a short delay
Error handling patternJavaScript
async function callZenovayAPI(endpoint) {
const response = await fetch(
  `https://api.zenovay.com/api/external/v1${endpoint}`,
  { headers: { 'X-API-Key': process.env.ZENOVAY_API_KEY } }
);

const result = await response.json();

if (!result.success) {
  const error = result.error;
  switch (response.status) {
    case 401:
      throw new Error('Invalid API key -- check your credentials');
    case 403:
      throw new Error(`Access denied: ${error.message}`);
    case 404:
      throw new Error(`Not found: ${error.message}`);
    case 429:
      throw new Error('Rate limited -- slow down requests');
    default:
      throw new Error(`API error: ${error.message}`);
  }
}

return result.data;
}

Available Endpoints

Here is a summary of all External API endpoints:

Account

MethodEndpointDescription
GET/usageAccount usage and limits

Websites

MethodEndpointDescription
GET/websitesList all accessible websites
GET/websites/:websiteIdGet website details

Analytics

MethodEndpointDescription
GET/analytics/:websiteIdAnalytics overview with daily stats
GET/analytics/:websiteId/visitorsVisitor records with pagination
GET/analytics/:websiteId/pagesTop pages by views
GET/analytics/:websiteId/countriesGeographic breakdown
GET/analytics/:websiteId/technologyDevice, browser, OS stats

Advanced

MethodEndpointDescription
GET/heatmaps/:websiteId/pagesPages with heatmap data
GET/replays/:websiteId/sessionsSession replay recordings
GET/errors/:websiteId/groupsJavaScript error groups

Public (No Auth Required)

MethodEndpointDescription
GET/e/live/:trackingCodeLive visitor count

Next Steps

Cette page vous a-t-elle été utile ?