# eurostat.consumer_spend

**stable** **Standard**

Household consumption spending by purpose (COICOP category) for up to 10 European countries plus the EU27 aggregate, annual, as a JSON-stat cube.

`GET /v1/eurostat/consumer_spend`

## What you get

One Eurostat record in Onekey's unified shape, in `data`. If the record does not exist you get a `404 not_found` and are not charged.

## What it costs

- **Standard · 1 credit** for a fresh fetch, charged only when it succeeds.
- **Free when served from cache (0.2 credit for a cached response over 100 KB).**
- **Free** if the request is invalid (never charged) or the source fails or reports not found (refunded).

## Parameters

| Name | Type | Required | Default | What it is | Constraints |
| --- | --- | --- | --- | --- | --- |
| `geo` | string | no | `EU27_2020` | Reporting country codes joined by + (URL-encode it as %2B), up to 11: two-letter Eurostat codes (DE, FR, EL for Greece...) and/or EU27_2020 / EA20, e.g. DE%2BFR%2BEU27_2020 | max 120 chars; must match `(?:[A-Z]{2}\|EU27_2020\|EA20)(?:\+(?:[A-Z]{2}\|EU27_2020\|EA20)){0,10}`; trimmed, upper |
| `coicop` | string | no | `TOTAL` | COICOP 1999 purpose code, e.g. TOTAL, CP01 (food and non-alcoholic beverages), CP07 (transport), CP11 (restaurants and hotels), CP111 (catering) | max 10 chars; must match `TOTAL\|CP(?:0[1-9]\|1[0-2])\d?\|CP122_127`; trimmed, upper |
| `unit` | string | no | `CP_MEUR` | Unit of measure: CP_MEUR (current prices, million euro), CP_MNAC (million national currency), CP_EUR_HAB / CP_NAC_HAB (per capita), PC_TOT (share of total), PC_GDP (share of GDP), CLV20_MEUR / CLV15_MEUR (chain-linked volumes), CLV_PCH_PRE (volume change on previous year), PD20_EUR (price index 2020=100) | max 16 chars; must match `CP_MEUR\|CP_MNAC\|CP_EUR_HAB\|CP_NAC_HAB\|PC_TOT\|PC_GDP\|CLV20_MEUR\|CLV15_MEUR\|CLV10_MEUR\|CLV20_MNAC\|CLV15_MNAC\|CLV10_MNAC\|CLV_I20\|CLV_I15\|CLV_PCH_PRE\|PYP_MEUR\|PYP_MNAC\|PD20_EUR\|PD15_EUR\|PD20_NAC\|PD15_NAC\|PD_PCH_PRE_EUR\|PD_PCH_PRE_NAC`; trimmed, upper |
| `start` | string | no | `2015` | First year (YYYY) | max 4 chars; must match `(?:19[5-9]\d\|20\d{2})`; trimmed |
| `end` | string | no | `2100` | Last year (YYYY); the default 2100 means the latest year published | max 4 chars; must match `(?:19[5-9]\d\|20\d{2}\|2100)`; trimmed |

## Request

```bash
curl "https://api.onekey.dev/v1/eurostat/consumer_spend?geo=DE%2BFR%2BEU27_2020&coicop=CP01&start=2020" \
  -H "x-api-key: YOUR_API_KEY"
```

```python
import requests

res = requests.get(
    "https://api.onekey.dev/v1/eurostat/consumer_spend",
    params={"geo": "DE+FR+EU27_2020", "coicop": "CP01", "start": "2020"},
    headers={"x-api-key": "YOUR_API_KEY"},
)
body = res.json()

if body["success"]:
    print(body["data"])
else:
    print(body["error"]["code"], body["error"]["message"])
```

```javascript
const params = new URLSearchParams({ geo: "DE+FR+EU27_2020", coicop: "CP01", start: "2020" });
const res = await fetch(`https://api.onekey.dev/v1/eurostat/consumer_spend?${params}`, {
  headers: { "x-api-key": "YOUR_API_KEY" },
});
const body = await res.json();

if (body.success) console.log(body.data);
else console.error(body.error.code, body.error.message);
```

## Recorded response

A real Eurostat response, recorded and returned in Onekey's shape. Fields the platform does not provide are `null`.

```json
{
  "success": true,
  "data": {
    "entity": {
      "name": "Household final consumption expenditure by purpose (COICOP 1999)"
    },
    "ext": {
      "updated": "2026-10-21T23:00:00+0200",
      "dimensions": [
        "freq",
        "unit",
        "coicop",
        "geo",
        "time"
      ],
      "size": [
        1,
        1,
        1,
        3,
        6
      ],
      "values": {
        "0": 1005677.9,
        "1": 1029814.4,
        "2": 1110216.7,
        "6": 194450,
        "7": 200574,
        "8": 216357,
        "12": 177214,
        "13": 176438,
        "14": 182900
      },
      "flags": {
        "6": "p",
        "7": "p",
        "8": "p",
        "13": "p",
        "14": "p"
      },
      "geo": {
        "index": {
          "EU27_2020": 0,
          "DE": 1,
          "FR": 2
        },
        "label": {
          "EU27_2020": "European Union - 27 countries (from 2020)",
          "DE": "Germany",
          "FR": "France"
        }
      },
      "time": {
        "index": {
          "2020": 0,
          "2021": 1,
          "2022": 2,
          "2023": 3,
          "2024": 4,
          "2025": 5
        },
        "label": {
          "2020": "2020",
          "2021": "2021",
          "2022": "2022",
          "2023": "2023",
          "2024": "2024",
          "2025": "2025"
        }
      },
      "coicop": {
        "index": {
          "CP01": 0
        },
        "label": {
          "CP01": "Food and non-alcoholic beverages"
        }
      },
      "unit": {
        "index": {
          "CP_MEUR": 0
        },
        "label": {
          "CP_MEUR": "Current prices, million euro"
        }
      }
    }
  },
  "metadata": {
    "platform": "eurostat",
    "endpoint": "consumer_spend",
    "cached": false,
    "stale": false,
    "age_s": 0,
    "fetched_at": "2026-01-01T12:00:00+00:00",
    "credits_charged": 1,
    "request_id": "7f3a9c2e5b1d4c8fa2e6d0b9c4f18e37"
  },
  "error": null
}
```

## Field mapping

How this endpoint's source fields become Onekey's [unified schema](https://onekey.dev/docs/schema.md). Fields the source lacks come back as `null`.

| Source path | Onekey field | Transform |
| --- | --- | --- |
| `label` | `entity.name` | - |
| `updated` | `ext.updated` | - |
| `id` | `ext.dimensions` | - |
| `size` | `ext.size` | - |
| `value` | `ext.values` | - |
| `status` | `ext.flags` | - |
| `dimension.geo.category` | `ext.geo` | - |
| `dimension.time.category` | `ext.time` | - |
| `dimension.coicop.category` | `ext.coicop` | - |
| `dimension.unit.category` | `ext.unit` | - |

## Caching and freshness

- Fresh for about 6 hours. Repeat calls in that window are served from cache and are free.
- Between 6 hours and 7 days the cached copy is still served instantly and marked `stale: true` while Onekey refreshes it in the background.
- If the source is down when a refresh is needed, the last copy can be served for up to 7 days more (marked stale).
- A "not found" is remembered for 1 hour and is free.
- The cache is shared across all customers, which is what keeps repeat calls cheap.

## What can go wrong

| Status | Code | What to do |
| --- | --- | --- |
| 401 | `unauthorized` | Check the `x-api-key` header. |
| 402 | `insufficient_credits` | [Add credits](https://onekey.dev/pricing); your balance must cover the price. |
| 404 | `not_found` | That record does not exist. Free; do not retry. |
| 422 | `invalid_params` | Fix the parameters using the table above. Free. |
| 429 | `rate_limited` | Wait `Retry-After` seconds, then retry. |
| 502 | `upstream_error` | The source failed. Refunded; retry with backoff. |

See [Errors](https://onekey.dev/docs/errors.md) for the full list and retry guidance.

Status: stable (verified against the live source).
