# EU Trade Explorer -- REST API HTTP REST API for the EU Trade Explorer, serving Eurostat Comext (customs trade) and PRODCOM (industrial production) statistics for the Combined Nomenclature. > Bridge to the tradedashboard.eu EU Trade Explorer — access the same data via REST endpoints or, for LLM agents, via the MCP bridge at mcp.tradedashboard.eu. ## Typical Workflow 1. **Resolve the product**: If you don't already know the right Combined Nomenclature (CN) customs code, use `/api/reference/search` with a keyword (e.g. "glass jars") and `/api/reference/validate-customs-code/{customs_code}` for a candidate code. Note that CN nomenclature is often coarser than a colloquial product name: there is no code for "glass jars" alone, only a heading (7010) that bundles jars with bottles and closures; check `has_subcodes` and the returned hierarchy before assuming a code is a clean match. 2. **Choose your path**: - **Short path**: Call `/api/descriptive/overview` for the headline totals. For a quick analysis, that plus `/api/descriptive/partner-detail` and `/api/concentration/concentration` is often enough. - **Long path**: There are ~25 analytical endpoints you can call iteratively depending on your angle: drill into `/api/descriptive/reporter-detail`, `/api/concentration/specialisation`, `/api/vulnerability/net-import-reliance`, etc. as needed. ## Request Model Every analytical endpoint takes the same `DashboardQuery` JSON body: - `customs_code`: Combined Nomenclature code(s) -- one code or a list; each code is one basket over the full requested period - `baskets`: the explicit form of the customs-code selection (a list of baskets, each a list of `(customs_code, optional from/to month)` pieces summed into one line) -- use it to clip a code to specific months or to chain successor codes; exactly one of `customs_code` and `baskets` - `reporter`: Declaring entity (EU Member State, etc.) - `partner_set`: Named partner preset or custom list - `period_start`, `period_end`: Analysis window (YYYY-MM format) - `frequency`: 'month', 'quarter', or 'year' - Plus endpoint-specific query parameters (`entity_level`, `flow`, `partner`, detection thresholds, ...) ## Streaming Responses The analytical endpoints under `/api/descriptive`, `/api/concentration`, `/api/volatility`, `/api/vulnerability`, `/api/autonomy` and `/api/production` do not return a single JSON object. They stream newline-delimited JSON (`application/jsonl`): zero or more `{"type": "progress", "message": ...}` lines while Eurostat data loads, then exactly one terminal frame — either `{"type": "result", "data": ...}` or `{"type": "error", "detail": ..., "status": ...}`. Many endpoints also accept a `compact=true` query parameter to condense long numeric time series into summary statistics (first/last/min/max/mean/pct_change) instead of full series. Use this when you just want main trends; omit it when identifying shocks and outliers. ## Authentication & Access Everything under `/api/reference` and `/api/auth` is public and unlimited. The analytical endpoints (`/api/descriptive`, `/api/concentration`, `/api/volatility`, `/api/vulnerability`, `/api/autonomy`, `/api/production`) require registration: anonymous calls for non-demonstration customs codes get HTTP 401 with a registration invitation. The only anonymous exception: queries made entirely of the dashboard's welcome-page demonstration customs codes, which stay fully browsable without an account, on every analytical endpoint. Registering is free and currently unlimited — register once, then use one of: - A signed-in session cookie (from the dashboard UI) - A personal API key sent as `Authorization: Bearer ...` or `X-API-Key` - OAuth 2.1 authentication (for programmatic/headless clients) See `/.well-known/oauth-authorization-server` for OAuth setup details. LLM agents and MCP clients should use the MCP bridge at mcp.tradedashboard.eu instead: there, listing the tools is open but every tool call requires an account credential, either OAuth 2.1 or the same personal API key sent as `Authorization: Bearer ...` or `X-API-Key` (no anonymous demonstration products, no free reference tools). ### Credentials Sessions, personal API keys and OAuth access tokens are accepted. Personal keys and OAuth tokens may read data and configure the account, but may not delete it, issue or revoke credentials, approve apps, or perform financial actions such as paying or cancelling a subscription; those actions require an interactive session. Revoking a personal key, token or connected app takes effect immediately. A password reset ends every existing session, personal key and OAuth credential: afterwards, log in again, create a new API key and reconnect your apps. Requests are additionally rate-limited per client IP at the edge (Caddy), ahead of this application, and successful analytical responses are edge-cached for 30 minutes -- a cache hit replays instantly and spends no compute. ## Dashboard Navigation You typically do not need to construct these API calls yourself if you're using the interactive dashboard. Instead, refer to the relevant menu item/tab on the website. For programmatic access, the dashboard structure is: | Menu | Name | Tab | Typical API endpoints | |------|------|-----|----------------------| | `overview` | Overview | `overview`, `report` | `/api/descriptive/overview` | | `by-country` | Distribution by country | `partners`, `reporters`, `reporter-benchmark`, `map-imports`, `map-exports` | `/api/descriptive/partner-detail`, `/api/descriptive/reporter-detail`, `/api/descriptive/reporter-benchmark`, `/api/descriptive/map-data` | | `concentration` | Market structure | `concentration`, `concentration-map`, `specialisation`, `production-volumes` | `/api/concentration/concentration`, `/api/concentration/concentration-map`, `/api/concentration/specialisation`, `/api/production/series` | | `cross-section` | Cross-section | `compare`, `subcode-volatility`, `subcode-concentration` | `/api/descriptive/subcode-compare`, `/api/volatility/volatility`, `/api/concentration/concentration-compare` | | `volatility` | Volatility & shocks | `volatility`, `supply-shocks`, `price-shocks`, `pattern-shifts` | `/api/volatility/volatility`, `/api/volatility/supply-shocks`, `/api/volatility/price-shocks`, `/api/volatility/pattern-shift` | | `vulnerability` | Strategic autonomy | `net-import-reliance`, `trade-intensity`, `export-propensity`, `subcontracting-*` | `/api/vulnerability/net-import-reliance`, `/api/vulnerability/trade-intensity`, `/api/vulnerability/export-propensity`, `/api/autonomy/subcontracting`, `/api/autonomy/subcontracting-reporters` | ## Methodological Notes These notes are reproduced here so figures can be interpreted and cited correctly: - **Concentration (HHI)**: The Herfindahl-Hirschman Index measures how concentrated trade is across partners or EU Member States. For each period, it sums the squared market shares of each entity, producing a score from 0 (perfectly spread across many partners) to 10,000 (one partner holds 100% of the market). - **Specialisation (RSCA)**: Intra-EU revealed symmetric comparative advantage per Member State: whether a Member State's share of intra-EU exports for a specific customs code is larger than its share of intra-EU exports overall. The Balassa index (RCA) compares a Member State's export share of the customs code against its export share of all goods (both measured within the EU); RSCA rescales RCA symmetrically onto [-1, 1]: RCA = (x_p / x_total) / (X_p / X_total), RSCA = (RCA - 1) / (RCA + 1), where x is the Member State's intra-EU exports and X is the EU total (p = this customs code, total = all goods). -1 is under-specialised, 0 is the EU average, +1 is strongly specialised. Intra-EU flows are distorted by the Rotterdam/Antwerp effect, so read the index with caution. - **Volatility (CV)**: Each value is the coefficient of variation (CV): standard deviation divided by the mean, for a single partner × customs-code pair over the selected period. Inactive periods (zero quantity) are excluded so they don't distort the result. A higher CV means the flow swings more relative to its typical level. Only the most active partners by volume are selected for volatility analysis. - **Supply shocks**: Detects abnormal collapses in trade volumes. For each partner × customs-code pair with enough sustained activity, the algorithm flags periods where volume drops well below that pair's historical average. To surface more (weaker) shocks: lower the minimum-deviation threshold, raise the cumulative trade share considered, extend tolerated gaps, lower the minimum number of stable years required, or treat any small drop (even ~5%) as a shock. - **Price shocks**: Detects sudden price variations while accounting for each flow's usual volatility. The algorithm compares each period's price against a retrospective reference window, then flags regime changes whose amplitude exceeds a configurable multiple of the coefficient of variation. - **Pattern shifts**: Suggested workflow: note the usual volatility of the entities that interest you (via volatility endpoints), check for significant volume/price variations there, use supply/price shock endpoints to identify the dates where these are most pronounced, then use one of those dates as the `midpoint` query parameter in `/api/volatility/pattern-shift`. - **Net import reliance (NIR)**: Expresses net imports (imports minus exports) as a share of domestic consumption in the Union: NIR = (Imports - Exports) / Apparent consumption, where Apparent consumption = Production + Imports - Exports. E.g., 40% means 40% of EU consumption of the goods is met by imports; negative means the EU is a net exporter (not import-dependent). Used by the European Commission to determine whether a sector should get particular monitoring or support. - **Trade intensity (TI)**: Measures how open EU27 production is to international trade, following the European Commission's CEEAG methodology (used for State-aid eligibility of sectors at risk of carbon leakage): TI = (Imports + Exports) / (Imports + Production). Close to 1 = highly trade-exposed; near 0 = predominantly domestic. - **Export propensity**: The share of EU27 production sold abroad: Export propensity = Exports / Production. E.g., 60% means 60% of the value produced in the Union is exported; re-exports or stock drawdown can push values above 100%. - **Subcontracting intensity**: The share of EU production manufactured for someone other than the factory's owner: Intensity = Sub-contracted production / Total sold production. Near 100% signals a processing hub with little own R&D; near 0% marks an autonomous industrial base. The own/sub split only exists from 2021 onward in the PRODCOM database. - **PRODCOM-backed endpoints**: For production volumes and all vulnerability endpoints—when a customs code maps to several PRODCOM codes, figures are aggregated across them, or, if Eurostat suppresses detail at that level, sourced from the nearest available higher aggregate. Use the `prodcom_code` query parameter to pin one specific mapping instead of relying on that default. - **Rotterdam/Antwerp caveat**: Whenever Belgium or the Netherlands appear as the main trading importer or exporter of a product, beware: it might just be that the bulk of the trade for that product is transiting through Antwerp or Rotterdam. ## reference Public reference data: country lists, UI language detection, customs-code validation/search and nomenclature trees. - `GET /api/reference/countries` — Get Countries - `GET /api/reference/language` — Get Language - `GET /api/reference/validate-customs-code/{customs_code}` — Validate Customs Code - `GET /api/reference/data-range` — Get Data Range - `GET /api/reference/comext-status` — Get Comext Status - `GET /api/reference/chapters` — Get Chapters - `GET /api/reference/subtree/{customs_code}` — Get Subtree - `GET /api/reference/search` — Search Customs Codes - `GET /api/reference/data-status` — Get Data Status ## dashboard Descriptive statistics for the main dashboard: overview totals, partner/reporter breakdowns, the map view and entity tables. - `POST /api/descriptive/overview` — Get Overview - `POST /api/descriptive/partner-detail` — Get Partner Detail - `POST /api/descriptive/reporter-detail` — Get Reporter Detail - `POST /api/descriptive/reporter-benchmark` — Get Reporter Benchmark - `POST /api/descriptive/map-data` — Get Map Data - `POST /api/descriptive/top-entities` — Get Top Entities ## subcodes Cross-section views comparing sub-codes or several codes side by side. - `POST /api/descriptive/subcode-compare` — Get Subcode Compare ## concentration Concentration analysis via the Herfindahl-Hirschman Index (HHI): trade concentration across partners/Member States (overall, per sub-code and on the map) and intra-EU specialisation. - `POST /api/concentration/concentration` — Get Concentration - `POST /api/concentration/concentration-compare` — Get Concentration Compare - `POST /api/concentration/concentration-map` — Get Concentration Map - `POST /api/concentration/specialisation` — Get Specialisation ## volatility Volatility and shock detection: coefficient-of-variation grids, sudden volume collapses, rapid price shifts and pattern shifts. - `POST /api/volatility/volatility` — Get Volatility - `POST /api/volatility/pattern-shift` — Get Pattern Shift - `POST /api/volatility/supply-shocks` — Get Volatility Supply Shocks - `POST /api/volatility/price-shocks` — Get Volatility Price Shocks ## vulnerability Industrial-exposure indicators that join PRODCOM production with Comext trade data: Net Import Reliance, Trade Intensity and Export Propensity. - `POST /api/vulnerability/net-import-reliance` — Get Net Import Reliance - `POST /api/vulnerability/trade-intensity` — Get Trade Intensity - `POST /api/vulnerability/export-propensity` — Get Export Propensity ## autonomy Industrial-autonomy indicators built on the PRODCOM sub-contracting / own-account split: how much of EU (and member-state) sold production is toll manufacturing for others. - `POST /api/autonomy/subcontracting` — Get Subcontracting Intensity - `POST /api/autonomy/subcontracting-reporters` — Get Subcontracting Reporters ## production PRODCOM production volumes: EU27 and per-country production series, and how concentrated that production is across the reporting countries (HHI). - `POST /api/production/series` — Get Production Series - `POST /api/production/concentration` — Get Production Concentration ## auth Account lifecycle: register, email verification, login/logout, password reset and per-user preferences. - `POST /api/auth/register` — Auth Register - `GET /api/auth/verify` — Auth Verify - `POST /api/auth/login` — Auth Login - `POST /api/auth/logout` — Auth Logout - `GET /api/auth/me` — Auth Me - `POST /api/auth/email-prefs` — Auth Email Prefs - `POST /api/auth/themes` — Auth Create Theme - `POST /api/auth/themes/{theme_id}` — Auth Update Theme - `DELETE /api/auth/themes/{theme_id}` — Auth Delete Theme - `POST /api/auth/theme-preference` — Auth Theme Preference - `GET /api/auth/theme.css` — Auth Current Theme Css - `POST /api/auth/resend-verification` — Auth Resend - `POST /api/auth/request-password-reset` — Auth Request Reset - `POST /api/auth/reset-password` — Auth Reset Password - `POST /api/auth/set-lang` — Auth Set Lang - `POST /api/auth/delete-account` — Auth Delete Account ## searches Account search lifecycle: record recent dashboard searches, save searches and remove saved searches. - `POST /api/searches/recent` — Searches Add Recent - `POST /api/searches/saved` — Searches Save - `DELETE /api/searches/saved/{search_id}` — Searches Remove Saved ## reports On-demand report generation: request reports, list request history and trial usage, plus the report pages' account gate and the full report text for registered readers. - `POST /api/reports/request` — Reports Request - `GET /api/reports/requests` — Reports Requests - `POST /api/reports/pdf-access` — Reports Pdf Access - `GET /api/reports/pdf-confirm` — Reports Pdf Confirm ## api-key Self-service personal API key management: generate, rotate and revoke the Bearer credential used for headless/programmatic REST access. - `POST /api/api-key/generate` — Auth Generate Api Key - `POST /api/api-key/revoke` — Auth Revoke Api Key ## oauth OAuth 2.1 authorization server backing MCP-client logins (e.g. an editor): dynamic client registration, the authorize/token/ revoke endpoints, and the account panel's connected-apps list/revoke. - `GET /.well-known/oauth-authorization-server` — Oauth Server Metadata - `POST /oauth/register` — Oauth Register Client - `GET /oauth/authorize` — Oauth Authorize Get - `POST /oauth/token` — Oauth Token - `POST /oauth/revoke` — Oauth Revoke - `GET /api/oauth/client-info` — Api Oauth Client Info - `POST /api/oauth/decision` — Api Oauth Decision - `GET /api/oauth/grants` — Api Oauth List Grants - `POST /api/oauth/grants/revoke` — Api Oauth Revoke Grant ## theme The theme builder: an organisation's two brand colours in, chart palettes for day, night and print and the interface colours of day and night out. Registered users only. - `GET /api/theme` — Get Theme - `GET /api/theme/custom/{theme_id}.css` — Get Custom Theme Css - `GET /api/theme/custom/{theme_id}` — Get Custom Theme ## Docs - [OpenAPI schema](https://tradedashboard.eu/openapi.json) - [Interactive API docs](https://tradedashboard.eu/openapi.html) - [Help](https://tradedashboard.eu/faq-en.html) ## Agent / MCP access The same underlying data is also exposed as MCP tools for LLM agents over Streamable HTTP, at a *different* surface (tool names, a single `query` argument, a `compact` summarisation mode, and a couple of helper tools this REST API doesn't have). Its own auto-generated manifest -- kept in sync with its actual tool registry, not with this file -- is at https://mcp.tradedashboard.eu/llms.txt. ## Additional Resources - [Dashboard](https://tradedashboard.eu/) - [Sitemap](https://tradedashboard.eu/sitemap.xml)