Developer Guide

API keys, authentication, your first call, widget embedding, and common errors — in one place.

Step 1

Find Your API Key

Your API key is generated automatically when you create a Triangle account. It does not expire unless you rotate it manually.

1

Open your developer portal

triangle-trade-intel.site/developer — log in with your account email. This is your API key management dashboard.

2

Find your key

Your key is listed under API Credentials. You will see up to three key types — test, live, and widget-only.

3

Copy the full key

Keys are truncated in the UI display. Always use the copy button rather than selecting text manually.

Your key is a secret. Never include it in client-side JavaScript, public repositories, or URLs. Anyone with your key can make API calls against your credit balance. Use widget keys (tri_widget_*) for browser-side embed code — they are domain-restricted.

Base URL

All API requests go to the same base URL:

Base URL
https://triangle-trade-intel.site/api/v1
Step 2

Your First API Call

The fastest way to confirm your key is working is a single /classify call.

cURL
curl -X POST https://triangle-trade-intel.site/api/v1/classify \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"description": "industrial conveyor belt, rubber, reinforced steel core"}'

A successful response returns:

Response (200 OK)
{
  "success": true,
  "hs_code": "4010.39.0030",
  "confidence": 0.94,
  "gri_reasoning": {
    "rules_applied": ["GRI 1", "GRI 6"],
    "binding_criterion": "Classified per heading text and chapter notes...",
    "federal_register_citation": "88 FR 17244"
  }
}

The gri_reasoning field is the audit trail. It documents how the classification was reached using the General Rules of Interpretation, with a Federal Register citation. This is what makes a classification CBP-defensible.

Step 3

Authentication

Every request requires a Bearer token in the Authorization header.

Header
Authorization: Bearer YOUR_API_KEY

Store as an environment variable

Terminal (Mac / Linux)
export TRIANGLE_API_KEY="your_key_here"
Node.js
const response = await fetch(
  'https://triangle-trade-intel.site/api/v1/classify',
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.TRIANGLE_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ description: 'your product description' }),
  }
);
Python
import os, requests

response = requests.post(
    "https://triangle-trade-intel.site/api/v1/classify",
    headers={
        "Authorization": f"Bearer {os.environ['TRIANGLE_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={"description": "your product description"},
)

Core Endpoints

The Triangle API has 47 endpoints. These four are the ones most integrations use first. Full reference →

POST/classify

Classifies a product description into an 8-digit HTS code. Returns the full duty stack and GRI reasoning trail. Only this endpoint accepts product descriptions — all others require hs_code.

Key param: description (string, required)

POST/duty-calculate

Returns the complete duty stack for a given HTS code. Includes MFN, Section 301, Section 232, Section 122 (10%, Feb 24 2026), and AD/CVD orders with Federal Register citations.

Key param: hs_code (string, required)

GET/tariff-rates

Returns market-specific duty rates. Supported destinations: us, mx, ca (USMCA corridor).

Key param: hs_code (string, required)

POST/usmca-qualify

USMCA origin qualification analysis. Pass the component breakdown — the API calculates Regional Value Content, checks the rule of origin, and returns the preference criterion.

Key param: hs_code + components (array)

Common mistake: The market parameter belongs on /tariff-rates, not /classify. Passing it to /classify returns an error.

Embeddable Widgets

7 pre-built widgets. Available on Starter and above. Use a tri_widget_live_* key (domain-restricted) or your standard API key.

Tariff Rate Lookup

MFN + Section 301/232/122 stacking

Intelligent HS Classifier

Full AI classification with guided interview

USMCA Qualification

RVC analysis and preference criterion

Mexico ROI Calculator

Nearshoring savings with duty breakdown

CBP Entry Review

Pre-filing risk scoring and red flags

IEEPA Refund Estimator

Historical refund calculator (post-Feb 20, 2026)

Audit Export

CBP-ready documentation export

Embedding a widget

One script tag per widget. Swap the src filename for the widget you want.

HTML
<script
  src="https://triangle-trade-intel.site/widgets/tariff-calculator.js"
  data-key="YOUR_WIDGET_KEY"
  defer
></script>

Widget key visibility: The data-key attribute is visible in page source. Use a tri_widget_live_* key and set domain restrictions in your developer portal before deploying to production.

Plans and Credit Limits

All plans include all 47 endpoints and all three corridor markets (US, MX, CA). No endpoint gating. What changes is credits per month, rate limit, and overage pricing.

PlanCredits/moRate limitOveragePrice
Free10010 req/minBlocked at limit$0
Starter50030 req/min$0.05/credit$49/mo
Pro3,00060 req/min$0.03/credit$199/mo
Business12,000150 req/min$0.02/credit$599/mo
Enterprise50,000+300 req/minCustomCustom

When your free credit balance hits zero the API returns a credits_exhausted error. Your key stays active. Upgrade at api-pricing →

Common Issues