🔍 单个 HS Code 查询
输入商品品名,AI 自动匹配加拿大 HS Code
搜索加拿大海关税则,为进口到加拿大的任何产品查找 HS Code 和适用税率
Salmonidae, fresh or chilled, excluding fillets, meat, livers and roes
Pacific salmon species, fresh or chilled, whole or in pieces
Sockeye salmon (Oncorhynchus nerka), frozen, excluding fillets
Fresh or chilled fillets and other meat of salmonidae, fresh
Describe your product in natural language — our AI maps it to the correct HS code classification automatically.
View MFN rates, GST, PST, and any applicable preferential tariff treatments (CUSMA, CPTPP, etc.).
Integrate HS code lookup into your own systems with our developer-friendly API. Rate-limited free tier available.
通过 REST API 批量提交 HS Code 查询任务,支持 Webhook 回调通知
https://hscode.proxy.jiayouexp.com/api
登录后前往「个人中心 → API Keys」创建你的 API Key 和 Secret。
📌 每个用户最多创建 10 个 API Key,Secret 仅在创建时显示一次,请务必妥善保存。
curl -X POST https://hscode.proxy.jiayouexp.com/api/api/submit \
-H "X-Api-Key: sk_your_api_key" \
-H "X-Api-Secret: your_api_secret" \
-H "Content-Type: application/json" \
-d '{"products": ["Fresh Atlantic Salmon"]}'
任务提交后通过以下两种方式获取结果:
GET /api/api/tasks 查询任务状态API 支持两种鉴权方式(二选一):
在请求头中携带 API Key 和 Secret:
X-Api-Key: sk_your_api_key_here
X-Api-Secret: your_api_secret_here
📌 API Key 格式:sk_ 开头 + 32 位十六进制字符
🔒 Secret 用于签名验证,请妥善保管
使用用户登录后的 JWT Token:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
/api/api/submit
批量提交 HS Code 查询任务,最多 500 个品名/次。积分不足时超出部分将标记为 paused 状态。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| products | array | 是 | 商品品名数组,最多 500 个,每个品名 ≤ 512 字符 |
| webhook_url | string | 否 | 本次任务专用的回调 URL(可选,会额外触发) |
curl -X POST https://hscode.proxy.jiayouexp.com/api/api/submit \
-H "X-Api-Key: sk_your_key" \
-H "X-Api-Secret: your_secret" \
-H "Content-Type: application/json" \
-d '{
"products": [
"Fresh Atlantic Salmon",
"Cotton T-shirts",
"Wireless Bluetooth Mouse"
],
"webhook_url": "https://your-server.com/webhook"
}'
{
"code": 0,
"message": "任务已提交,共3条",
"data": {
"batch_no": "BAT20240422123456001",
"total": 3,
"processed": 3,
"paused": 0,
"balance": 47,
"task_ids": [101, 102, 103],
"paused_ids": []
}
}
| 字段 | 类型 | 说明 |
|---|---|---|
| batch_no | string | 批次号,用于后续查询 |
| total | int | 提交的总品名数 |
| processed | int | 已扣除积分并进入队列的任务数 |
| paused | int | 因积分不足暂停的任务数 |
| balance | int | 当前剩余积分 |
| task_ids | array | 已提交的任务 ID 列表 |
| paused_ids | array | 暂停的任务 ID 列表 |
/api/api/tasks
分页查询当前用户的任务列表和状态统计。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | int | 否 | 页码,默认 1 |
| limit | int | 否 | 每页数量,默认 20,最大 100 |
| batch_no | string | 否 | 按批次号筛选 |
| status | string | 否 | 按状态筛选 |
| 状态 | 说明 |
|---|---|
queued | 排队中,等待 Worker 处理 |
processing | 正在查询中 |
success | 查询成功,已返回 HS Code |
failed | 查询失败,已退还积分 |
paused | 因积分不足暂停,充值后可继续 |
# 查询所有任务
curl "https://hscode.proxy.jiayouexp.com/api/api/tasks?page=1&limit=20" \
-H "X-Api-Key: sk_your_key" \
-H "X-Api-Secret: your_secret"
# 按批次号查询
curl "https://hscode.proxy.jiayouexp.com/api/api/tasks?batch_no=BAT20240422123456001" \
-H "X-Api-Key: sk_your_key" \
-H "X-Api-Secret: your_secret"
# 查询成功任务
curl "https://hscode.proxy.jiayouexp.com/api/api/tasks?status=success" \
-H "X-Api-Key: sk_your_key" \
-H "X-Api-Secret: your_secret"
{
"code": 0,
"message": "ok",
"data": {
"tasks": {
"items": [
{
"id": 101,
"batch_no": "BAT20240422123456001",
"type": "api",
"product_name": "Fresh Atlantic Salmon",
"hscode": "0302110000",
"status": "success",
"error_msg": null,
"points_deducted": 1,
"created_at": "2024-04-22 12:34:56",
"finished_at": "2024-04-22 12:35:01"
}
],
"total": 150,
"page": 1,
"limit": 20,
"pages": 8
},
"stats": {
"total": 150,
"success": 145,
"failed": 2,
"running": 3,
"paused": 0
}
}
}
/api/api/batch-query
同步批量查询 HS Code,优先从历史记忆(Redis/MySQL 缓存)获取结果, 缓存未命中时才调用外部 API。每条查询均扣 1 积分(无论是否命中缓存)。 适合需要即时返回结果的场景。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| products | array | 是 | 商品品名数组,最多 500 个(自动去重),每个品名 ≤ 512 字符 |
curl -X POST https://hscode.proxy.jiayouexp.com/api/api/batch-query \
-H "X-Api-Key: sk_your_key" \
-H "X-Api-Secret: your_secret" \
-H "Content-Type: application/json" \
-d '{
"products": [
"Fresh Atlantic Salmon",
"Cotton T-shirts",
"Wireless Bluetooth Mouse"
]
}'
{
"code": 0,
"message": "查询完成,共3条(缓存命中2条),调用 API 1 次",
"data": {
"results": [
{
"product_name": "Fresh Atlantic Salmon",
"hscode": "0302110000",
"cache_hit": true
},
{
"product_name": "Cotton T-shirts",
"hscode": "6109100012",
"cache_hit": false
},
{
"product_name": "Wireless Bluetooth Mouse",
"hscode": "3924900010",
"cache_hit": true
}
],
"total": 3,
"success": 3,
"cache_hits": 2,
"api_calls": 1,
\"points_used\": 3,
\"balance\": 97
}
}
| 字段 | 类型 | 说明 |
|---|---|---|
| results | array | 查询结果列表,顺序与请求一致 |
| results[].product_name | string | 商品品名 |
| results[].hscode | string | 10 位 HS Code,查询失败时为空 |
| results[].cache_hit | bool | 是否命中历史记忆缓存 |
| results[].error | string | 错误信息(仅在查询失败时出现) |
| total | int | 查询的总品名数(去重后) |
| success | int | 成功查询的数量 |
| cache_hits | int | 命中缓存的数量(不扣积分) |
| api_calls | int | 调用外部 API 的次数(扣积分) |
| points_used | int | 本次消耗的积分(等于 api_calls) |
| balance | int | 查询后的剩余积分 |
💡 与 /api/api/submit 的区别:
Webhook 允许你在任务完成后自动接收通知。需要 JWT Token 认证(通过 Web 界面管理)。
/api/webhook/create
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| webhook_url | string | 是 | 回调 URL(需为合法 URL 格式) |
| secret | string | 否 | 签名密钥,不提供则自动生成(32 位) |
/api/webhook/list
/api/webhook/toggle
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| webhook_id | int | 是 | Webhook ID |
| status | int | 是 | 1=启用,0=禁用 |
/api/webhook/delete
/api/webhook/logs
当任务处理完成后(成功或失败),系统会自动向以下 URL 发送 HTTP POST 请求:
webhook_url(如有){
"event": "task.completed",
"task_id": 101,
"batch_no": "BAT20240422123456001",
"type": "api",
"product_name": "Fresh Atlantic Salmon",
"hscode": "0302110000",
"confidence": 0,
"status": "success",
"error_msg": null,
"created_at": "2024-04-22 12:34:56",
"finished_at": "2024-04-22 12:35:01"
}
| 字段 | 类型 | 说明 |
|---|---|---|
| event | string | 固定值 task.completed |
| task_id | int | 任务 ID |
| batch_no | string | 批次号 |
| type | string | 任务来源:api / single / batch |
| product_name | string | 商品品名 |
| hscode | string | 匹配到的 10 位 HS Code(失败时为空) |
| status | string | success 或 failed |
| error_msg | string/null | 失败时的错误信息 |
如果 Webhook 配置了 Secret,回调请求头会包含签名:
Content-Type: application/json
X-Webhook-Signature: sha256=abc123def456...
X-Webhook-Timestamp: 1713772496
验证方式:HMAC-SHA256(payload_body, secret)
import hmac, hashlib
signature = request.headers['X-Webhook-Signature'].replace('sha256=', '')
expected = hmac.new(secret.encode(), request.body, hashlib.sha256).hexdigest()
assert hmac.compare_digest(signature, expected), "Invalid signature"
🔄 回调失败时自动重试,最多重试 3 次:
您的 Webhook 服务应在 10 秒内返回 HTTP 2xx 状态码,否则视为回调失败。
| code | HTTP 状态码 | 说明 | 常见原因 |
|---|---|---|---|
| -1 | 401 | 鉴权失败 | API Key 无效 / Secret 错误 / Token 过期 / 未提供认证信息 |
| -1 | 401 | API Key 无效或已禁用 | Key 不存在 / 状态为 0(已禁用)/ Secret 不匹配 |
| -1 | 405 | 请求方法不允许 | 使用了错误的 HTTP 方法(如 GET 代替 POST) |
| -1 | 400 | 请求参数错误 | products 为空数组 / 无有效品名 / 超过 500 限制 |
| -1 | 500 | 服务器内部错误 | RabbitMQ 连接失败 / 数据库异常 |
{
"code": -1,
"message": "错误描述",
"data": []
}
Log in to continue using HS Code lookup services
Register to start using HS Code intelligent lookup
AI 驱动的商品品名匹配加拿大 HS Code 服务
输入品名查询 HS Code
上传 Excel 批量处理
查看所有任务和进度
1 元 = 50 积分
管理 API 密钥和 Secret
输入商品品名,AI 自动匹配加拿大 HS Code
为账户充值积分,用于 HS Code 查询
请输入密钥名称以创建新的 API Key 和 Secret
⚠️ Secret 仅在创建时显示一次,请务必妥善保存!