
Tariff Calculator Amazon
- 642 installs
- 480 repo stars
- Updated July 23, 2026
- nexscope-ai/amazon-skills
tariff-calculator-amazon is an agent skill that runs offline Python scripts to estimate import duties, Section 301 tariffs, VAT/GST, and landed costs for developers pricing cross-border Amazon FBA inventory.
About
tariff-calculator-amazon is a Nexscope AI agent skill (v1.0.0) that estimates import duties, Section 301 tariffs, VAT/GST, and full landed costs for cross-border Amazon FBA SKUs using offline Python scripts with no API keys. It bundles calculator.py and hs_lookup.py to map HS codes to duty rates across nine preset trade routes—China to US, China to EU, US to EU, and six more—plus custom origin/destination pairs with USMCA, EVFTA, and RCEP preferential rates. Run python3 scripts/calculator.py with JSON specifying hs_code, origin_country, destination_country, fob_value, quantity, and freight_cost to get per-unit landed cost breakdowns, including Section 301 additions from 7.5% to 25% on China-to-US goods. hs_lookup.py suggests HS codes from plain product descriptions like wireless earbuds. Reach for tariff-calculator-amazon when pricing international inventory, comparing sourcing countries, or validating Amazon margin math before listing or procurement commits.
- Landed cost
- Import duties
- Margin modeling
- Cross-border SKUs
- Price floors
Tariff Calculator Amazon by the numbers
- 642 all-time installs (skills.sh)
- +87 installs in the week ending Jul 26, 2026 (Skillselion tracking)
- Ranked #196 of 1,106 Finance & Trading skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/nexscope-ai/amazon-skills --skill tariff-calculator-amazonAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 642 |
|---|---|
| repo stars | ★ 480 |
| Last updated | July 23, 2026 |
| Repository | nexscope-ai/amazon-skills ↗ |
How do you calculate Amazon import duties and landed cost?
Estimate import duties, tariffs, and landed costs for Amazon FBA or cross-border SKUs before setting prices and sourcing decisions.
Who is it for?
Developers and operators modeling cross-border Amazon FBA margins who need offline HS-code duty math across China, US, EU, UK, Canada, and Australia routes.
Skip if: Skip tariff-calculator-amazon when customs brokers need legally binding filings, real-time government tariff API integration, or non-ecommerce trade compliance workflows.
When should I use this skill?
User asks to estimate import duties, Section 301 tariffs, VAT/GST, landed cost, or HS code lookup for Amazon cross-border SKUs.
What you get
Tariff and landed-cost report with FOB, freight, duty, VAT/GST, customs fees, total landed cost, and per-unit cost breakdown.
- landed cost report
- HS code suggestions
- per-unit cost breakdown
By the numbers
- Skill version 1.0.0 with calculator.py and hs_lookup.py scripts
- Documents 9 preset international trade routes
- Section 301 China-to-US additional rates range from 7.5% to 25%
Files
Tariff Calculator — Amazon 💰
Universal tariff and landed cost calculator for international Amazon sellers.
Installation
npx skills add nexscope-ai/eCommerce-Skills --skill tariff-calculator-amazon -gFeatures
- Universal Trade Routes — Any origin to any destination
- Tariff Rate Lookup — HS code → duty rate
- Section 301 Tariffs — US additional duties on China imports
- VAT/GST Calculation — EU, UK, CA, AU, CN rates
- Landed Cost — Complete cost breakdown
- HS Code Matcher — Product description → HS code suggestions
- Trade Agreements — USMCA, EVFTA, RCEP preferential rates
Supported Trade Routes
| Route | Key Tariffs | VAT/GST |
|---|---|---|
| 🇨🇳 → 🇺🇸 China → USA | Section 301 (7.5-25%) | N/A |
| 🇨🇳 → 🇪🇺 China → EU | Standard duties | 19-22% |
| 🇨🇳 → 🇬🇧 China → UK | Standard duties | 20% |
| 🇺🇸 → 🇪🇺 USA → EU | Standard duties | 19-22% |
| 🇪🇺 → 🇺🇸 EU → USA | Standard duties | N/A |
| 🇺🇸 → 🇨🇳 USA → China | Retaliatory tariffs | 13% VAT |
| 🇨🇳 → 🇨🇦 China → Canada | Standard duties | 5% GST |
| 🇨🇳 → 🇦🇺 China → Australia | Standard duties | 10% GST |
| Custom | User-defined | User-defined |
Section 301 Tariffs (China → USA)
| HS Chapter | Products | Additional Rate |
|---|---|---|
| 84xx | Computers, machinery | 25% |
| 85xx | Electronics (some) | 0-25% |
| 94xx | Furniture, lighting | 25% |
| 95xx | Toys | 25% |
| 61/62 | Apparel | 7.5% |
| 64xx | Footwear | 7.5% |
| 42xx | Bags, accessories | 7.5% |
Landed Cost Formula
Landed Cost =
FOB Value
+ International Freight
+ Insurance
+ Import Duty
+ VAT/GST (if applicable)
+ Customs Clearance
+ Port Fees
+ Inland FreightUsage
Basic Calculation
python3 scripts/calculator.pyWith Parameters
python3 scripts/calculator.py '{
"hs_code": "8518300000",
"origin_country": "CN",
"destination_country": "US",
"fob_value": 5000.00,
"quantity": 500,
"freight_cost": 200.00
}'HS Code Lookup
python3 scripts/hs_lookup.py "wireless earbuds"
python3 scripts/hs_lookup.py "bluetooth speaker"Custom Trade Route
python3 scripts/calculator.py '{
"hs_code": "9503009000",
"origin_country": "VN",
"destination_country": "DE",
"fob_value": 10000.00,
"quantity": 1000,
"freight_cost": 500.00,
"custom_duty_rate": 0.047,
"custom_vat_rate": 0.19
}'Output Example
💰 Tariff & Landed Cost Report
Product: Wireless Bluetooth Earbuds
HS Code: 8518300000
Route: China 🇨🇳 → USA 🇺🇸
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📦 Cost Breakdown
FOB Value $ 5,000.00
International Freight $ 200.00
Insurance $ 15.00
CIF Value $ 5,215.00
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🏛️ Duties & Taxes
Base Duty (0.0%) $ 0.00
Section 301 (0.0%) $ 0.00
Total Duty $ 0.00
Customs Clearance $ 150.00
Port Fees $ 50.00
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💵 Landed Cost Summary
Total Landed Cost $ 5,515.00
Per Unit Cost $ 11.03Trade Agreement Support
| Agreement | Countries | Benefit |
|---|---|---|
| USMCA | US, Mexico, Canada | Reduced/zero duties |
| EVFTA | EU, Vietnam | Reduced duties |
| RCEP | Asia-Pacific | Reduced duties |
| UK-Japan | UK, Japan | Reduced duties |
Custom Configuration
Create a custom config for your routes:
{
"default_origin": "CN",
"default_destination": "US",
"include_insurance": true,
"insurance_rate": 0.003,
"customs_fee": 150,
"port_fee": 50
}---
Part of [Nexscope AI](https://www.nexscope.ai/?co-from=skill) — AI tools for e-commerce sellers.
#!/usr/bin/env python3
"""
Tariff Calculator - Core Engine
TariffCalculate - Core Engine
Features:
- TariffTax RateQuery (HScode → Tax Rate)
- TariffCalculate (goodsValue × Tax Rate)
- VAT/GST Calculate
- to shoreCost (Landed Cost) CompleteCalculate
- Section 301 TariffQuery
- Trade agreement benefits
- many CurrencySupport
Version: 1.0.0
"""
import json
from dataclasses import dataclass, field
from typing import List, Dict, Optional, Tuple
from enum import Enum
from datetime import datetime
import sys
class Country(Enum):
"""Country/Region"""
CN = "CN" # in country
US = "US" # USA
EU = "EU" # EU
UK = "UK" # UK
CA = "CA" # Canada big
AU = "AU" # Australia
VN = "VN" # Vietnam
MX = "MX" # Mexico
IN = "IN" # printDegree
JP = "JP" # Daybasic
KR = "KR" # Korea
# ============================================================
# Tax RateData (2024)
# ============================================================
# BasicTariffTax Rate (MFN most MFN)
BASE_TARIFF_RATES = {
# HS Chapter before 2position → BasicTax Rate
"39": {"US": 0.065, "EU": 0.065, "UK": 0.065, "CA": 0.06, "AU": 0.05}, # Plastic
"42": {"US": 0.08, "EU": 0.04, "UK": 0.04, "CA": 0.08, "AU": 0.05}, # Leather products
"61": {"US": 0.12, "EU": 0.12, "UK": 0.12, "CA": 0.18, "AU": 0.10}, # Knitted apparel
"62": {"US": 0.12, "EU": 0.12, "UK": 0.12, "CA": 0.18, "AU": 0.10}, # Non-knitted apparel
"64": {"US": 0.10, "EU": 0.08, "UK": 0.08, "CA": 0.18, "AU": 0.05}, # shoeCategory
"84": {"US": 0.0, "EU": 0.02, "UK": 0.02, "CA": 0.0, "AU": 0.0}, # Mechanical equipment
"85": {"US": 0.0, "EU": 0.02, "UK": 0.02, "CA": 0.0, "AU": 0.0}, # Electronicelectric
"94": {"US": 0.0, "EU": 0.0, "UK": 0.0, "CA": 0.08, "AU": 0.05}, # Furniture
"95": {"US": 0.0, "EU": 0.045, "UK": 0.045, "CA": 0.0, "AU": 0.05}, # Toy
"default": {"US": 0.05, "EU": 0.05, "UK": 0.05, "CA": 0.05, "AU": 0.05},
}
# Section 301 Tariff ( in country → USA)
SECTION_301_RATES = {
# HS 4Digit code → AdditionalTax Rate
"8471": 0.25, # Computer
"8473": 0.25, # Computer accessories
"8504": 0.25, # Transformer/Power
"8517": 0.25, # Communication equipment
"8528": 0.25, # Display
"9403": 0.25, # Furniture
"9405": 0.25, # Lighting
"9503": 0.25, # Toy
"6110": 0.075, # Knit shirt
"6203": 0.075, # Men wear
"6204": 0.075, # Women wear
"6402": 0.075, # shoeCategory
"3926": 0.25, # Plastic products
"4202": 0.075, # boxPackage
}
# VAT/GST Tax Rate
VAT_RATES = {
"US": 0.0, # US has no federal VAT ( each state has Sales Tax)
"EU": 0.20, # EUAverage (Germany19%, France20%, meaning big profit22%)
"UK": 0.20, # UK VAT 20%
"CA": 0.05, # Canada big GST 5% (+ PST varies)
"AU": 0.10, # Australia GST 10%
}
# EU each country VAT
EU_VAT_RATES = {
"DE": 0.19, # Germany
"FR": 0.20, # France
"IT": 0.22, # meaning big profit
"ES": 0.21, # Spain
"NL": 0.21, # Netherlands
"PL": 0.23, # Poland
}
# Trade agreement benefits
TRADE_AGREEMENTS = {
("MX", "US"): {"name": "USMCA", "reduction": 1.0}, # 100% Exemption
("CA", "US"): {"name": "USMCA", "reduction": 1.0},
("VN", "EU"): {"name": "EVFTA", "reduction": 0.5}, # 50% Exemption
("AU", "US"): {"name": "AUSFTA", "reduction": 1.0},
("KR", "US"): {"name": "KORUS", "reduction": 1.0},
}
# CurrencyExchange rate ( for USD)
EXCHANGE_RATES = {
"USD": 1.0,
"EUR": 1.08,
"GBP": 1.26,
"CAD": 0.74,
"AUD": 0.65,
"CNY": 0.14,
"JPY": 0.0067,
}
# ============================================================
# Data Structures
# ============================================================
@dataclass
class ProductInfo:
"""ProductInformation"""
description: str = ""
hs_code: str = "" # 6-10position HScode
origin_country: str = "CN" # Country of origin
fob_value: float = 0.0 # FOB Price (USD)
quantity: int = 1
unit_weight_kg: float = 0.0
currency: str = "USD"
@dataclass
class ShippingInfo:
"""TransportInformation"""
destination_country: str = "US"
destination_eu_country: str = "" # EU specificCountry
shipping_method: str = "sea" # sea/air/express
freight_cost: float = 0.0 # Shipping (USD)
insurance_rate: float = 0.003 # InsuranceRate (0.3%)
@dataclass
class CostBreakdown:
"""Cost Breakdown"""
# Basic
fob_value: float = 0.0
freight: float = 0.0
insurance: float = 0.0
cif_value: float = 0.0
# Taxes and fees
base_tariff_rate: float = 0.0
base_tariff: float = 0.0
section_301_rate: float = 0.0
section_301_tariff: float = 0.0
total_tariff_rate: float = 0.0
total_tariff: float = 0.0
vat_rate: float = 0.0
vat: float = 0.0
# Miscellaneous fees
customs_clearance: float = 0.0
port_fees: float = 0.0
inland_freight: float = 0.0
other_fees: float = 0.0
# Summary
total_taxes_fees: float = 0.0
landed_cost: float = 0.0
landed_cost_per_unit: float = 0.0
# Trade agreement
trade_agreement: str = ""
tariff_reduction: float = 0.0
@dataclass
class TariffResult:
"""CalculateResult"""
product: ProductInfo
shipping: ShippingInfo
breakdown: CostBreakdown
hs_code_info: Dict
warnings: List[str]
summary: str
summary_zh: str
# ============================================================
# CoreCalculateFunction
# ============================================================
def get_hs_chapter(hs_code: str) -> str:
"""Get HS Chapter ( before 2position)"""
return hs_code[:2] if len(hs_code) >= 2 else "00"
def get_hs_heading(hs_code: str) -> str:
"""Get HS Tax ID ( before 4position)"""
return hs_code[:4] if len(hs_code) >= 4 else "0000"
def get_base_tariff_rate(hs_code: str, destination: str) -> float:
"""GetBasicTariffTax Rate"""
chapter = get_hs_chapter(hs_code)
rates = BASE_TARIFF_RATES.get(chapter, BASE_TARIFF_RATES["default"])
return rates.get(destination, 0.05)
def get_section_301_rate(hs_code: str, origin: str, destination: str) -> float:
"""Get Section 301 AdditionalTariff"""
if origin != "CN" or destination != "US":
return 0.0
heading = get_hs_heading(hs_code)
return SECTION_301_RATES.get(heading, 0.0)
def get_trade_agreement(origin: str, destination: str) -> Optional[Dict]:
"""Get trade agreement benefits"""
return TRADE_AGREEMENTS.get((origin, destination))
def get_vat_rate(destination: str, eu_country: str = "") -> float:
"""GetVAT/GST Tax Rate"""
if destination == "EU" and eu_country:
return EU_VAT_RATES.get(eu_country, VAT_RATES["EU"])
return VAT_RATES.get(destination, 0.0)
def estimate_freight(weight_kg: float, method: str, destination: str) -> float:
"""EstimateShipping"""
# Simple estimate
rates = {
"sea": {"US": 0.8, "EU": 1.0, "UK": 1.1, "CA": 0.7, "AU": 1.2}, # $/kg
"air": {"US": 5.0, "EU": 5.5, "UK": 5.5, "CA": 4.5, "AU": 6.0}, # $/kg
"express": {"US": 8.0, "EU": 9.0, "UK": 9.0, "CA": 7.5, "AU": 10.0}, # $/kg
}
rate = rates.get(method, rates["sea"]).get(destination, 1.0)
return weight_kg * rate
def calculate_landed_cost(
product: ProductInfo,
shipping: ShippingInfo,
customs_clearance: float = 150.0,
port_fees: float = 50.0,
inland_freight: float = 100.0,
other_fees: float = 0.0
) -> TariffResult:
"""Calculate to shoreCost"""
warnings = []
hs_info = {
"code": product.hs_code,
"chapter": get_hs_chapter(product.hs_code),
"heading": get_hs_heading(product.hs_code),
}
# 1. FOB
fob = product.fob_value
# 2. Shipping
freight = shipping.freight_cost
if freight == 0 and product.unit_weight_kg > 0:
total_weight = product.unit_weight_kg * product.quantity
freight = estimate_freight(total_weight, shipping.shipping_method, shipping.destination_country)
warnings.append(f"Freight estimated: ${freight:.2f} based on {total_weight}kg")
# 3. Insurance
insurance = fob * shipping.insurance_rate
# 4. CIF
cif = fob + freight + insurance
# 5. BasicTariff
base_rate = get_base_tariff_rate(product.hs_code, shipping.destination_country)
# 6. Section 301 ( in country→USA)
s301_rate = get_section_301_rate(product.hs_code, product.origin_country, shipping.destination_country)
if s301_rate > 0:
warnings.append(f"⚠️ Section 301 tariff applies: {s301_rate*100:.1f}%")
# 7. Trade agreement benefits
agreement = get_trade_agreement(product.origin_country, shipping.destination_country)
tariff_reduction = 0.0
agreement_name = ""
if agreement:
agreement_name = agreement["name"]
tariff_reduction = base_rate * agreement["reduction"]
base_rate = base_rate * (1 - agreement["reduction"])
warnings.append(f"✅ Trade agreement {agreement_name} applies: {agreement['reduction']*100:.0f}% tariff reduction")
# 8. totalTariff
total_tariff_rate = base_rate + s301_rate
total_tariff = cif * total_tariff_rate
# 9. VAT/GST
vat_rate = get_vat_rate(shipping.destination_country, shipping.destination_eu_country)
vat_base = cif + total_tariff # VAT UsuallyBased on CIF + Tariff
vat = vat_base * vat_rate
# 10. totalTaxes and fees
total_taxes = total_tariff + vat + customs_clearance + port_fees
# 11. to shoreCost
landed_cost = cif + total_taxes + inland_freight + other_fees
landed_cost_per_unit = landed_cost / product.quantity if product.quantity > 0 else landed_cost
breakdown = CostBreakdown(
fob_value=round(fob, 2),
freight=round(freight, 2),
insurance=round(insurance, 2),
cif_value=round(cif, 2),
base_tariff_rate=round(base_rate, 4),
base_tariff=round(cif * base_rate, 2),
section_301_rate=round(s301_rate, 4),
section_301_tariff=round(cif * s301_rate, 2),
total_tariff_rate=round(total_tariff_rate, 4),
total_tariff=round(total_tariff, 2),
vat_rate=round(vat_rate, 4),
vat=round(vat, 2),
customs_clearance=round(customs_clearance, 2),
port_fees=round(port_fees, 2),
inland_freight=round(inland_freight, 2),
other_fees=round(other_fees, 2),
total_taxes_fees=round(total_taxes, 2),
landed_cost=round(landed_cost, 2),
landed_cost_per_unit=round(landed_cost_per_unit, 2),
trade_agreement=agreement_name,
tariff_reduction=round(tariff_reduction, 4),
)
# Summary
summary = f"Landed Cost: ${landed_cost:.2f} | Tariff: {total_tariff_rate*100:.1f}% (${total_tariff:.2f}) | VAT: {vat_rate*100:.0f}%"
summary_zh = f" to shoreCost: ${landed_cost:.2f} | Tariff: {total_tariff_rate*100:.1f}% (${total_tariff:.2f}) | VAT: {vat_rate*100:.0f}%"
return TariffResult(
product=product,
shipping=shipping,
breakdown=breakdown,
hs_code_info=hs_info,
warnings=warnings,
summary=summary,
summary_zh=summary_zh,
)
# ============================================================
# OutputFormat
# ============================================================
def format_report(result: TariffResult, lang: str = "en") -> str:
"""FormatReport"""
p = result.product
s = result.shipping
b = result.breakdown
origin_names = {"CN": "China 🇨🇳", "VN": "Vietnam 🇻🇳", "MX": "Mexico 🇲🇽", "IN": "India 🇮🇳"}
dest_names = {"US": "USA 🇺🇸", "EU": "EU 🇪🇺", "UK": "UK 🇬🇧", "CA": "Canada 🇨🇦", "AU": "Australia 🇦🇺"}
origin_display = origin_names.get(p.origin_country, p.origin_country)
dest_display = dest_names.get(s.destination_country, s.destination_country)
if lang == "zh":
lines = [
"💰 **Tariff and to shoreCostCalculateReport**",
"",
f"**Product**: {p.description or 'N/A'}",
f"**HScode**: {p.hs_code}",
f"**Route**: {origin_display} → {dest_display}",
f"**Quantity**: {p.quantity} piece",
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## 📦 Cost Breakdown",
"",
"```",
f"FOB goodsValue ${b.fob_value:>10,.2f}",
f"InternationalShipping ${b.freight:>10,.2f}",
f"Insurance fee (0.3%) ${b.insurance:>10,.2f}",
f"────────────────────────────────────",
f"CIF to CIF price ${b.cif_value:>10,.2f}",
"```",
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## 🏛️ Taxes and feesBreakdown",
"",
"```",
f"BasicTariff ({b.base_tariff_rate*100:>5.1f}%) ${b.base_tariff:>10,.2f}",
]
if b.section_301_rate > 0:
lines.append(f"Section 301 ({b.section_301_rate*100:>4.1f}%) ${b.section_301_tariff:>10,.2f}")
lines.extend([
f"────────────────────────────────────",
f"totalTariff ({b.total_tariff_rate*100:>5.1f}%) ${b.total_tariff:>10,.2f}",
])
if b.vat_rate > 0:
lines.append(f"VAT/GST ({b.vat_rate*100:>4.0f}%) ${b.vat:>10,.2f}")
lines.extend([
f"Customs clearancefee ${b.customs_clearance:>10,.2f}",
f"Portfee ${b.port_fees:>10,.2f}",
f"────────────────────────────────────",
f"Taxes and feesTotal ${b.total_taxes_fees:>10,.2f}",
"```",
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## 🚚 OtherFee",
"",
"```",
f" inside landShipping ${b.inland_freight:>10,.2f}",
f"Other Fees ${b.other_fees:>10,.2f}",
"```",
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## 💵 to shoreCostSummary",
"",
"```",
f"CIF to CIF price ${b.cif_value:>10,.2f}",
f"Taxes and feesTotal ${b.total_taxes_fees:>10,.2f}",
f"OtherFee ${b.inland_freight + b.other_fees:>10,.2f}",
f"════════════════════════════════════",
f"total to shoreCost ${b.landed_cost:>10,.2f}",
f"Single pieceCost ${b.landed_cost_per_unit:>10,.2f}",
"```",
])
if result.warnings:
lines.extend([
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## ⚠️ NoticeItem",
"",
])
for w in result.warnings:
lines.append(f"• {w}")
lines.extend([
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
result.summary_zh,
])
else:
lines = [
"💰 **Tariff & Landed Cost Report**",
"",
f"**Product**: {p.description or 'N/A'}",
f"**HS Code**: {p.hs_code}",
f"**Route**: {origin_display} → {dest_display}",
f"**Quantity**: {p.quantity} units",
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## 📦 Cost Breakdown",
"",
"```",
f"FOB Value ${b.fob_value:>10,.2f}",
f"International Freight ${b.freight:>10,.2f}",
f"Insurance (0.3%) ${b.insurance:>10,.2f}",
f"────────────────────────────────────",
f"CIF Value ${b.cif_value:>10,.2f}",
"```",
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## 🏛️ Duties & Taxes",
"",
"```",
f"Base Tariff ({b.base_tariff_rate*100:>5.1f}%) ${b.base_tariff:>10,.2f}",
]
if b.section_301_rate > 0:
lines.append(f"Section 301 ({b.section_301_rate*100:>4.1f}%) ${b.section_301_tariff:>10,.2f}")
lines.extend([
f"────────────────────────────────────",
f"Total Tariff ({b.total_tariff_rate*100:>4.1f}%) ${b.total_tariff:>10,.2f}",
])
if b.vat_rate > 0:
lines.append(f"VAT/GST ({b.vat_rate*100:>4.0f}%) ${b.vat:>10,.2f}")
lines.extend([
f"Customs Clearance ${b.customs_clearance:>10,.2f}",
f"Port Fees ${b.port_fees:>10,.2f}",
f"────────────────────────────────────",
f"Total Taxes & Fees ${b.total_taxes_fees:>10,.2f}",
"```",
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## 🚚 Other Costs",
"",
"```",
f"Inland Freight ${b.inland_freight:>10,.2f}",
f"Other Fees ${b.other_fees:>10,.2f}",
"```",
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## 💵 Landed Cost Summary",
"",
"```",
f"CIF Value ${b.cif_value:>10,.2f}",
f"Total Taxes & Fees ${b.total_taxes_fees:>10,.2f}",
f"Other Costs ${b.inland_freight + b.other_fees:>10,.2f}",
f"════════════════════════════════════",
f"Total Landed Cost ${b.landed_cost:>10,.2f}",
f"Cost Per Unit ${b.landed_cost_per_unit:>10,.2f}",
"```",
])
if result.warnings:
lines.extend([
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
"## ⚠️ Notices",
"",
])
for w in result.warnings:
lines.append(f"• {w}")
lines.extend([
"",
"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",
"",
result.summary,
])
return "\n".join(lines)
# ============================================================
# CLI
# ============================================================
def main():
lang = "zh" if "--zh" in sys.argv else "en"
# DemoData
product = ProductInfo(
description="Wireless Bluetooth Earbuds",
hs_code="8518300000",
origin_country="CN",
fob_value=5000.00,
quantity=500,
unit_weight_kg=0.1,
)
shipping = ShippingInfo(
destination_country="US",
shipping_method="sea",
freight_cost=200.00,
insurance_rate=0.003,
)
# Calculate
result = calculate_landed_cost(product, shipping)
# Output
print(format_report(result, lang))
if __name__ == "__main__":
main()
#!/usr/bin/env python3
"""
HS Code Lookup & Matcher
HScodeQuery and smart can Match
Features:
- ProductDescription → HScodeRecommendation
- HScode → ProductCategoryother
- Section 301 ListQuery
- Common HScodeDataLibrary
Version: 1.0.0
"""
import re
from typing import List, Dict, Tuple
from dataclasses import dataclass
@dataclass
class HSCodeInfo:
"""HScodeInformation"""
code: str
description: str
description_zh: str
chapter: str
section_301: bool
section_301_rate: float
notes: str = ""
# ============================================================
# HScodeDataLibrary (Common e-commerceProduct)
# ============================================================
HS_DATABASE = {
# ElectronicProduct (Chapter 85)
"8517120000": HSCodeInfo(
code="8517120000",
description="Smartphones",
description_zh="Smartphone",
chapter="85",
section_301=True,
section_301_rate=0.0, # example outside
notes="Usually exempt from Section 301"
),
"8518300000": HSCodeInfo(
code="8518300000",
description="Headphones and earphones",
description_zh="Headphones",
chapter="85",
section_301=True,
section_301_rate=0.075,
),
"8471300000": HSCodeInfo(
code="8471300000",
description="Laptops and notebooks",
description_zh="Laptop computer",
chapter="84",
section_301=True,
section_301_rate=0.0, # example outside
notes="Currently exempt from Section 301"
),
"8504400000": HSCodeInfo(
code="8504400000",
description="Power adapters and chargers",
description_zh="Power adapter/Charging",
chapter="85",
section_301=True,
section_301_rate=0.25,
),
"8528590000": HSCodeInfo(
code="8528590000",
description="Monitors",
description_zh="Display",
chapter="85",
section_301=True,
section_301_rate=0.25,
),
# Home goods (Chapter 94)
"9403200000": HSCodeInfo(
code="9403200000",
description="Metal furniture",
description_zh="Metal furniture",
chapter="94",
section_301=True,
section_301_rate=0.25,
),
"9403600000": HSCodeInfo(
code="9403600000",
description="Wooden furniture",
description_zh="Wooden furniture",
chapter="94",
section_301=True,
section_301_rate=0.25,
),
"9405100000": HSCodeInfo(
code="9405100000",
description="Chandeliers and ceiling lights",
description_zh="Chandelier/Ceiling light",
chapter="94",
section_301=True,
section_301_rate=0.25,
),
"9405400000": HSCodeInfo(
code="9405400000",
description="LED lights and strips",
description_zh="LEDlight/Light strip",
chapter="94",
section_301=True,
section_301_rate=0.25,
),
# Apparel (Chapter 61/62)
"6109100000": HSCodeInfo(
code="6109100000",
description="Cotton T-shirts",
description_zh="CottonTshirt",
chapter="61",
section_301=True,
section_301_rate=0.075,
),
"6110200000": HSCodeInfo(
code="6110200000",
description="Cotton sweaters",
description_zh="Cotton sweater",
chapter="61",
section_301=True,
section_301_rate=0.075,
),
"6203420000": HSCodeInfo(
code="6203420000",
description="Men's cotton trousers",
description_zh="Men cotton pants",
chapter="62",
section_301=True,
section_301_rate=0.075,
),
"6204620000": HSCodeInfo(
code="6204620000",
description="Women's cotton trousers",
description_zh="Women cotton pants",
chapter="62",
section_301=True,
section_301_rate=0.075,
),
# shoeCategory (Chapter 64)
"6402990000": HSCodeInfo(
code="6402990000",
description="Rubber/plastic footwear",
description_zh="Rubber/Plastic shoes",
chapter="64",
section_301=True,
section_301_rate=0.075,
),
"6403990000": HSCodeInfo(
code="6403990000",
description="Leather footwear",
description_zh="Leather shoes",
chapter="64",
section_301=True,
section_301_rate=0.075,
),
"6404190000": HSCodeInfo(
code="6404190000",
description="Textile footwear",
description_zh="Textile shoes",
chapter="64",
section_301=True,
section_301_rate=0.075,
),
# boxPackage (Chapter 42)
"4202210000": HSCodeInfo(
code="4202210000",
description="Leather handbags",
description_zh="Leather handbag",
chapter="42",
section_301=True,
section_301_rate=0.075,
),
"4202920000": HSCodeInfo(
code="4202920000",
description="Backpacks and bags (textile)",
description_zh="backPackage/bag (Textile)",
chapter="42",
section_301=True,
section_301_rate=0.075,
),
# Toy (Chapter 95)
"9503000000": HSCodeInfo(
code="9503000000",
description="Toys and games",
description_zh="ToyAndGame",
chapter="95",
section_301=True,
section_301_rate=0.25,
),
# Plastic products (Chapter 39)
"3924100000": HSCodeInfo(
code="3924100000",
description="Plastic tableware and kitchenware",
description_zh="Plastic tableware/Kitchenware",
chapter="39",
section_301=True,
section_301_rate=0.25,
),
"3926909000": HSCodeInfo(
code="3926909000",
description="Other plastic articles",
description_zh="OtherPlastic products",
chapter="39",
section_301=True,
section_301_rate=0.25,
),
# Beauty care (Chapter 33)
"3304990000": HSCodeInfo(
code="3304990000",
description="Beauty and makeup products",
description_zh="BeautyProduct",
chapter="33",
section_301=False,
section_301_rate=0.0,
),
# Pet supplies
"6307900000": HSCodeInfo(
code="6307900000",
description="Pet beds and textile products",
description_zh="Pet bed/Textile products",
chapter="63",
section_301=True,
section_301_rate=0.075,
),
}
# Keywords → HScodeMapping
KEYWORD_MAPPING = {
# Electronic
"earphone": "8518300000",
"earbud": "8518300000",
"headphone": "8518300000",
"earbuds": "8518300000",
"Headphones": "8518300000",
"charger": "8504400000",
"adapter": "8504400000",
"Charging": "8504400000",
"monitor": "8528590000",
"Display": "8528590000",
"laptop": "8471300000",
"notebook": "8471300000",
"Computer": "8471300000",
"phone": "8517120000",
"smartphone": "8517120000",
"Phone": "8517120000",
# Home
"furniture": "9403600000",
"Furniture": "9403600000",
"desk": "9403200000",
"table": "9403200000",
"chair": "9401610000",
"light": "9405400000",
"lamp": "9405100000",
"light": "9405400000",
"led": "9405400000",
# Apparel
"t-shirt": "6109100000",
"tshirt": "6109100000",
"shirt": "6109100000",
"sweater": "6110200000",
"Sweater": "6110200000",
"pants": "6203420000",
"trousers": "6203420000",
"Pants": "6203420000",
# shoe
"shoe": "6402990000",
"footwear": "6402990000",
"sneaker": "6404190000",
"boot": "6403990000",
"shoe": "6402990000",
# boxPackage
"bag": "4202920000",
"backpack": "4202920000",
"handbag": "4202210000",
"Package": "4202920000",
# Toy
"toy": "9503000000",
"game": "9503000000",
"Toy": "9503000000",
# Plastic
"plastic": "3926909000",
"Plastic": "3926909000",
# Pet
"pet": "6307900000",
"Pet": "6307900000",
}
def search_hs_code(query: str) -> List[Tuple[str, HSCodeInfo, float]]:
"""Search HScode
Return: [(hs_code, info, confidence), ...]
"""
results = []
query_lower = query.lower()
# 1. Direct HScodeQuery
if query.isdigit() and len(query) >= 4:
for code, info in HS_DATABASE.items():
if code.startswith(query):
results.append((code, info, 1.0))
if results:
return sorted(results, key=lambda x: -x[2])
# 2. KeywordsMatch
for keyword, hs_code in KEYWORD_MAPPING.items():
if keyword in query_lower:
if hs_code in HS_DATABASE:
info = HS_DATABASE[hs_code]
confidence = 0.8 if len(keyword) > 3 else 0.6
results.append((hs_code, info, confidence))
# 3. DescriptionMatch
for code, info in HS_DATABASE.items():
desc_match = False
if query_lower in info.description.lower():
desc_match = True
confidence = 0.7
elif query_lower in info.description_zh:
desc_match = True
confidence = 0.7
if desc_match and (code, info, confidence) not in results:
results.append((code, info, confidence))
# remove heavy andSort
seen = set()
unique_results = []
for code, info, conf in sorted(results, key=lambda x: -x[2]):
if code not in seen:
seen.add(code)
unique_results.append((code, info, conf))
return unique_results[:5]
def get_hs_info(hs_code: str) -> HSCodeInfo:
"""Get HScodeDetails"""
# PreciseMatch
if hs_code in HS_DATABASE:
return HS_DATABASE[hs_code]
# before suffixMatch
for code, info in HS_DATABASE.items():
if code.startswith(hs_code) or hs_code.startswith(code[:4]):
return info
# Return default
chapter = hs_code[:2] if len(hs_code) >= 2 else "00"
return HSCodeInfo(
code=hs_code,
description=f"HS Chapter {chapter} product",
description_zh=f"HS number {chapter} chapterProduct",
chapter=chapter,
section_301=False,
section_301_rate=0.0,
notes="Custom HS code - verify with customs authority"
)
def format_search_results(results: List[Tuple[str, HSCodeInfo, float]], lang: str = "en") -> str:
"""FormatSearchResult"""
if not results:
if lang == "zh":
return "❌ Not foundMatch HScode,Please manuallyInputOr consult customs。"
return "❌ No matching HS codes found. Please enter manually or consult customs."
lines = []
if lang == "zh":
lines.append("🔍 **HScodeSearchResult**\n")
for i, (code, info, conf) in enumerate(results, 1):
conf_icon = "🟢" if conf >= 0.8 else "🟡" if conf >= 0.6 else "🔴"
s301 = f"⚠️ 301Tariff {info.section_301_rate*100:.1f}%" if info.section_301 and info.section_301_rate > 0 else ""
lines.append(f"**{i}. {code}** {conf_icon}")
lines.append(f" {info.description_zh}")
if s301:
lines.append(f" {s301}")
lines.append("")
else:
lines.append("🔍 **HS Code Search Results**\n")
for i, (code, info, conf) in enumerate(results, 1):
conf_icon = "🟢" if conf >= 0.8 else "🟡" if conf >= 0.6 else "🔴"
s301 = f"⚠️ Section 301: {info.section_301_rate*100:.1f}%" if info.section_301 and info.section_301_rate > 0 else ""
lines.append(f"**{i}. {code}** {conf_icon}")
lines.append(f" {info.description}")
if s301:
lines.append(f" {s301}")
lines.append("")
return "\n".join(lines)
# ============================================================
# CLI
# ============================================================
def main():
import sys
lang = "zh" if "--zh" in sys.argv else "en"
query = sys.argv[1] if len(sys.argv) > 1 and not sys.argv[1].startswith("--") else "earbuds"
results = search_hs_code(query)
print(format_search_results(results, lang))
if __name__ == "__main__":
main()
Related skills
How it compares
Pick tariff-calculator-amazon over generic spreadsheet models when Amazon-specific landed-cost formulas, Section 301 tables, and HS lookup must run offline inside an agent session.
FAQ
Does tariff-calculator-amazon need an API key?
tariff-calculator-amazon needs no API keys. Nexscope ships calculator.py and hs_lookup.py as offline Python scripts that compute duties, Section 301 surcharges, VAT/GST, and landed costs locally from JSON inputs.
Which trade routes does tariff-calculator-amazon support?
tariff-calculator-amazon documents nine preset routes including China to US, China to EU, China to UK, US to EU, EU to US, US to China, China to Canada, and China to Australia, plus custom origin/destination pairs with user-defined duty and VAT rates.
How do you run a landed cost calculation?
tariff-calculator-amazon runs via python3 scripts/calculator.py with JSON fields hs_code, origin_country, destination_country, fob_value, quantity, and freight_cost, returning FOB, duty, fees, total landed cost, and per-unit cost.