Free Sri Lanka vehicle import tax API
The same calculation as the website, for your own site, app or spreadsheet. It follows the Sri Lanka Customs gazettes, names the rate version it used, and costs nothing.
Quick start
No sign-up and no key. Send the tax class, the CIF value and what the class measures (engine capacity, motor power…). The machine-readable description is the OpenAPI 3.1 spec, which also works with Postman, code generators and Custom GPT actions.
curl -X POST https://autoimports.webgen.live/api/v1/calculate \
-H "Content-Type: application/json" \
-d '{ "mode": "class", "taxClassKey": "hybrid_petrol", "cif": { "amount": 1500000, "currency": "JPY" }, "measure": 1500, "vehicleAge": 1 }'Everything can also go in the address, for tools that can only open a link. format=md returns readable Markdown:
curl "https://autoimports.webgen.live/api/v1/quote?class=hybrid_petrol&cc=1500&age=1&cif=1500000¤cy=JPY&format=md"Not sure which taxClassKey to use? List them with GET /api/v1/tax-classes, or browse the import tax pages.
More languages
const res = await fetch("https://autoimports.webgen.live/api/v1/calculate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
mode: "class",
taxClassKey: "hybrid_petrol",
cif: { amount: 1_500_000, currency: "JPY" },
measure: 1500,
vehicleAge: 1,
}),
});
const quote = await res.json();
console.log(quote.totalTax, "LKR in taxes, rates v" + quote.rateVersion);// Runs in a visitor's browser: any website may call the API (CORS is open)
const res = await fetch("https://autoimports.webgen.live/api/v1/quote?class=petrol&cc=1000&age=1&cif=1200000¤cy=JPY");
const { totalTax, totalCost, rateVersion } = await res.json();import requests
quote = requests.post(
"https://autoimports.webgen.live/api/v1/calculate",
json={
"mode": "class",
"taxClassKey": "hybrid_petrol",
"cif": {"amount": 1_500_000, "currency": "JPY"},
"measure": 1500,
"vehicleAge": 1,
},
timeout=10,
).json()
print(quote["totalTax"], "LKR in taxes, rates v", quote["rateVersion"])<?php
$payload = json_encode([
"mode" => "class",
"taxClassKey" => "hybrid_petrol",
"cif" => ["amount" => 1500000, "currency" => "JPY"],
"measure" => 1500,
"vehicleAge" => 1,
]);
$ch = curl_init("https://autoimports.webgen.live/api/v1/calculate");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
]);
$quote = json_decode(curl_exec($ch), true);
echo $quote["totalTax"] . " LKR in taxes, rates v" . $quote["rateVersion"];/** =IMPORT_TAX("hybrid_petrol", 1500, 1, 1500000, "JPY") → total tax in LKR */
function IMPORT_TAX(taxClass, measure, age, cif, currency) {
const q = "class=" + encodeURIComponent(taxClass) + "&cc=" + measure + "&age=" + age +
"&cif=" + cif + "¤cy=" + encodeURIComponent(currency);
const res = UrlFetchApp.fetch("https://autoimports.webgen.live/api/v1/quote?" + q, { muteHttpExceptions: true });
const body = JSON.parse(res.getContentText());
if (res.getResponseCode() !== 200) throw new Error(body.error.message);
return body.totalTax;
}Building a chat assistant instead? See the MCP server and ChatGPT, Gemini and other chats. Want a ready-made calculator on your page? See embedding.
POST /api/v1/calculate
Send JSON with Content-Type: application/json (16 KB at most).
| Field | What it is |
|---|---|
mode | class (most vehicles; needs taxClassKey) or cab (the receipt-based method for cabs and pickups; no class). |
taxClassKey | From GET /api/v1/tax-classes, e.g. petrol, hybrid_petrol, electric. |
cif | amount and currency (ISO code such as JPY, USD, GBP, LKR). CIF is cost + insurance + freight to Colombo. Add fxRate (LKR per unit) and fxManual: true to use your own exchange rate; otherwise the live rate is used. |
measure | What the class measures: cc, kW, seats, payload or GVW. Each tax class says which, in its measure field. Classes that need none ignore it. |
vehicleAge | Years old. Only classes with needsAge: true use it. |
additional | Up to 3 extra charges (handling, clearing, other), each with amount and currency, added to the landed cost. |
vehicle | Optional make, model, year. Echoed back; they do not change the tax. |
locale | en (default), si or ta: the language of labels and the link back. |
include | ["breakdown"] adds the full engine breakdown; ["applicable"] adds every band of the class. |
The answer
Amounts are whole Sri Lankan rupees. Within v1 the answer only grows: fields are added, never removed or renamed.
{
"calcId": "0b7c…",
"rateVersion": 2,
"ratesPublishedAt": "2026-10-17T04:57:37.990741+00:00",
"currency": "LKR",
"vehicle": {
"category": { "key": "car", "label": "Cars / Station Wagons" },
"taxClass": { "key": "hybrid_petrol", "label": "Hybrid Petrol", "hsCode": "8703.4x.xx" },
"measure": { "value": 1500, "unit": "cc" },
"ageYears": 1
},
"cif": { "amount": 1500000, "currency": "JPY" },
"fx": { "rate": 2.0924, "source": "Frankfurter", "date": "2026-10-18", "manual": false },
"cifLkr": 3138600,
"taxes": [
{ "code": "cid", "label": "Customs import duty (CID)", "amount": 941580, "basis": "30%" },
{ "code": "excise", "label": "Excise duty", "amount": 5175000, "basis": "1,500 CC x LKR 3,450/CC" }
// … surcharge, luxury, pal, sscl, vat, vel, other
],
"totalTax": 8660535,
"totalCost": 11799135,
"effectiveRate": 275.9,
"calculatorUrl": "https://…/calculator?category=car&class=hybrid_petrol",
"sources": [ { "charge": "excise", "references": [ { "label": "G.N. 2418/43", … } ], … } ],
"disclaimer": "This is an estimate only. …"
}rateVersionandratesPublishedAtsay which published rates priced it. Show them to your users: rates change with each gazette.taxeslists every charge in the order Customs applies it, with the rule used.sourcesnames the gazettes and Acts behind each charge.calculatorUrlopens the website's calculator for the same class, where the user can get a PDF.
Other endpoints
| Endpoint | Returns |
|---|---|
GET /api/v1/quote | A calculation from query parameters (class, cc | kw | seats | payload | gvw, age, cif, currency, fx, locale, format=md). |
GET /api/v1/categories | Vehicle categories: cars, vans, trucks, buses, cabs… |
GET /api/v1/tax-classes | Tax classes, each with what to measure and whether age matters. Filter with ?category=car. |
GET /api/v1/rates | The live rate version, the currencies, the cab rates and the legal sources. |
GET /api/v1/rates/{taxClass} | One class with every excise and age band it uses. |
GET /api/v1/fx?currency=JPY | The LKR exchange rate and where it came from. |
GET /api/v1/openapi.json | This API as an OpenAPI 3.1 document, for code generators, Postman and GPT Actions. |
Every endpoint answers browsers from any website (CORS), so you can call the API straight from your page.
Errors
Errors are JSON: { "error": { "code", "message", "issues": [{ "path", "code" }] } }. The code values are stable; issues point at each bad field.
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | A field is missing or invalid. See issues. |
| 400 | invalid_json | The body is not JSON. |
| 401 | invalid_api_key | A key was sent but is not valid. Leave it out to use the anonymous limits. |
| 403 | origin_not_allowed | The key may not be used from that website. |
| 413 / 415 | payload_too_large / unsupported_media_type | Body over 16 KB, or not sent as JSON. |
| 422 | unknown_tax_class / unsupported_currency / fx_unavailable | Well formed but cannot be priced. |
| 429 | rate_limited | Slow down; see the Retry-After header. |
| 503 | rates_unavailable | Rates are temporarily unavailable. Try again shortly. |
Limits and keys
Without a key you get 30 requests a minute and 500 a day for each IP address. Every answer carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset headers.
A site that needs more can ask for a free API key. Send it as X-API-Key or Authorization: Bearer. Keep it on your server: anyone who sees it can use your quota.
Good practice
- Show the
rateVersion, the disclaimer and a link back to the calculator next to the numbers. They are estimates: Sri Lanka Customs assesses the final duty. - Do not copy rates into your own code. Ask the API each time: the gazettes change them.
- Cache
categoriesandtax-classesfor a few minutes, not calculations: they depend on the live exchange rate. - Send a descriptive
User-Agent, so we can tell your site from the rest and help you if something breaks.