# Get historical keyword metrics

Fetches historical keyword metrics. Works with Google Ads.

```http
POST https://api.pozy.ai/v1/ads/keywords/historical-metrics
```

- Area: Ads / Ad Insights
- Auth: Authorization: Bearer pz_live_...

## Request body

Content type: `application/json`

- `accountId`, string, required
- `adAccountId`, string
- `customerId`, string
- `keywords`, array of string, required: At least 1 item. Up to 1000 items. Each item: up to 80 characters
- `countries`, array of string: At least 1 item. Up to 10 items. Each item: 2 to 2 characters
- `languageConstantId`, string: Default `1000`
- `network`, string: One of `GOOGLE_SEARCH`, `GOOGLE_SEARCH_AND_PARTNERS`. Default `GOOGLE_SEARCH`
- `includeAdultKeywords`, boolean
- `includeAverageCpc`, boolean

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/ads/keywords/historical-metrics" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9",
  "keywords": [
    "string"
  ]
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/ads/keywords/historical-metrics", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9",
    keywords: [
      "string"
    ]
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.post(
    "https://api.pozy.ai/v1/ads/keywords/historical-metrics",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "keywords": [
            "string",
        ],
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `customerId`, string
- `data`, array of object
- `aggregateMetricResults`, object: Can be null

```json
{
  "customerId": "691909ff82eb5ed7c816716d",
  "data": [
    {}
  ],
  "aggregateMetricResults": {}
}
```
