Set up the Stats API

The Stats API is included on Team Plus and Enterprise. Use it to collect your statistics automatically in your own systems.
  1. Step 1

    Create an API key

    Under Settings → Stats API, add a label if you like, such as the tool that will use the key, and choose Create. Copy the key when it appears: it is shown only once.
    An account can have five keys. Give each tool its own, so you can revoke one without stopping the others.
  2. Step 2

    Request your statistics

    Each request asks for one kind of statistics over one period, with the key in the Authorization header, or in the address as &api_key=… for tools that can’t set headers:
    curl -H "Authorization: Bearer ol_stats_…" \
      "https://api.onelink.to/public/stats/device?period=month"
    Swap device for redirect, country, referrer or utm, and choose the period: day for yesterday, month for the last 30 days, or full for the last 400 days. The answer lists each Onelink with its statistics per day. The full reference, with an example answer for each kind, is under Settings → Stats API.
  3. Step 3

    Fetch once a day

    Statistics cover completed days, counted in UTC, and are prepared shortly after midnight UTC, so one run after 01:00 UTC is enough. Each key may make 50 requests a day and 5 a minute.
    If the statistics are still being prepared, the answer is 202 with an empty list. Try again after five minutes. This mostly happens on the first request for a kind of statistics.

Features in this guide