The Stats API is included on Team Plus and Enterprise. Use it to collect your statistics automatically in your own systems.
- 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. - Step 2
Request your statistics
Each request asks for one kind of statistics over one period, with the key in theAuthorizationheader, 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"Swapdeviceforredirect,country,referrerorutm, and choose the period:dayfor yesterday,monthfor the last 30 days, orfullfor 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. - 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 is202with an empty list. Try again after five minutes. This mostly happens on the first request for a kind of statistics.