Documentation v1.0.1

API

The API feature in TariffBase allows developers to retrieve tariff rate data through programmatic access. This tool is designed for easy integration with external systems, providing accurate and up-to-date tariff information.


1. Getting Started

To access the API:

  1. Navigate to the API section in your dashboard.
  2. Copy your unique API Token for authentication.
  3. Store your token securely—do not expose it in client-side code or public repositories.

Note: API access is available exclusively with the Professional Plan.

API Token and Documentation Page


2. Authentication

All API requests require authentication using your API token. Include the token in the request header:

Authorization: Token your-api-token-here

3. Endpoints

Tariff Rate Lookup

Retrieve tariff rates for a specific product code between trading partners.

Endpoint:

GET https://www.tariffbase.io/api/v1/tariff-rate/

Request Parameters

Parameter Type Required Description
code string Yes The HS code or national tariff code (e.g., 8703, 02013006)
country string Yes The importing country code (CN, EU, US)
partner string Yes The exporting/origin country code (e.g., CN, US, DE)

Example Request

Using cURL:

curl -X GET "https://www.tariffbase.io/api/v1/tariff-rate/?code=8703&partner=CN&country=US" \
  -H "Authorization: Token your-api-token-here"

Using Python:

import requests

url = "https://www.tariffbase.io/api/v1/tariff-rate/"
headers = {"Authorization": "Token your-api-token-here"}
params = {
    "code": "8703",
    "partner": "CN",
    "country": "US"
}

response = requests.get(url, headers=headers, params=params)
data = response.json()
print(data)

Example Response

{
  "code": "8703",
  "description": "Motor cars and other motor vehicles",
  "country": "US",
  "partner": "CN",
  "rates": [
    {
      "regime": "MFN",
      "rate": "2.5%",
      "notes": "Most Favored Nation rate"
    },
    {
      "regime": "Additional-CHN-2024",
      "rate": "+100%",
      "notes": "Section 301 additional tariff"
    }
  ],
  "last_updated": "2025-01-15"
}

4. Rate Limits

To ensure system stability and fair usage, the API enforces the following rate limits:

Plan Rate Limit
Professional 10 requests per minute

If you exceed the rate limit, the API will return a 429 Too Many Requests response. Wait before making additional requests.


5. Error Codes

Status Code Description
200 Success - Request completed successfully
400 Bad Request - Missing or invalid parameters
401 Unauthorized - Invalid or missing API token
403 Forbidden - API access not enabled for your plan
404 Not Found - No tariff data found for the specified parameters
429 Too Many Requests - Rate limit exceeded
500 Internal Server Error - Contact support if this persists

Example Error Response

{
  "error": "Invalid country code",
  "message": "The country parameter must be one of: CN, EU, US",
  "status": 400
}

6. Best Practices

  • Cache responses when possible to minimize API calls for frequently accessed data.
  • Handle errors gracefully in your application by checking response status codes.
  • Use specific HS codes for more precise results; broader codes may return multiple entries.
  • Monitor your usage to stay within rate limits, especially during bulk operations.

7. Support

If you encounter issues or have questions about the API:

  • Check the API Documentation in your dashboard for the latest updates.
  • Contact our support team at support@tariffbase.io.

By following these guidelines, you can efficiently integrate TariffBase's API into your workflow for automated tariff data retrieval.