Get started with the API
BetaRead your sites’ reports from your own code: totals from what Lyli records, as JSON. The API is read-only and included in every plan.
Base URL
Every endpoint path in these docs is relative to it. The API accepts requests over HTTPS only and returns JSON.
https://app.lyli.io/api/v1The API is in beta, so endpoints may still change. We list every change in the changelog.
Authentication
Send a key in the Authorization header of every request:
Authorization: Bearer lyli_…Where keys come from
Open Workspace › Settings › API keys. Only admins can create and revoke keys; members can see the list.
Select Create API key. Name the key, choose all sites or some, and choose when it expires: never, in 30, 90, or 365 days, or on a date. We email every admin about it.
Copy the key. We show it once and store only a hash of it. If you lose it, revoke it and create a new one.
Keys belong to the workspace, not to the person who created them, so they keep working when people leave. Revoking a key stops it at once.
Keep keys on your server. The API sends no CORS headers, so requests from a browser fail, and we reject keys sent in the URL. Every key starts with lyli_, so you can search your code and logs for leaked keys.
Your first request
List the sites your key can read. Each site’s id is the one in its address in the app, app.lyli.io/sites/<id>.
curl https://app.lyli.io/api/v1/sites \
-H "Authorization: Bearer $LYLI_API_KEY"// Node 18 or later, on your server
const res = await fetch("https://app.lyli.io/api/v1/sites", {
headers: { Authorization: `Bearer ${process.env.LYLI_API_KEY}` },
});
const { sites } = await res.json();import os
import requests
res = requests.get(
"https://app.lyli.io/api/v1/sites",
headers={"Authorization": f"Bearer {os.environ['LYLI_API_KEY']}"},
timeout=10,
)
sites = res.json()["sites"]{
"sites": [
{
"id": "s_k3m9x2p7qa",
"domain": "harbor.example",
"name": "harbor.example",
"timezone": "Europe/Stockholm"
}
]
}An example workspace with one site.
Rate limits
600 requests an hour for the whole workspace, in bursts of up to 50 requests per 10 seconds. Every key draws on the same 600, so more keys don’t add requests, and the count starts again when the clock hour turns. Workspace › Settings › API keys shows this hour’s count.
Past either limit, we return 429. Wait the number of seconds in Retry-After, then retry the request:
HTTP/1.1 429 Too Many Requests
Retry-After: 666
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1791500400
{
"error": {
"code": "rate_limited",
"message": "This workspace has used its 600 requests for this hour.",
"limit": "hour",
"retry_after": 666
}
}Errors
An error returns an HTTP status code and a JSON body whose error.code your code can check:
{
"error": {
"code": "invalid_parameter",
"message": "Unknown period: 31d. See Periods in the API docs."
}
}Periods and comparisons
Every report but Realtime takes period, the same periods as the dashboards. Without it, you get the last 30 days.
2026-09-24T09..2026-09-24T14, both ends included.Add against to compare periods. The response then includes the other period’s totals:
The Overview, Funnels, Journeys, Attribution, Retention, and Performance take against. Breakdown, Goals & events, and Realtime don’t compare, so sending against to them returns a 400.
Filters, segments, and cohorts
The dashboards’ 14 filters are parameters too. Each matches its value exactly, as the report’s list shows it, and several filters combine: country=SE&device=mobile counts mobile visits from Sweden.
direct, search, social, referral, email, or ai.google.com./pricing. End it in * for every path that starts with it: /blog/*.docs.harbor.example.SE. A city with its country, SE:Stockholm.desktop, mobile, or tablet.Firefox or macOS.Time zones
Days and hours follow the site’s reporting time zone. To read them in another, pass timezone with a name such as America/New_York. Custom ranges use that time zone too, and every response includes the time zone it used.
What the API never returns
The API returns totals, never lists of single visits, and can’t change anything. Totals can be small: in a short period or a narrow breakdown, a row can count a single visit, so treat what a key reads as your visitors’ data.
- Replays. No key, and no option, reads one.
- IP addresses and user-agent strings. We never store them in our database, so there are none to return.
- History imported from Google Analytics. Keys read what Lyli recorded; imported days count only in your dashboards.
Endpoints
One for each report. Every one is a GET. Every report but Realtime takes the period, time zone, filters, segment, and cohort above, and those that compare take against too. A report’s own parameters are listed under it.
country,device if left out.sortvisitors, visits, views, bounce_rate, or visit_duration. visitors if left out.dirasc or desc. desc if left out.report= in its address in the app./pricing, or a custom event’s name. From the entry page if left out.depth3 to 7 steps. 4 with to, and 5 otherwise, if left out.events1 to show custom events as steps.first or last visit. last if left out.day, week, or month. week if left out.For an assistant that asks about your reports, see Connect with MCP.