# Prompts

Returns the average ranking position of your brand across all monitored prompts, with optional grouping by provider or topic and time series data.

## Request

```
GET /v1/prompts/avg-rank
```

### Query Parameters

All [common filters](/getting-started/filtering.md) are supported, plus:

| Parameter   | Type              | Required | Default     | Description                            |
| ----------- | ----------------- | -------- | ----------- | -------------------------------------- |
| `groupKey`  | string            | No       | —           | Group results by `provider` or `topic` |
| `startDate` | string (ISO 8601) | No       | 30 days ago | Start of date range                    |
| `endDate`   | string (ISO 8601) | No       | Today       | End of date range                      |
| `providers` | string\[]         | No       | All         | Filter by AI provider                  |
| `topicIds`  | string\[]         | No       | All         | Filter by topic                        |
| `countries` | string\[]         | No       | All         | Filter by country code                 |

## Response

### Success (200 OK)

Without `groupKey`:

```json
[
  {
    "avgRank": 2.4,
    "timeSeries": [
      {
        "bucketIndex": "0",
        "startDate": "2026-01-01",
        "endDate": "2026-01-31",
        "avgRank": 2.8
      },
      {
        "bucketIndex": "1",
        "startDate": "2026-02-01",
        "endDate": "2026-02-28",
        "avgRank": 2.4
      }
    ]
  }
]
```

With `groupKey=provider`:

```json
[
  {
    "groupKey": "OPENAI",
    "avgRank": 1.8,
    "timeSeries": [...]
  },
  {
    "groupKey": "GEMINI",
    "avgRank": 3.1,
    "timeSeries": [...]
  }
]
```

### Fields

| Field                      | Type           | Description                                                                                |
| -------------------------- | -------------- | ------------------------------------------------------------------------------------------ |
| `groupKey`                 | string         | Group identifier (provider name or topic name). Only present when `groupKey` param is used |
| `avgRank`                  | number or null | Average ranking position (1 = best). Null if no data                                       |
| `timeSeries`               | array          | Rank trend over time buckets                                                               |
| `timeSeries[].bucketIndex` | string         | Zero-based time bucket index                                                               |
| `timeSeries[].startDate`   | string         | Bucket start date                                                                          |
| `timeSeries[].endDate`     | string         | Bucket end date                                                                            |
| `timeSeries[].avgRank`     | number or null | Average rank in this period                                                                |

## Examples

### curl

```bash
# Overall average rank
curl "https://app.limy.ai/api/v1/prompts/avg-rank" \
  -H "X-API-Key: YOUR_API_KEY"

# Grouped by provider
curl "https://app.limy.ai/api/v1/prompts/avg-rank?groupKey=provider" \
  -H "X-API-Key: YOUR_API_KEY"
```

### Python

```python
# Average rank by provider
response = requests.get(
    f"https://app.limy.ai/api/v1/prompts/avg-rank",
    headers={"X-API-Key": API_KEY},
    params={"groupKey": "provider"}
)

for group in response.json():
    print(f"{group['groupKey']}: avg rank #{group['avgRank']:.1f}")
```

### JavaScript

```javascript
const response = await fetch(
  `https://app.limy.ai/api/v1/prompts/avg-rank?groupKey=topic`,
  { headers: { 'X-API-Key': API_KEY } }
);

const groups = await response.json();
groups.forEach(g =>
  console.log(`${g.groupKey}: avg rank #${g.avgRank?.toFixed(1) ?? 'N/A'}`)
);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api-reference.limy.ai/analytics/avg-rank.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
