> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rankraft.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AI referral report

> POST /v1/reports/referrals

Visitors who arrived on your site from an AI answer engine, grouped by any of date, hour, source, landing path and page type. Needs an [integration](/agent-analytics/integrations/overview) installed on the site.

## Body

**site\_id** `string` *required*

The site's id, from [List sites](/api-reference/endpoints/list-sites).

**start\_date** `string` *required*

Inclusive day, `YYYY-MM-DD`, in `timezone`.

**end\_date** `string` *required*

Inclusive day, `YYYY-MM-DD`, in `timezone`. At most 400 days after `start_date`.

**timezone** `string` (default: UTC)

IANA zone for `date` and `hour` buckets and for the day boundaries.

**group\_by** `enum\<string\>[]`

Up to 3 of: `date`, `hour`, `referral_source`, `path`, `page_type`.

**metrics** `enum\<string\>[]`

Any of: `visits`, `landing_pages`, `last_visit`.

**filter** `object`

Fields `referral_source`, `path`, `page_type`. See [Filtering](/api-reference/filtering).

**sort** `object`

**properties**

**field** `string` *required*

One of the requested `group_by` fields or `metrics`.

**dir** `enum\<string\>` (default: desc)

One of: `asc`, `desc`.

**limit** `integer` (default: 100)

Rows per page, 1–500.

**cursor** `string`

Opaque cursor from `info.next_cursor`.

## Response

**info** `object`

**properties**

**count** `integer`

Rows in this page.

**total\_results** `integer`

Rows across all pages.

**next\_cursor** `string`

Pass as `cursor` for the next page; null on the last page.

**site\_id** `string`

**start\_date** `string`

**end\_date** `string`

**timezone** `string`

**data** `object[]`

**properties**

**date** `string`

**hour** `string`

`YYYY-MM-DDTHH:00` in the requested time zone.

**referral\_source** `string`

`chatgpt`, `perplexity`, `claude`, `gemini`, `copilot`, …

**path** `string`

The landing page.

**page\_type** `string`

**visits** `integer`

**landing\_pages** `integer`

Distinct landing paths.

**last\_visit** `string`

```bash cURL theme={"system"}
curl -X POST https://api.rankraft.ai/v1/reports/referrals \
  -H "X-API-Key: $RANKRAFT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "site_id": "3f2c9a10-7b1e-4c55-9d2a-1a2b3c4d5e6f",
    "start_date": "2026-09-01",
    "end_date": "2026-09-30",
    "group_by": ["referral_source"],
    "metrics": ["visits", "landing_pages"]
  }'
```

```javascript JavaScript theme={"system"}
// npm install rankraft-js · https://www.npmjs.com/package/rankraft-js
import { RankRaft } from "rankraft-js";

const rr = new RankRaft(); // reads RANKRAFT_API_KEY

const page = await rr.reports.referrals({
  site_id: "3f2c9a10-7b1e-4c55-9d2a-1a2b3c4d5e6f",
  start_date: "2026-09-01",
  end_date: "2026-09-30",
  group_by: ["referral_source"],
  metrics: ["visits", "landing_pages"],
});
for (const row of page.data) console.log(row.referral_source, row.visits, row.landing_pages);
```

```python Python theme={"system"}
# pip install rankraft-py · https://pypi.org/project/rankraft-py/
from rankraft import RankRaft

with RankRaft() as rr:  # reads RANKRAFT_API_KEY
    page = rr.reports.referrals(
        site_id="3f2c9a10-7b1e-4c55-9d2a-1a2b3c4d5e6f",
        start_date="2026-09-01",
        end_date="2026-09-30",
        group_by=["referral_source"],
        metrics=["visits", "landing_pages"],
    )
    for row in page:
        print(row["referral_source"], row["visits"], row["landing_pages"])
```

```json 200 theme={"system"}
{
  "info": {
    "site_id": "3f2c9a10-7b1e-4c55-9d2a-1a2b3c4d5e6f",
    "start_date": "2026-09-01",
    "end_date": "2026-09-30",
    "timezone": "UTC",
    "count": 2,
    "total_results": 2,
    "next_cursor": null
  },
  "data": [
    { "referral_source": "chatgpt", "visits": 412, "landing_pages": 37 },
    { "referral_source": "perplexity", "visits": 58, "landing_pages": 12 }
  ]
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.