Skip to content

Get started with the API

Beta

Read 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.

Base URL
https://app.lyli.io/api/v1

The 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:

Every request
Authorization: Bearer lyli_…

Where keys come from

1

Open Workspace › Settings › API keys. Only admins can create and revoke keys; members can see the list.

2

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.

3

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>.

Your terminal
curl https://app.lyli.io/api/v1/sites \
  -H "Authorization: Bearer $LYLI_API_KEY"
200 OK · application/json
{
  "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.

HeaderWhat it says
X-RateLimit-LimitRequests allowed per hour for the workspace: 600.
X-RateLimit-RemainingRequests left this hour, after this one.
X-RateLimit-ResetWhen the limit resets, as a Unix timestamp in seconds.
Retry-AfterOnly on a 429: how many seconds to wait.

Past either limit, we return 429. Wait the number of seconds in Retry-After, then retry the request:

429 Too Many Requests
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:

400 Bad Request
{
  "error": {
    "code": "invalid_parameter",
    "message": "Unknown period: 31d. See Periods in the API docs."
  }
}
StatusCodeWhen
400invalid_parameterAn unknown parameter, or a value we can’t parse, such as a range longer than 731 days.
401unauthorizedNo key, or one that’s unknown, revoked, or expired.
402workspace_pausedThe workspace is paused, so its reports are unavailable. Requests work again once the workspace is active.
403site_not_allowedThe key doesn’t have access to this site.
404not_foundNo such site in the workspace, or no such funnel.
429rate_limitedMore than 600 requests this hour, or more than 50 in 10 seconds. See Rate limits.
5xxserver_errorSomething went wrong on our side. Wait a moment, then retry the request.

Periods and comparisons

Every report but Realtime takes period, the same periods as the dashboards. Without it, you get the last 30 days.

periodWhat it covers
todaySo far today, by the hour.
yesterdayYesterday, by the hour.
7d, 30d, 90dThe last 7, 30, or 90 complete days, by day. Today is left out.
52wThe last 52 weeks, by week. Today is left out.
2026-09-01..2026-09-15Whole days, both ends included, up to 731 days back.
HoursWhole hours the same way, such as 2026-09-24T09..2026-09-24T14, both ends included.

Add against to compare periods. The response then includes the other period’s totals:

againstCompared with
previousThe period just before, of the same length.
monthThe same days 4 weeks earlier, or 5 for the last 30 days, so weekdays line up. For periods of up to 5 weeks.
yearThe same days 52 weeks earlier, so weekdays line up.

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.

FilterIts values
channeldirect, search, social, referral, email, or ai.
sourceA source as the Sources list shows it, such as google.com.
page, entryA path, such as /pricing. End it in * for every path that starts with it: /blog/*.
hostnameA hostname, such as docs.harbor.example.
country, cityA two-letter country code, SE. A city with its country, SE:Stockholm.
devicedesktop, mobile, or tablet.
browser, osAs the Browsers and Systems lists show them, such as Firefox or macOS.
campaign, medium, term, contentA campaign tag’s value, as the Campaigns list shows it.
segment, cohortA saved segment’s or cohort’s ID, as in the app’s address.

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.

PathReturns
/sitesThe sites your key can read.It takes no parameters.
/sites/{site}/overviewThe totals, the chart’s series, and the comparison.
/sites/{site}/breakdownAny metric by up to 3 fields.byUp to 3 filters’ names, comma-separated. country,device if left out.sortvisitors, visits, views, bounce_rate, or visit_duration. visitors if left out.dirasc or desc. desc if left out.
/sites/{site}/eventsCustom events, with completions, visitors, and revenue.
/sites/{site}/goalsGoals, with conversions and rate.
/sites/{site}/funnels/{funnel}A saved funnel, step by step.{funnel}The funnel’s ID: what follows report= in its address in the app.
/sites/{site}/journeysPaths to or from a page or event.from, toOne of them: a path, such as /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.
/sites/{site}/attributionConversions and revenue by channel, source, or campaign.goalA path or a custom event’s name. The site’s key goal, or its first goal, if left out; needed when the site has no goals.creditfirst or last visit. last if left out.
/sites/{site}/retentionWho came back, for recognized visitors.startA path or a custom event’s name: who did it for the first time. A first visit if left out.backA path or a custom event’s name: what counts as coming back. Any visit if left out.byday, week, or month. week if left out.
/sites/{site}/performanceThe Performance score and the Web Vitals.
/sites/{site}/realtimeWho’s online now, as totals.It takes no parameters.

For an assistant that asks about your reports, see Connect with MCP.