# Brazil Statistics API
> Official Brazilian economic statistics straight from IBGE (Instituto Brasileiro de Geografia e Estatística) and its SIDRA service — no key, read live. The ipca endpoint returns the IPCA, Brazil's official consumer price index, for the latest month: the headline index (base December 1993 = 100), the month-on-month change, the year-to-date change and the all-important twelve-month inflation rate that the Banco Central targets. The ipca/series endpoint returns the historical monthly IPCA index, monthly change and twelve-month rate over the last N months, ready to chart. The aggregate endpoint is a thin live gateway to any SIDRA aggregate: pass an aggregate id, one or more variable ids, a period selector and a territorial level and it returns the parsed series — opening up thousands of IBGE tables (population, GDP, employment, industry, retail) beyond inflation. The regions endpoint lists Brazil's 27 federative units with their region grouping. Live data from IBGE SIDRA, lightly cached; decimal values parsed to numbers. Live. 5 endpoints. This serves Brazilian national statistics; for the BRL exchange rate or policy rate use a central-bank / FX API.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/brazil-stats-api/..."
```

## Pricing
- **Free** (Free) — 240 calls/Mo, 2 req/s
- **Basic** ($11/Mo) — 20,500 calls/Mo, 6 req/s
- **Pro** ($29/Mo) — 102,000 calls/Mo, 22 req/s
- **Mega** ($65/Mo) — 455,000 calls/Mo, 55 req/s

## Endpoints

### Inflation

#### `GET /v1/ipca` — Brazil IPCA (latest month): index, MoM, YTD and 12-month inflation

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/brazil-stats-api/v1/ipca"
```

**Response:**
```json
{
    "data": {
        "index": 7640.15,
        "period": "202605",
        "source": "IBGE (Instituto Brasileiro de Geografia e Estatística) — SIDRA aggregate 1737",
        "country": "Brazil",
        "indicator": "IPCA — Índice Nacional de Preços ao Consumidor Amplo (official consumer price index)",
        "index_base": "December 1993 = 100",
        "period_iso": "2026-05",
        "change_12m_pct": 4.72,
        "change_ytd_pct": 3.2,
        "change_month_pct": 0.58
    },
    "meta": {
        "timestamp": "2026-06-15T20:41:02.093Z",
        "request_id": "235c8531-410a-4790-a6d6-f3f5383583fa"
    },
    "status": "ok",
    "message": "Brazil IPCA retrieved",
    "success": true
}
```

#### `GET /v1/ipca/series` — Historical IPCA index + monthly + 12-month series

**Parameters:**
- `months` (query, optional, string) — Number of recent months (default 24, max 120) Example: `24`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/brazil-stats-api/v1/ipca/series?months=24"
```

**Response:**
```json
{
    "data": {
        "count": 24,
        "series": [
            {
                "index": 6941.51,
                "period": "202406",
                "period_iso": "2024-06",
                "change_12m_pct": 4.23,
                "change_month_pct": 0.21
            },
            {
                "index": 6967.89,
                "period": "202407",
                "period_iso": "2024-07",
                "change_12m_pct": 4.5,
                "change_month_pct": 0.38
            },
            {
                "index": 6966.5,
                "period": "202408",
                "period_iso": "2024-08",
                "change_12m_pct": 4.24,
                "change_month_pct": -0.02
            },
            {
                "index": 6997.15,
                "period": "202409",
                "period_iso": "2024-09",
                "change_12m_pct": 4.42,
                "change_month_pct": 0.44
            },
            {
                "index": 7036.33,
                "period": "202410",
                "period_iso": "2024-10",
                "change_12m_pct": 4.76,
                "change_month_pct": 0.56
            },
            {
                "index": 7063.77,
                "period": "202411",
                "period_iso": "2024-11",
                "change_12m_pct": 4.87,
                "change_month_pct": 0.39
            },
            {
                "index": 7100.5,
                "period": "202412",
                "period_iso": "2024
…(truncated, see openapi.json for full schema)
```

### SIDRA

#### `GET /v1/aggregate` — Query any IBGE SIDRA aggregate

**Parameters:**
- `aggregate` (query, optional, string) — SIDRA aggregate id (default 1737 = IPCA) Example: `1737`
- `variable` (query, optional, string) — Variable id(s), pipe-separated (default 63 = monthly change) Example: `63`
- `periods` (query, optional, string) — Period selector: -1 (last n), 202605, or 202401-202605 (default -1) Example: `-1`
- `level` (query, optional, string) — Territorial level: N1 country, N2 region, N3 state (default N1) Example: `N1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/brazil-stats-api/v1/aggregate?aggregate=1737&variable=63&periods=-1&level=N1"
```

**Response:**
```json
{
    "data": {
        "level": "N1",
        "source": "IBGE SIDRA",
        "aggregate": "1737",
        "variables": [
            {
                "name": "IPCA - Variação mensal",
                "unit": "%",
                "values": [
                    {
                        "value": 0.58,
                        "period": "202605",
                        "period_iso": "2026-05"
                    }
                ],
                "variable_id": "63"
            }
        ]
    },
    "meta": {
        "timestamp": "2026-06-15T20:41:02.912Z",
        "request_id": "b22e5bf5-4afc-4682-8a1b-d2bd5dc8b55a"
    },
    "status": "ok",
    "message": "IBGE SIDRA aggregate retrieved",
    "success": true
}
```

### Reference

#### `GET /v1/regions` — Brazil federative units (states)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/brazil-stats-api/v1/regions"
```

**Response:**
```json
{
    "data": {
        "count": 27,
        "source": "IBGE localidades",
        "states": [
            {
                "id": 12,
                "name": "Acre",
                "region": {
                    "id": 1,
                    "name": "Norte",
                    "acronym": "N"
                },
                "acronym": "AC"
            },
            {
                "id": 27,
                "name": "Alagoas",
                "region": {
                    "id": 2,
                    "name": "Nordeste",
                    "acronym": "NE"
                },
                "acronym": "AL"
            },
            {
                "id": 16,
                "name": "Amapá",
                "region": {
                    "id": 1,
                    "name": "Norte",
                    "acronym": "N"
                },
                "acronym": "AP"
            },
            {
                "id": 13,
                "name": "Amazonas",
                "region": {
                    "id": 1,
                    "name": "Norte",
                    "acronym": "N"
                },
                "acronym": "AM"
            },
            {
                "id": 29,
                "name": "Bahia",
                "region": {
                    "id": 2,
                    "name": "Nordeste",
                    "acronym": "NE"
                },
                "acronym": "BA"
            },
            {
                "id": 23,
            
…(truncated, see openapi.json for full schema)
```

### Meta

#### `GET /v1/meta` — API metadata

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/brazil-stats-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "api": "Statistics of Brazil (IBGE) API",
        "notes": "Live data from IBGE's SIDRA service. The aggregate endpoint can query any SIDRA aggregate/variable for any territorial level.",
        "source": "IBGE — Instituto Brasileiro de Geografia e Estatística, SIDRA REST API (servicodados.ibge.gov.br)",
        "country": "Brazil",
        "endpoints": [
            "/v1/ipca",
            "/v1/ipca/series",
            "/v1/aggregate",
            "/v1/regions",
            "/v1/meta"
        ],
        "documentation": "https://brazil-stats-api.oanor.dev",
        "primary_indicator": "IPCA — official consumer price index (SIDRA aggregate 1737, monthly, base Dec 1993=100)"
    },
    "meta": {
        "timestamp": "2026-06-15T20:41:03.300Z",
        "request_id": "34e459c6-351b-4457-baa2-0030112afbfd"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/brazil-stats-api
OpenAPI spec: https://www.oanor.com/api/brazil-stats-api/openapi.json
