# REST reference

Every route is under `https://api.butlrs.ai/v1/`. Keyed routes take `Authorization: Bearer <key>`; `Idempotency-Key` makes a call replay-safe for 24 h. Every response is `{data, meta}` or `{error, meta}` (see [Errors & cursors](/docs/errors.md)).


## `GET /v1/apps`

Tool: **search_apps**


| parameter | in | required | schema |
|---|---|---|---|
| `storefront` | query | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `query` | query | no | `string maxLength=64 minLength=1` |
| `app_category` | query | no | `string maxLength=64 minLength=1` |
| `price_band` | query | no | `free | lt_1 | 1_5 | 5_20 | 20_plus` |
| `has_iap` | query | no | `boolean` |
| `min_rating` | query | no | `number minimum=0 maximum=5` |
| `min_rating_count` | query | no | `integer minimum=0 maximum=2000000000` |
| `abandonment_state` | query | no | `crossed | below | unknown` |
| `is_delisted` | query | no | `boolean` |
| `sort` | query | no | `rating_count | rating | last_observed | abandonment_score` |
| `limit` | query | no | `integer minimum=1 maximum=100 default=20` |
| `cursor` | query | no | `string maxLength=4096 minLength=1` |


## `GET /v1/apps/{app_id}`

Tool: **get_app**


| parameter | in | required | schema |
|---|---|---|---|
| `app_id` | path | yes | `string` |
| `app_id` | path | yes | `string maxLength=64 minLength=1 pattern=^[ !#-\[\]-~]+$` |
| `storefront` | query | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |


## `POST /v1/apps/{app_id}/fetch`

Tool: **fetch_now**


| parameter | in | required | schema |
|---|---|---|---|
| `app_id` | path | yes | `string` |
| `app_id` | path | yes | `string maxLength=64 minLength=1 pattern=^[ !#-\[\]-~]+$` |


Body (JSON object):

```json
{
  "storefront": "us"
}
```

## `GET /v1/apps/{app_id}/ranks`

Tool: **get_rank_history**


| parameter | in | required | schema |
|---|---|---|---|
| `app_id` | path | yes | `string` |
| `app_id` | path | yes | `string maxLength=64 minLength=1 pattern=^[ !#-\[\]-~]+$` |
| `storefront` | query | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `keyword` | query | no | `string maxLength=128 minLength=1` |
| `range` | query | no | `7d | 30d | 90d | all` |
| `limit` | query | no | `integer minimum=1 maximum=1000 default=200` |
| `cursor` | query | no | `string maxLength=4096 minLength=1` |
| `chart_type` | query | no | `string maxLength=64` |
| `chart_category` | query | no | `string maxLength=64` |


## `GET /v1/changes`

Tool: **get_change_feed**


| parameter | in | required | schema |
|---|---|---|---|
| `storefront` | query | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `app_id` | query | no | `string maxLength=64 minLength=1` |
| `developer_id` | query | no | `string maxLength=64 minLength=1` |
| `event_types` | query | no | `array maxItems=20 items=string` |
| `app_category` | query | no | `string maxLength=64 minLength=1` |
| `since_cursor` | query | no | `string maxLength=4096 minLength=1` |
| `limit` | query | no | `integer minimum=1 maximum=500 default=100` |


## `GET /v1/coverage`

Tool: **Coverage**


## `GET /v1/developers/{developer_id}`

Tool: **get_developer**


| parameter | in | required | schema |
|---|---|---|---|
| `developer_id` | path | yes | `string` |
| `developer_id` | path | yes | `string maxLength=64 minLength=1 pattern=^[ !#-\[\]-~]+$` |
| `storefront` | query | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `portfolio_limit` | query | no | `integer minimum=1 maximum=100 default=20` |
| `portfolio_cursor` | query | no | `string maxLength=4096 minLength=1` |


## `POST /v1/keys/free`

Tool: **Keys Free**


## `GET /v1/price`

Tool: **Price**


## `POST /v1/query`

Tool: **query_corpus**


Body (JSON object):

```json
{
  "dataset": "x",
  "limit": 100,
  "metrics": [
    "x"
  ]
}
```

Required: `dataset`, `metrics`.