Trade data API
Customs records, buyers and suppliers, contacts and market statistics over one REST API, billed by the results it returns.
The trade data API answers what an exporter, a sourcing team or their agent asks: who buys this product, who supplies my competitor, how do I reach them, how big is the market. Every endpoint is JSON over HTTPS.
- Base URL:
https://api.won.dev/v1 - OpenAPI 3.1 document:
https://api.won.dev/v1/openapi.json - Every page of these docs is also available as Markdown: add
.mdto its URL.
Authentication
Send your API key in the Authorization header. Authentication covers live and test keys, budgets and how requests are made.
curl "https://api.won.dev/v1/trade/hs-codes?q=office%20chair" \
-H "Authorization: Bearer $WON_API_KEY"GET endpoints take their parameters in the query string, with lists comma-separated (include=partners,contacts). POST endpoints take a JSON body. A parameter the endpoint does not know is an error, never silently ignored, and one invalid_input response lists every parameter that needs fixing.
Endpoints
| Endpoint | Request | Billed by |
|---|---|---|
| Find HS codes | GET /trade/hs-codes | Free |
| Check data coverage | GET /trade/coverage | Free |
| Find buyers or suppliers | POST /trade/companies/search | trade_company $0.01 |
| Search shipment records | POST /trade/shipments/search | trade_record $0.005 |
| Look up a company | GET /trade/companies/lookup | trade_lookup $0.02 |
| Get a company | GET /trade/companies/{id} | trade_company_profile $0.04, trade_company $0.01, trade_record $0.005, person_email $0.03, company_channels $0.02 |
| List a company's shipments | GET /trade/companies/{id}/shipments | trade_record $0.005 |
| List a company's trading partners | GET /trade/companies/{id}/partners | trade_company $0.01 |
| Find contacts at a company | GET /trade/companies/{id}/contacts | person_email $0.03 |
| Find leads | POST /trade/leads/find | trade_company $0.01, person_email $0.03, company_channels $0.02 |
| Get market statistics | POST /trade/stats/query | trade_stats $0.10, trade_official_stats $0.02 |
A typical flow
GET /trade/hs-codes?q=office chairfinds the HS code of the product. Free.POST /trade/companies/searchranks its buyers or suppliers.GET /trade/companies/{id}/contactsfinds the people to approach at one of them.POST /trade/leads/finddoes steps 2 and 3 in one call.POST /trade/stats/querysizes the market and shows which countries it is in.
Billing by result
You pay for the results a call returns, never for the call itself.
| Unit | Price | What is counted |
|---|---|---|
trade_record | $0.005 | One shipment record. |
trade_company | $0.01 | One company in a list of buyers, suppliers or partners, or the company of a lead. |
trade_company_profile | $0.04 | One company profile. |
trade_lookup | $0.02 | One lookup by name or website that finds at least one company. |
person_email | $0.03 | One contact with a work email on the company's own domain that passed verification. |
company_channels | $0.02 | The shared mailboxes, phone numbers or messaging contacts found on one company's website, however many. |
trade_stats | $0.10 | One market statistics query with results. |
trade_official_stats | $0.02 | One market statistics query answered from official statistics only. |
- An empty result is free. So is a failed request.
- The same request again within 24 hours is free: it returns the stored answer with
usage.replayed: trueandcost: 0. An answer whosenoticesays a part could not be loaded is not stored: the repeat loads it again, and what you already paid for is not charged a second time. - A result your organization paid for in the last 30 days comes back free, whichever request or endpoint returns it, and
usage.already_paidcounts it. A lookup and a market statistics query answer one question, so each one is charged. Seeusage. - The same request sent while the first one is still running fails with
request_in_progress. Waitretry_afterseconds and send it again. dry_run: truereturns the most the call can cost, and how many results match when that is already known. Nothing runs and nothing is charged.max_costcaps one call in US dollars. If the call could cost more, it fails withbudget_exceededbefore anything is charged, and the hint names thelimitthat fits.- The balance has to cover the most a call can cost. That amount is reserved while the call runs, and only what came back is charged.
POSTrequests take anIdempotency-Keyheader: any unique string. A retry with the same key and the same body returns the first response and is not charged again. The same key with a different body fails withidempotency_conflict. See Idempotency.
Every response ends with usage: what the call cost and the balance left.
{
"usage": {
"unit": "trade_company",
"records": 25,
"cost": 0.25,
"balance": 48.75,
"replayed": false
}
}A dry_run response:
{
"data": {
"dry_run": true,
"max_cost": 0.25,
"breakdown": [
{
"unit": "trade_company",
"max_records": 25,
"unit_price": 0.01,
"max_cost": 0.25
}
]
},
"total": 4087,
"query": {
"role": "importer",
"hs_code": "940161",
"importer_country": "US",
"limit": 25
},
"notice": null,
"usage": {
"unit": "trade_company",
"records": 0,
"cost": 0,
"balance": 49,
"replayed": false
}
}Modes
Each endpoint has one fixed way of using the data sources behind it. You never choose a source and never see one's name; the mode tells you what to expect of the answer and of the bill.
proxy: one source answers. We normalize the fields, give every company, shipment and person a stable ID, and bill by row.merge: several sources each contribute the part they are good at, in one response. A part that cannot be loaded isnulland is not charged.waterfall: sources are tried in a fixed order, cheapest first, until the result qualifies. Only a qualifying result is charged, at one fixed price, whichever step found it.composite: an endpoint that chains the three, such as leads.
Pagination
List endpoints take limit and cursor, and return total, has_more and next_cursor. Pass next_cursor as cursor with the same parameters to get the next page. A cursor works only with the query that produced it and expires after 24 hours. A query can be paged through its first 10,000 results; beyond that, narrow it with a shorter date range, a country or a longer hs_code. See Pagination.
In every response
Every answer has the same top-level fields, in the same order: see Responses.
query: the request as it was understood, with defaults filled in and countries, codes and dates normalized. Check it when a result surprises you.query.data_throughis the date of the newest record the answer could include.notice:null, or one or two sentences about this result: why it is empty, what is left out, what to call next. Agents should read it.- IDs are stable and typed by prefix:
co_for a company,shp_for a shipment,per_for a person. Pass a company's ID to the company endpoints. - Dates are
YYYY-MM-DD, countries are ISO 3166 two-letter codes, money is in US dollars. See Reading the numbers for what the counts and values mean.
Test keys
A key that starts with won_test_ gets fixed sample data from every endpoint: made-up companies named SAMPLE ..., people who do not exist, the same response shapes and the same validation. It costs nothing and never reaches a data source, so use it in tests and while you build. The examples in these docs show the same sample companies.