API reference
HS Code Classifier API
Product description, page or photo to its HS code, with confidence, US HTS duty and EU CN line.
- Host
hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com- Base path
/v1/hs-codes- Auth
X-RapidAPI-Key,X-RapidAPI-Host- For agents
openapi.json·hs-codes.md
Overview and pricing · Tutorial: HS Code Lookup API · RapidAPI playground (opens in a new tab) ↗ · Apify actor (opens in a new tab) ↗
Classification
Product to HS code with AI, checked against the nomenclature.
Classify Product
POST /v1/hs-codes/classify
Product description, page or photo to its HS code. Classify a product into its 6-digit HS 2022 code from a description, page `url` or photo `image_url`: up to 3 real codes with confidence, reasoning and official texts; with `country`, the US HTS line (duty rate) or EU CN line. An aid, to confirm with a broker. 10 credits.
| Parameter | In | Type | Description |
|---|---|---|---|
description |
body | string |
What the product is, in any language: a title, a catalogue line or a full description. Required unless `url` or `image_url` is given. |
material |
body | string |
Material or composition, e.g. '60% cotton, 40% polyester'. |
use |
body | string |
Function or intended use, e.g. 'for passenger cars'. |
url |
body | string |
A product page to read (title, description, specifications). |
image_url |
body | string |
A photo of the product: PNG, JPEG, WEBP, HEIC, GIF, BMP or TIFF, up to 10 MB. |
country |
body | "US" | "EU" |
Also pick the national tariff line: `US` (HTS, 10 digits, with the general duty rate) or `EU` (Combined Nomenclature, 8 digits). |
max_results |
body | integer |
HsCandidate codes to return, best first (1-3). Default 3. |
curl -X POST "https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/classify" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com" \
-H "Content-Type: application/json" \
-d '{
"description": "Men'\''s short-sleeve crew-neck T-shirt, 100% cotton jersey",
"country": "US"
}'
import requests
url = "https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/classify"
payload = {
"description": "Men's short-sleeve crew-neck T-shirt, 100% cotton jersey",
"country": "US"
}
headers = {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com",
}
r = requests.post(url, json=payload, headers=headers)
print(r.json())
const res = await fetch("https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/classify", {
method: "POST",
headers: {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com",
"Content-Type": "application/json",
},
body: JSON.stringify({
"description": "Men's short-sleeve crew-neck T-shirt, 100% cotton jersey",
"country": "US"
}),
});
console.log(await res.json());
Classify Product from Image
POST /v1/hs-codes/classify/upload
Uploaded product photo (plus optional text) to its HS code. Same as /classify, for a photo sent as multipart/form-data (field `file`), with the same optional text fields. 10 credits.
| Parameter | In | Type | Description |
|---|---|---|---|
file required |
form | file |
Product photo, up to 10 MB. |
description |
form | string |
What the product is (optional). |
material |
form | string |
Material or composition, e.g. '60% cotton, 40% polyester'. |
use |
form | string |
Function or intended use, e.g. 'for passenger cars'. |
country |
form | "US" | "EU" |
Also pick the national tariff line: `US` (HTS, 10 digits, with the general duty rate) or `EU` (Combined Nomenclature, 8 digits). |
max_results |
form | integer |
Candidate codes to return, best first (1-3). Default 3. |
curl -X POST "https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/classify/upload" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com" \
-F "file=@./my-file"
import requests
url = "https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/classify/upload"
headers = {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com",
}
with open("my-file", "rb") as f:
r = requests.post(url, headers=headers, files={"file": f})
print(r.json())
import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("file", new Blob([await readFile("my-file")]), "my-file");
const res = await fetch("https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/classify/upload", {
method: "POST",
headers: {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com",
},
body: form,
});
console.log(await res.json());
Lookup
HS codes, their hierarchy and national lines, and keyword search. No AI.
Get HS Code
GET /v1/hs-codes/code
An HS code with its hierarchy, children and national lines. Check that an HS 2022 code exists and get its official texts up the hierarchy, the codes under it and, with `country`, the US HTS or EU CN lines. 404 `code_not_found` when it does not exist (not billed). 1 credit.
| Parameter | In | Type | Description |
|---|---|---|---|
code required |
query | string |
2, 4, 6, 8 or 10 digits; dots and spaces are ignored. |
country |
query | "US" | "EU" |
Also list the national lines under the code: `US` (HTS with general duty rates) or `EU` (CN). Required for 8 and 10-digit codes. |
curl -G "https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/code" \
--data-urlencode "code=6109.10" \
--data-urlencode "country=US" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com"
import requests
url = "https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/code"
params = {
"code": "6109.10",
"country": "US"
}
headers = {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com",
}
r = requests.get(url, params=params, headers=headers)
print(r.json())
const res = await fetch("https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/code?code=6109.10&country=US", {
headers: {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com",
},
});
console.log(await res.json());
Search HS Codes
GET /v1/hs-codes/search
Keywords to matching HS subheadings, no AI. 6-digit subheadings whose official texts match the keywords, ranked by relevance, with their chapter and heading. Instant and deterministic; use /classify when the wording of the product differs from the tariff's. 1 credit.
| Parameter | In | Type | Description |
|---|---|---|---|
q required |
query | string |
Words describing the goods, in English. |
limit |
query | integer |
Results, 1-25. Default 10. |
curl -G "https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/search" \
--data-urlencode "q=cotton t-shirt" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com"
import requests
url = "https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/search"
params = {
"q": "cotton t-shirt"
}
headers = {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com",
}
r = requests.get(url, params=params, headers=headers)
print(r.json())
const res = await fetch("https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/search?q=cotton+t-shirt", {
headers: {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com",
},
});
console.log(await res.json());
Response
{
"product": "A men's short-sleeve crew-neck T-shirt made of 100% cotton jersey knit fabric.",
"hs_code": "610910",
"results": [
{
"hs_code": "610910",
"formatted": "6109.10",
"section": { "code": "XI", "description": "Textiles and textile articles" },
"chapter": { "code": "61", "description": "Apparel and clothing accessories; knitted or crocheted" },
"heading": { "code": "6109", "description": "T-shirts, singlets and other vests; knitted or crocheted" },
"subheading": { "code": "610910", "description": "T-shirts, singlets and other vests; of cotton, knitted or crocheted" },
"confidence": 1.0,
"reasoning": "The product is a knitted T-shirt made of cotton, which is specifically provided for in heading 6109 under GIR 1 and 6.",
"national": {
"country": "US",
"code": "6109100012",
"formatted": "6109.10.00.12",
"description": "Of cotton › Men's or boys' › Other T-shirts › Men's (338)",
"general_duty": "16.5%",
"units": ["doz.", "kg"]
}
}
],
"to_confirm": [],
"inputs": ["description"],
"edition": "HS 2022",
"disclaimer": "Classification aid, not a binding ruling: have the code confirmed by a licensed customs broker before you declare goods."
}
From a real response. When the description leaves room for doubt, you get up to 3 candidates and the facts to check, for example a power bank: 8507.60 (lithium-ion accumulators, 0.95) then 8504.40 (static converters).
Why developers pick this API
- 💸 Priced for whole catalogues: about $0.008 per classification on PRO, where HS code APIs charge $0.03 to $0.10 and Zonos Classify $0.011 to $0.05. Lookups and searches cost a tenth of that, and failed calls use 0 credits.
- ✅ No invented codes: a language model alone happily returns codes that do not exist. Here every code is validated against the nomenclature and comes with its official texts.
- 🎯 Measured, not promised: 106 of 108 test products classified exactly at 6 digits on the first answer (98%), all 108 within the top 3 (textiles, electronics, food, chemicals, auto parts, toys, marketplace titles, rule-driven cases).
- 🇺🇸🇪🇺 National codes included: HTS line with duty rate or CN line in the same call, where others stop at 6 digits.
- 🧾 Explainable: the reasoning and the facts to confirm make the answer easy to review by your broker.
From a product page or a photo
{ "url": "https://www.allbirds.com/products/womens-runner-nz-slip-on-light-grey", "country": "EU" }
{ "image_url": "https://example.com/photos/kettle.jpg", "material": "stainless steel" }
The page is read like a browser would (title, product data, description); a photo is looked at by a vision model. To send a file, use /classify/upload with multipart field file and the same optional fields.
Lookup and search
curl "https://hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com/v1/hs-codes/code?code=8517.13&country=US" \
-H "X-RapidAPI-Key: YOUR_API_KEY" -H "X-RapidAPI-Host: hs-code-classifier-ai-customs-tariff-lookup.p.rapidapi.com"
{
"hs_code": "851713",
"formatted": "8517.13",
"section": { "code": "XVI", "description": "Machinery and mechanical appliances; electrical equipment; ..." },
"chapter": { "code": "85", "description": "Electrical machinery and equipment and parts thereof; ..." },
"heading": { "code": "8517", "description": "Telephone sets, including smartphones and other telephones for cellular/wireless networks; ..." },
"subheading": { "code": "851713", "description": "Telephone sets; smartphones for cellular or other wireless networks" },
"level": "subheading",
"children": [],
"national": [
{
"country": "US",
"code": "8517130000",
"formatted": "8517.13.00.00",
"description": "Telephone sets, including smartphones and other telephones for cellular networks or for other wireless networks › Smartphones",
"general_duty": "Free",
"units": ["No."]
}
],
"edition": "HS 2022"
}
From a real response, section texts shortened. Give 2, 4, 6, 8 or 10 digits (dots ignored): a chapter lists its headings, a heading its subheadings. /search?q=lithium ion battery returns 8507.60, 8506.50, 8507.80 ranked by relevance, instantly and without AI.
Errors
| Status | code |
Meaning |
|---|---|---|
| 400 | missing_input |
No description, url or image_url. |
| 400 | not_classifiable |
Not physical goods (a service, gibberish) or too vague ("parts"). Not billed. |
| 400 | page_empty |
The page has no readable text without JavaScript: send its description instead. |
| 400 | unsupported_file |
The image is not PNG, JPEG, WEBP, HEIC, GIF, BMP or TIFF, or is over 10 MB. |
| 400 | invalid_code / country_required |
A code has 2 to 10 digits; 8 and 10-digit codes need country. |
| 404 | code_not_found |
The code is not in the nomenclature. Not billed. |
| 429 | daily_limit_reached |
Daily safety limit of your plan; resets at 00:00 UTC. |
| 503 | ai_error / source_unavailable |
The AI or the USITC did not answer; retry. Not billed. |
Honest limits
- Material and make decide many codes. "Jeans" alone cannot tell cotton from synthetic: give
materialanduse, or readto_confirm. - Sets, parts and multi-function goods are where classification is hardest; expect a lower confidence and 2-3 candidates.
- No legal notes: the WCO Explanatory Notes and binding rulings are not included; the model applies the Interpretative Rules from its training.
- EU duty rates (TARIC) are not included, only the CN code.
Use it from an AI agent
Add this MCP server and the HS Code Classifier - Bulk Product to HS, HTS & CN Codes actor becomes a tool your agent can call. Works in Claude, Cursor, VS Code and any MCP client; billed per event through Apify.
https://mcp.apify.com?tools=helenisapi/hs-code-classifier
Prefer plain HTTP? Give your agent the OpenAPI document or the Markdown reference.