COMEXT
Retrieve monthly bilateral merchandise trade data from Eurostat COMEXT, by reporting economy, partner country, product, trade direction, and measure.
Monthly time series Eurostat DS-045409Syntax
COMEXT(REPORTER.PARTNER.PRODUCT.FLOW.MEASURE.YYYYMM.YYYYMM)For example, Germany's monthly imports of Russian mineral fuels, January 2020 through December 2025:
russia=COMEXT(DE.RU.27.IMPORT.VALUE.202001.202512)
LINE_CHART(russia)
Arguments
| Argument | Meaning | Examples |
|---|---|---|
REPORTER | Reporting EU economy, using Eurostat country codes; aggregate reporter EU27_2020 is also accepted. | DE, FR, HU, EU27_2020 |
PARTNER | Partner economy or country. | RU, NL, BE |
PRODUCT | Numeric HS/CN product code, 2, 4, 6, or 8 digits. More digits identify more specific products. | 27, 2709, 2710, 2711, 2716 |
FLOW | Direction from the reporter's perspective. | IMPORT or EXPORT |
MEASURE | Trade value or weight. | VALUE or WEIGHT |
YYYYMM start/end | Inclusive monthly date range; start must not exceed end. | 202001.202512 |
VALUE is in euros, not thousands or millions of euros. WEIGHT is reported in units of 100 kilograms, not tonnes. For tonnes, multiply the returned weight by 0.1. Missing months remain missing; they are not filled with zeros.Product-code examples
| Code | Broad description | Analytical use |
|---|---|---|
27 | Mineral fuels, mineral oils, and related products | Broad energy-trade overview; mixes different commodities |
2709 | Crude petroleum oils | Crude oil imports |
2710 | Petroleum oils other than crude; certain preparations | Refined petroleum trade |
2711 | Petroleum gases and other gaseous hydrocarbons | Gas-related merchandise trade |
2716 | Electrical energy | Cross-border electricity trade values or weight indicator, where reported |
The COMEXT WEIGHT measure should not be treated as a reliable physical electricity quantity. For electricity flows in MWh or TWh, use an electricity-specific statistical source such as Eurostat energy balances or ENTSO-E.
Examples
1. Compare countries' direct imports from Russia
hu=COMEXT(HU.RU.27.IMPORT.VALUE.202001.202512)
sk=COMEXT(SK.RU.27.IMPORT.VALUE.202001.202512)
fr=COMEXT(FR.RU.27.IMPORT.VALUE.202001.202512)
be=COMEXT(BE.RU.27.IMPORT.VALUE.202001.202512)
nl=COMEXT(NL.RU.27.IMPORT.VALUE.202001.202512)
LINE_CHART(hu,sk,fr,be,nl)
2. Follow cross-country energy trade into Germany
de_nl=COMEXT(DE.NL.27.IMPORT.VALUE.202001.202512)
de_be=COMEXT(DE.BE.27.IMPORT.VALUE.202001.202512)
de_fr=COMEXT(DE.FR.27.IMPORT.VALUE.202001.202512)
LINE_CHART(de_nl,de_be,de_fr)Because the reporter is DE and the flow is IMPORT, these series are Germany's reported imports from the Netherlands, Belgium, and France—not those countries' exports to Germany as reported by the exporters.
3. Separate crude oil and refined petroleum
crude=COMEXT(DE.NL.2709.IMPORT.VALUE.202001.202512)
refined=COMEXT(DE.NL.2710.IMPORT.VALUE.202001.202512)
LINE_CHART(crude,refined)
4. Compare value with physical weight
value=COMEXT(DE.RU.2710.IMPORT.VALUE.202001.202512)
weight=COMEXT(DE.RU.2710.IMPORT.WEIGHT.202001.202512)
SLIDESHOW(LINE_CHART(value),LINE_CHART(weight))Use separate panels or axes: euros and 100 kg are not comparable units. Price changes can move value and weight in different directions.
5. Create a two-stage Sankey
ru_nl=COMEXT(NL.RU.27.IMPORT.VALUE.202001.202512)
nl_de=COMEXT(DE.NL.27.IMPORT.VALUE.202001.202512)
ru=sankey_link(0,Russia)
nl=sankey_link(1,Netherlands)
de=sankey_link(2,Germany)
a=sankey_path(ru,nl,ru_nl,red)
b=sankey_path(nl,de,nl_de,steelblue)
g=sankey_group(a,b)
animate_sankey_chart(set_title(g,Russia_Netherlands_Germany))How the data are retrieved
RainbowStats requests the Eurostat COMEXT dataset DS-045409 through its JSON-stat API at monthly frequency. Each call filters the reporter, partner, product, trade flow, measure, and requested time interval. The implementation stores successful responses in a local disk cache and reuses cached values for repeated calls. A successful empty response may also be cached.
The command accepts an EU reporter or EU aggregate; it is not a general worldwide reporter database. To study Russia's exports to India or Türkiye as reported by those non-EU economies, use a complementary source such as UN Comtrade.
Reading COMEXT results responsibly
- Values versus quantities: nominal trade values combine price and volume changes. Examine
WEIGHTwhere appropriate. - Missing is not zero: an absent monthly observation does not prove that trade stopped.
- Broad codes combine products: HS 27 includes crude oil, refined products, gas, coal, electricity, and other goods. Use narrower codes to test a specific energy hypothesis.
- Reporter perspective matters:
DE.NL...IMPORTis Germany's import declaration with the Netherlands as partner; it is not necessarily identical to the Netherlands' mirror export declaration. - Origin versus routing: bilateral trade does not trace individual shipments through processing, storage, or re-export.
- Sanctions: the existence of trade does not by itself show a legal violation; rules and exemptions vary over time and by commodity.
Reproducible RainbowStats study
See the companion Europe, Unite! analysis for a five-country Russian energy import line chart and a two-stage Sankey connecting Russia, selected EU countries, and Germany.