Overview

The Hardal Analytics API provides programmatic access to your website analytics data. These endpoints allow you to retrieve statistics, real-time data, session information, and more for integration with custom dashboards or applications.

All API requests require authentication using an API key that can be generated in your Hardal dashboard settings.

Authentication

Include your API key in the request header:

Authorization: Bearer YOUR_API_KEY

Protect your API key and never expose it in client-side code. All API requests should be made server-side.

Endpoints

Website Statistics

Chart Data

Real-time Data

Sessions & Events

Metrics & Analysis

Error Handling

The API uses standard HTTP status codes and returns error details in the response body:

{
  "error": {
    "code": 401,
    "message": "Invalid API key"
  }
}

Rate Limits

API requests are limited to 100 requests per minute per API key. Exceeding this limit will result in a 429 status code.

Data Retention

API data reflects the same retention policy as your Hardal Analytics account settings.

Using the API

Sample Request with cURL

curl -X GET "https://<yourcustomsignaldomain.com>/website/123456/stats?startAt=2023-04-01&endAt=2023-04-30" \
  -H "Authorization: Bearer YOUR_API_KEY"

Sample Request with JavaScript

const fetchStats = async () => {
  const response = await fetch('https://<yourcustomsignaldomain.com>/website/123456/stats?startAt=2023-04-01&endAt=2023-04-30', {
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  });
  
  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.message || 'Failed to fetch stats');
  }
  
  return await response.json();
};