快速上手
用免费的测试 key,五分钟内跑通第一批调用:查出一种商品的进口商和该联系的人,看清正式调用要花多少钱,再切换到正式环境。
跟着这一页走,你会从没有 key 开始,拿到一份按进口量排名的买家列表,以及其中一家公司里该联系的人。全程使用测试 key:它返回样例数据,永远不扣费,所以充值之前就能完整跑一遍。
你需要一个 Won.dev 账号和 curl。用 Google 账号或邮箱验证码登录即可,新账号自带 $1 免费额度,不需要绑卡。
1. 创建测试 key
在控制台打开 API key 页面,点击 创建 key,模式选 测试。key 只显示一次:请存进环境变量,不要写进在浏览器里运行的代码。
export WON_API_KEY=won_test_...测试 key 能调用正式 key 的所有接口,参数、校验和返回结构都一样。见测试。
2. 查出商品的 HS 编码
海关数据按 HS 编码检索,这是海关给每一类商品编的号。用商品的普通叫法就能查到。这一步用任何 key 都免费。
curl "https://api.won.dev/v1/trade/hs-codes?q=sofa&limit=2" \
-H "Authorization: Bearer $WON_API_KEY"{
"data": [
{
"code": "940161",
"description": "Seats (other than those of heading 9402), whether or not convertible into beds, and parts thereof > Other seats, with wooden frames > Upholstered",
"parent": "9401"
},
{
"code": "940171",
"description": "Seats (other than those of heading 9402), whether or not convertible into beds, and parts thereof > Other seats, with metal frames > Upholstered",
"parent": "9401"
}
],
"query": { "q": "sofa", "limit": 2 },
"notice": null,
"usage": { "cost": 0, "balance": 1, "replayed": false }
}940161 是木框架的软垫座椅,也就是常见的布艺沙发。后面的调用都用它。
3. 先看这次查询要花多少钱
任何收费调用加上 dry_run: true,都不会真正执行,也不会扣费,返回的是这次调用最多会花多少钱。
curl https://api.won.dev/v1/trade/companies/search \
-H "Authorization: Bearer $WON_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "role": "importer", "hs_code": "940161", "importer_country": "US", "limit": 10, "dry_run": true }'返回结果,只保留 data:
{
"data": {
"dry_run": true,
"max_cost": 0.1,
"breakdown": [
{ "unit": "trade_company", "max_records": 10, "unit_price": 0.01, "max_cost": 0.1 }
]
}
}用正式 key 查 10 家买家,最多花 $0.10。想把一次调用锁在某个价格以内,就带上 max_cost:可能超出的调用会在执行前被拒绝。见定价与计费。
4. 给买家排名
去掉 dry_run,再发一次同样的请求。这里只要两家:
curl https://api.won.dev/v1/trade/companies/search \
-H "Authorization: Bearer $WON_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "role": "importer", "hs_code": "940161", "importer_country": "US", "limit": 2 }'{
"data": [
{
"id": "co_8f3k2m9x4p1q",
"name": "SAMPLE NORTHFIELD HOME FURNISHINGS INC",
"role": "importer",
"country": "US",
"shipments": 1840,
"recorded_value_usd": 21480350.4,
"website": "northfield-home.example",
"sample_product": "UPHOLSTERED SOFA WITH WOODEN FRAME, FABRIC COVER"
},
{
"id": "co_3d9t6w1b7n5z",
"name": "SAMPLE HARBORSIDE SEATING CO",
"role": "importer",
"country": "US",
"shipments": 962,
"recorded_value_usd": 9310772.15,
"website": "harborside-seating.example",
"sample_product": "RECLINER SOFA SET, LEATHER, 3 SEATER"
}
],
"total": 4,
"has_more": true,
"next_cursor": "cur_Zx81kQp4b2JtMW0uMXJ6ZzQ",
"query": {
"role": "importer",
"hs_code": "940161",
"importer_country": "US",
"exclude_forwarders": true,
"sort": "shipments",
"since": "2025-11-01",
"until": "2026-11-20",
"data_through": "2026-11-11"
},
"notice": "Sample data: this is a test key. It returns the same made-up examples whatever you ask, and nothing is charged. Use a live key for real records.",
"usage": {
"unit": "trade_company",
"records": 2,
"already_paid": 0,
"cost": 0,
"balance": 1,
"replayed": false
}
}每个返回结果都按这个顺序给出这些字段。query 是服务端理解到的请求,默认日期也已填好。notice 提醒你这份结果需要留意的地方,这里说明它是样例数据。usage 是这次调用的花费:records: 2 用正式 key 是 $0.02,测试 key 的 cost 为 0。见返回结构。
5. 找到该联系的人
传入公司的 id,就能找到这家公司里该联系的人,每人都带一个返回前验证过的工作邮箱。
curl "https://api.won.dev/v1/trade/companies/co_8f3k2m9x4p1q/contacts?department=purchasing&limit=1" \
-H "Authorization: Bearer $WON_API_KEY"返回结果,只保留 data:
{
"data": [
{
"id": "per_4m7q2x9k1c8d",
"name": "Jordan Lee",
"title": "Director of Global Sourcing",
"seniority": "executive",
"department": "purchasing",
"email_status": "verified",
"linkedin_url": "https://www.linkedin.com/in/sample-jordan-lee",
"email": "jordan.lee@northfield-home.example"
}
]
}用正式 key 时,每个联系人 $0.03。记下 per_ 开头的 ID:发送活动可以用它作为 contact_id,不用再填邮箱地址。
6. 切换到正式环境
在同一页面创建一个 正式 模式的 key,并给它设一个预算,也就是这个 key 最多能花多少钱。把它换成测试 key,再跑一遍第 3 到第 5 步。其他什么都不用改:调用会返回真实的公司和联系人,并从余额中扣费。空结果和失败的调用都不收费。
export WON_API_KEY=won_live_...免费额度用完后,到控制台的 账单 页面充值。预算和 key 的权限见鉴权。
下一步
最后更新于