# Onsite API

> Read your Onsite numbers from your own scripts, dashboards and tools, and make everyday changes like tracking keywords or resolving alerts.

The Onsite API gives your code the same numbers you see in Onsite: Search Console clicks and searches, insights, rank tracking, indexing, alerts and Google Analytics. Ask for the same site, period and filters as in the app and you get the same answer.

It covers what you do in Onsite most days. You can read every report, track and untrack keywords, resolve or reopen alerts, add chart notes and start exports.

## Before you start

- An Onsite account on a team with an active plan.
- An API key from [**Settings › API keys**](https://onsite.so/settings/api-keys). [Authentication](/api/authentication) shows how to make one.

## Base URL

Every endpoint lives under one address. All requests use HTTPS and answer in JSON.

```text wrap
https://api.onsite.so/api/v1
```

## Make your first request

<Steps>
  <Step title="Create a key">
    In Onsite, open [**Settings › API keys**](https://onsite.so/settings/api-keys), select **Create key**, give it a name and copy it. Onsite shows the key once.
  </Step>
  <Step title="Save it where your code can read it">
    Keep the key out of your code and out of version control. An environment variable works well:

    ```bash
    export ONSITE_API_KEY="oapi_..."
    ```
  </Step>
  <Step title="List your sites">
    ```bash
    curl "https://api.onsite.so/api/v1/sites" \
      -H "Authorization: Bearer $ONSITE_API_KEY"
    ```
  </Step>
  <Step title="Read a site's performance">
    Use any site from the list, by its domain or its ID:

    ```bash
    curl "https://api.onsite.so/api/v1/sites/example.com/performance?range=last_28d" \
      -H "Authorization: Bearer $ONSITE_API_KEY"
    ```
  </Step>
</Steps>

## Check it worked

The sites request answers with the sites your key can read, and where the page sits in the full list:

```json
{
  "sites": [
    {
      "id": "0f8e6c2a-4a8f-4d7e-9b1e-5c3d2a1b0e9f",
      "site": "https://example.com/",
      "address": "example-com",
      "property": "sc-domain:example.com",
      "group": "owned",
      "status": "active",
      "connected": { "analytics": true, "bing": false }
    }
  ],
  "page": { "shown": 1, "total": 1, "nextCursor": null }
}
```

If you get an error instead, its `message` says what to change. [Errors](/api/errors) lists every kind.

## How the API works

- **Sites.** Every endpoint that reads one site takes it in the path. Use its domain (`example.com`), its address in Onsite (`example-com`), its Search Console property or its ID, as **List sites** shows them.
- **Periods.** Reports take a `range`, such as `last_28d` or `2026-08-01..2026-08-31`, and most take `compare`. They match the date picker in Onsite.
- **Lists.** Long lists come a page at a time. [Pagination](/api/pagination) shows how to get the rest.
- **Changes.** Requests that change something use `POST`, `PATCH` or `DELETE`, and only work with a key that has **Can make changes** turned on.
- **Field names** are the same in every response: `clicks`, `impressions`, `ctr` (in percent) and `position`.

## Next

<CardGroup cols={2}>
  <Card title="Authentication" icon="key-round" href="/api/authentication">
    Create, limit and revoke API keys.
  </Card>
  <Card title="Errors" icon="circle-alert" href="/api/errors">
    What each error means and how to fix it.
  </Card>
  <Card title="Rate limits" icon="gauge" href="/api/rate-limits">
    How many requests a key can make.
  </Card>
  <Card title="Pagination" icon="list" href="/api/pagination">
    Get every row of a long list.
  </Card>
</CardGroup>
