RainbowStats · Data Source Reference

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-045409

Syntax

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

ArgumentMeaningExamples
REPORTERReporting EU economy, using Eurostat country codes; aggregate reporter EU27_2020 is also accepted.DE, FR, HU, EU27_2020
PARTNERPartner economy or country.RU, NL, BE
PRODUCTNumeric HS/CN product code, 2, 4, 6, or 8 digits. More digits identify more specific products.27, 2709, 2710, 2711, 2716
FLOWDirection from the reporter's perspective.IMPORT or EXPORT
MEASURETrade value or weight.VALUE or WEIGHT
YYYYMM start/endInclusive monthly date range; start must not exceed end.202001.202512
Units: 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

CodeBroad descriptionAnalytical use
27Mineral fuels, mineral oils, and related productsBroad energy-trade overview; mixes different commodities
2709Crude petroleum oilsCrude oil imports
2710Petroleum oils other than crude; certain preparationsRefined petroleum trade
2711Petroleum gases and other gaseous hydrocarbonsGas-related merchandise trade
2716Electrical energyCross-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))
Interpretation warning: the two Sankey legs are independent bilateral trade observations. They do not establish that Russian-origin fuel entering the Netherlands was subsequently shipped to Germany, nor do they establish sanctions circumvention. The link widths need not balance at the intermediary node.

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

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.

Open reproducible scriptEurostat COMEXT API