---
title: "Ask AI about your analytics data"
description: "Query your Adapty analytics in plain language with an AI coding agent, using the Export Analytics API."
---

Ask an AI coding agent about your Adapty analytics in plain language — revenue, conversions, retention, LTV — and let it pull the numbers for you. Point a tool that can make API calls at the [Export Analytics API](export-analytics-api), and it queries your metrics on demand.

## What you can ask about

The Export Analytics API returns the same metrics you see in the Adapty dashboard charts. Each metric has its own operation:

| Metric | What it covers | Operation |
| --- | --- | --- |
| Revenue, MRR, ARR, ARPU | Money earned over time, grouped by period, country, or campaign | [retrieveAnalyticsData](https://adapty.io/docs/api-export-analytics/operations/retrieveAnalyticsData.md) |
| Cohort retention | How long subscribers from a given cohort keep paying | [retrieveCohortData](https://adapty.io/docs/api-export-analytics/operations/retrieveCohortData.md) |
| Conversion rates | How many users move from one step or channel to the next | [retrieveConversionData](https://adapty.io/docs/api-export-analytics/operations/retrieveConversionData.md) |
| Churn and funnel | Where users drop off and how fast they unsubscribe | [retrieveFunnelData](https://adapty.io/docs/api-export-analytics/operations/retrieveFunnelData.md) |
| Lifetime value (LTV) | Average revenue per user segment over time | [retrieveLTVData](https://adapty.io/docs/api-export-analytics/operations/retrieveLTVData.md) |
| Retention | Share of users still active after a number of days | [retrieveRetentionData](https://adapty.io/docs/api-export-analytics/operations/retrieveRetentionData.md) |

For the full list of parameters and filters, see the [API reference](api-export-analytics).

## Before you start

You need three things:

- **An Adapty account with data**: The API returns the same metrics as your dashboard charts, so your app must already collect analytics.
- **A secret API key**: Find it in [App settings → General](https://app.adapty.io/settings/general), in the **Secret key** field. Keys are app-specific, so use a separate key for each app. Store it in an environment variable (for example, `ADAPTY_SECRET_KEY`) so your agent can read it without you pasting it into chat.
- **An AI tool that can call APIs**: For example, Claude Code, Cursor, or Claude Desktop with a fetch tool. Plain chat tools like claude.ai or ChatGPT can't call the API directly.

:::note
export-analytics-secret-key.webp
:::

## Give your agent the API spec

The [OpenAPI spec](https://adapty.io/docs/api-specs/export-analytics-api.yaml) describes every endpoint, the authentication header, the request body, and example responses. Once your agent has the spec, it builds correct requests without you writing any code.

Give your agent the spec by URL:

- **Paste the URL**: If your agent can fetch URLs, give it `https://adapty.io/docs/api-specs/export-analytics-api.yaml` and ask it to read the spec.
- **Use a fetch tool**: If your agent has a tool that retrieves URLs (for example, an MCP fetch server), point it at the same URL.

The spec sets the base URL to `https://api-admin.adapty.io`, so your agent has everything it needs once your key is in the environment.

## Ask about your data

With the spec loaded and your key in an environment variable, describe the metric you want in plain language.

Example prompts:

```
What was my MRR at the end of each month this year, and how does it compare to last year?

Show my trial-to-paid conversion rate for the last 90 days, broken down by product.

Which countries drive the most revenue from my yearly subscription? Top 10.

How is week-1 retention trending for subscribers who started in the last 6 months?

What's the refund rate on my annual plan since launch, by month?

Compare LTV for paid-campaign users vs. organic over the last year, and export it as CSV.
```

The agent maps your request to the right operation, reads the key from the environment, and returns the data. Responses are JSON by default. Ask for CSV when you want a spreadsheet-ready file — the agent sets `format` to `csv` in the request body.

:::warning
Keep your secret key in an environment variable — not pasted into chat or committed in a rules file. Keys are app-specific, so rotate yours in **Settings → General** if it leaks. See [rotate API keys](export-analytics-api-authorization#rotate-api-keys).
:::

## Set up once for repeated use

To avoid repeating setup every session, save the spec and key where your agent can reuse them:

- **Save the spec link**: Add the spec URL to your agent's rules or memory file (for example, a `CLAUDE.md` or Cursor rules file) so it loads every session.
- **Store the key in your environment**: Keep `ADAPTY_SECRET_KEY` in your shell profile or the tool's secret store, so you never paste it again.
- **Save reusable prompts or create a custom skill**: Keep your common questions as saved prompts, or wrap them in a custom skill or slash command so your agent runs a report on demand.

## Limits

Keep these constraints in mind:

- **Rate limit**: The API allows 2 requests per second per API key. Exceeding it returns a `429 Too Many Requests` error. Tell your agent to wait and retry on `429`.
- **App-specific keys**: Each key works for one app. To pull data from several apps, provide the matching key for each.
- **Output format**: Responses are JSON by default. Set `format` to `csv` in the request body for a CSV export.

For the full authentication and request rules, see [Authorization and request format](export-analytics-api-authorization).