{% extends 'paxalia/base.html' %} {% load static i18n %} {% block title %}{% trans "Paxalia API Reference" %} – Paxalia Analytics{% endblock %} {% block page_title %}{% trans "Paxalia API Reference" %}{% endblock %} {% block page_subtitle %}{% trans "Server-to-server event ingestion and read access" %}{% endblock %} {% block extra_css %} {% endblock %} {% block dashboard_content %}

{% trans "What this API is for" %}

{% trans "Server-to-server ingest" %}{% trans "Send trusted backend events without exposing an API key to browser JavaScript." %}
{% trans "Read analytics" %}{% trans "Pull summary, page-view, and event data into internal tools, jobs, or reporting systems." %}
{% trans "Automation" %}{% trans "Use scoped keys with CI, scheduled jobs, or integrations where anonymous browser tracking is not appropriate." %}

{% trans "Authentication" %}

{% trans "Every request needs an" %} {% trans "API key" %} {% trans "sent as a Bearer token:" %}

Authorization: Bearer pxa_...

{% trans "A key has one or both scopes: ingest (post events) and read (query data). Requests are rate-limited to 300/minute per key. This is separate from the anonymous, browser-facing event snippet — a secret key should never be embedded in client-side JavaScript." %}

POST /paxalia-api/v1/ingest/

{% trans "Requires the ingest scope. Same payload shape as the public event snippet." %}

curl -X POST {{ base_url }}ingest/ \
  -H "Authorization: Bearer pxa_..." \
  -H "Content-Type: application/json" \
  -d '{"category": "signup", "action": "completed", "label": "referral"}'

GET /paxalia-api/v1/stats/summary/

{% trans "Requires the read scope. Query params: start_date, end_date (YYYY-MM-DD, default: last 30 days)." %}

curl {{ base_url }}stats/summary/?start_date=2026-01-01&end_date=2026-01-31 \
  -H "Authorization: Bearer pxa_..."

{
  "start_date": "2026-01-01",
  "end_date": "2026-01-31",
  "total_views": 48213,
  "unique_visitors": 12904
}

GET /paxalia-api/v1/pageviews/

{% trans "Requires the read scope. Query params: start_date, end_date, limit (max 500, default 100), offset." %}

curl "{{ base_url }}pageviews/?limit=50" \
  -H "Authorization: Bearer pxa_..."

{
  "total": 48213, "limit": 50, "offset": 0,
  "results": [
    {"path": "/pricing/", "method": "GET", "status_code": 200,
     "referrer": "https://google.com/", "country_code": "US",
     "utm_source": "", "utm_medium": "", "utm_campaign": "",
     "created_at": "2026-01-15T09:32:00Z"}
  ]
}

GET /paxalia-api/v1/events/

{% trans "Requires the read scope. Query params: start_date, end_date, limit, offset, category." %}

curl "{{ base_url }}events/?category=signup" \
  -H "Authorization: Bearer pxa_..."
{% endblock %}