# Search analytics API

> Read cached Google Search Console data for a Blogizi project over HTTP: totals, daily chart, top queries and pages. One request, your account API key.

HTML version: https://blogizi.com/docs/api-search-analytics
Markdown version: https://blogizi.com/docs/api-search-analytics.md

Read cached Google Search Console performance for a project. Bind a property in the dashboard first; see [Search Console](/docs/search-console).

## Request

```http
GET /api/search-analytics?days=28
Authorization: Bearer YOUR_ACCOUNT_API_KEY
X-Blogizi-Project: your-project-slug
```

| Parameter | Values | Default |
|---|---|---|
| `days` | `7`, `28`, `90`, `180`, `365`, `480` | `28` |
| `refresh` | `1` to sync before responding (5-minute cooldown) | off |

`X-Blogizi-Project` is required when the account has more than one project.

```bash
curl -s "https://blogizi.com/api/search-analytics?days=28" \
  -H "Authorization: Bearer $BLOGIZI_API_KEY" \
  -H "X-Blogizi-Project: my-blog"
```

## Response

```json
{
  "property": "sc-domain:yourapp.com",
  "range": { "startDate": "2026-09-08", "endDate": "2026-10-05", "days": 28 },
  "lastSyncedAt": "2026-10-09T06:00:12.000Z",
  "totals": { "clicks": 41, "impressions": 2210, "ctr": 0.0186, "position": 24.7 },
  "queries": [
    { "keys": ["what is yaml frontmatter"], "clicks": 3, "impressions": 96, "ctr": 0.031, "position": 9.4 }
  ],
  "pages": [
    { "keys": ["https://yourapp.com/blog/yaml-frontmatter-explained"], "clicks": 5, "impressions": 423, "ctr": 0.0118, "position": 10.3 }
  ],
  "chart": [
    { "date": "2026-10-05", "label": "Oct 5", "clicks": 1, "impressions": 99 }
  ]
}
```

- `ctr` is a fraction (0.0186 = 1.86%). `position` is Google's average position.
- `queries` and `pages` hold every stored row (up to 1,000 each), sorted by clicks. `previousTotals` holds the same totals for the period before.
- A range that hasn't been synced yet is fetched from Google on the first request, which takes a few seconds.

## Errors

| Status | Meaning |
|---|---|
| 401 | Missing or invalid API key |
| 402 | No active subscription on the account |
| 400 | Project not found, multiple projects and none selected, or Search Console not bound for this project |

Prefer tool calls? The same data is available to agents as the [`get_search_performance`](/docs/mcp-get-search-performance) MCP tool.
