Ir al contenido
Won.dev
DocumentaciónReferencia de la API
API de comercio exterior

Consultar estadísticas de mercado

Tamaño de mercado, participación por país y tendencias mensuales, a partir de registros de embarque y estadísticas oficiales.

Mide un mercado y muestra dónde está y cómo se mueve: totales, los países de ambos lados y una serie mes a mes, para un producto o para una empresa. La respuesta mantiene separados dos tipos de cifras. records cuenta nuestros registros de embarque y suma sus valores declarados: sirve para tendencias y para el ritmo de compras de una empresa, pero no es un total de mercado, porque la cobertura varía por país y los conocimientos de embarque de EE. UU. no traen valor. official es lo que publican las oficinas de estadística: úsalo para el tamaño del mercado y la participación de cada país. Existe cuando se da un hs_code y la consulta indica el país importador o el exportador, para más de 200 países y territorios: las estadísticas propias del país cuando las publica, y si no, lo que sus socios reportan sobre su comercio con él, marcado como mirror. Va unos dos meses por detrás del mes actual para Estados Unidos, la UE y el Reino Unido, y a menudo más en otros lugares. coverage.recorded_value_share dice qué parte del valor oficial representan los valores registrados. Cuesta USD 0.10 por una consulta con resultados, o USD 0.02 cuando solo se pide o se encuentra official; sin resultados es gratis. Los meses marcados como partial todavía se están completando: no los leas como una caída. El rango puede abarcar hasta 36 meses.

  • Cobro: trade_stats USD 0.10: Una consulta de estadísticas de mercado con resultados. trade_official_stats USD 0.02: Una consulta de estadísticas de mercado respondida solo con estadísticas oficiales, o con conteos de embarques sin valores.
  • Modo: merge (qué significa cada modo)

Una clave de prueba (won_test_...) responde esta solicitud con las mismas empresas de muestra, sin costo.

POST
/trade/stats/query

Autenticación

apiKey
headerAuthorizationBearer <clave de API>

Authorization: Bearer won_live_..., a key from the console.

Parámetros de encabezado

Idempotency-Key?string

Any unique string. A retry with the same key and the same body returns the first response and is not charged again.

Longitudlength <= 255

Cuerpo de la solicitud

application/json
  1. body
hs_code?string

HS code, digits only. 6 to 10 digits for shipment records. Official statistics alone (basis: ["official"]) also take a 2-digit chapter or a 4-digit heading, such as 9401.

Longitudlength <= 20
product?string

Product keywords in English, such as office chair. A fuzzy match on the goods description. Use it when you do not know the HS code; an hs_code is more precise.

Longitud2 <= length <= 100
company?string

Only the records of this company: its co_ ID, or its name. Shows what one buyer or seller trades over time. Needs role. An ID with no hs_code, product or country, over the last 12 months (the default range), counts the company itself by its ID. Otherwise it is matched by its name as it stands in the records, so companies that share the name count together. records.company_match says which. Official statistics do not exist by company.

Longitud2 <= length <= 200
role?string

With company: count what it imports, or what it exports.

Valores"importer""exporter"
importer_country?string

Country the goods are imported into: an ISO code such as US, or an English name such as United States. EU is the European Union as a whole, in official statistics only.

Longitudlength <= 80
exporter_country?string

Country the goods are exported from: an ISO code such as VN, or an English name such as Vietnam. EU is the European Union as a whole, in official statistics only.

Longitudlength <= 80
since?string

First day of the date range, YYYY-MM-DD. Default: the first day of the month 12 months before until.

Longitudlength <= 10
until?string

Last day of the date range, YYYY-MM-DD. Default: up to the latest records.

Longitudlength <= 10
basis?array<>

Which numbers to return. Default: both. official alone is cheaper and answers from official statistics only.

Elementos1 <= items <= 2
Valor predeterminado
[  "records",  "official"]
top?integer

How many countries each breakdown lists, 1 to 50.

Rango1 <= value <= 50
Valor predeterminado20
max_cost?number

Spending cap for this call in US dollars. If the call could cost more, it fails with budget_exceeded before anything is charged.

Rango0 < value
dry_run?boolean

If true, only return the maximum cost of this call. Nothing runs, nothing is charged.

Valor predeterminadofalse

Cuerpo de la respuesta

The result. With dry_run, only the maximum cost.

application/json
  1. response
data*

The statistics, one part for each kind of number.

query*

The request as it was understood: country names as codes, the default dates filled in. data_through says how recent the records behind the answer are.

notice*|

A plain sentence when there is something to know about this result: why a part is missing, or what to try next. Null otherwise.

usage*

What this call was charged, and the balance left.

Solicitud de ejemplo
curl -X POST 'https://api.won.dev/v1/trade/stats/query' \  -H 'Content-Type: application/json' \  -d '{  "hs_code": "940161",  "importer_country": "US"}'
Respuesta de ejemplo
{  "data": {    "records": {      "shipments": 1165783,      "recorded_value_usd": 2620186000,      "by_importer_country": [        {          "country": "US",          "shipments": 1021440        }      ],      "by_exporter_country": [        {          "country": "VN",          "shipments": 932019        },        {          "country": "MY",          "shipments": 104871        },        {          "country": "MX",          "shipments": 58330        }      ],      "by_month": [        {          "month": "2026-07",          "shipments": 118420,          "recorded_value_usd": 251340118.2,          "partial": false        },        {          "month": "2026-08",          "shipments": 121077,          "recorded_value_usd": 259871402.75,          "partial": false        },        {          "month": "2026-09",          "shipments": 126295,          "recorded_value_usd": 270019576.35,          "partial": false        },        {          "month": "2026-10",          "shipments": 98114,          "recorded_value_usd": 204118330.1,          "partial": true        },        {          "month": "2026-11",          "shipments": 5526,          "recorded_value_usd": 3393700.19,          "partial": true        }      ]    },    "official": {      "reporter": "US",      "flow": "import",      "period": {        "since": "2025-11",        "until": "2026-09"      },      "value_usd": 4813000000,      "value_basis": "customs",      "cif_value_usd": 5102000000,      "by_partner_country": [        {          "country": "VN",          "value_usd": 2888000000,          "share": 0.6        },        {          "country": "MX",          "value_usd": 722000000,          "share": 0.15        },        {          "country": "CN",          "value_usd": 481000000,          "share": 0.1        }      ],      "by_month": [        {          "month": "2026-07",          "value_usd": 428000000        },        {          "month": "2026-08",          "value_usd": 417000000        },        {          "month": "2026-09",          "value_usd": 401000000        }      ],      "source": "official_statistics"    },    "coverage": {      "recorded_value_share": 0.6321    }  },  "query": {    "hs_code": "940161",    "importer_country": "US",    "since": "2025-11-01",    "until": "2026-11-20",    "basis": [      "records",      "official"    ],    "top": 20,    "data_through": "2026-11-11"  },  "notice": null,  "usage": {    "unit": "trade_stats",    "records": 1,    "already_paid": 0,    "cost": 0.1,    "balance": 47.98,    "replayed": false  }}

Última actualización: