NewAPIVerve Academy: free courses and certifications anyone can verify.Explore the Academy →

Sales Tax Lookup Template

  • Next.js
  • TypeScript

The combined sales tax rate for any US ZIP code, with the tax and total for a price.

A Next.js app that looks up US sales tax by ZIP code. Enter a ZIP and a price to get the combined rate for that city and state, the tax due and the total, printed on a receipt. Use it as a quick reference for shoppers and sellers, or lift the route to add tax to a cart or invoice.

The sales tax lookup app running

What it does

Any US ZIP code
Returns the combined state, county, city and district rate, with the city and state it matched.
Tax and total
Works out the tax to the cent and the total for any price, in the browser, with no extra calls.
Rate breakdown on paid plans
With a paid key the app splits the rate into state, county, city and special district bars.
Cached for a week
Each ZIP's rate is cached for seven days, so repeat lookups cost nothing.
Keeps your key private
The browser only talks to your own API route, which holds the key, checks the ZIP and limits each visitor to 10 a minute.

How it works

The route: it checks the ZIP code, then calls Sales Tax and caches the answer.

app/api/salestax/route.ts
/** GET /api/salestax?zip=90210: the combined sales tax rate for a US ZIP code. */
export async function GET(request: Request) {
  const zip = (new URL(request.url).searchParams.get('zip') || '').trim();
  if (!/^\d{5}$/.test(zip)) return fail('Enter a 5-digit US ZIP code');

  const key = `salestax:${zip}`;
  const hit = fromCache(key, TTL_MS);
  if (hit) return Response.json(hit);

  const blocked = guard(request);
  if (blocked) return blocked;

  return respond(async () => {
    const data = await callApi<SalesTax>('salestax', { query: { zip } });
    toCache(key, data);
    return data;
  });
}

See the whole file on GitHub →

Deploy it

  1. Get a free API key

    The free plan includes 200 credits a month, no card needed. Create your key.

  2. Deploy it

    Click Deploy to Vercel. Vercel copies the repo to your GitHub account and asks for APIVERVE_API_KEY: paste your key there.

  3. Open your app

    Vercel builds it and gives you a live URL, usually in about a minute. Every push to the repo redeploys it.

Try the Sales Tax Lookup API — the call this template makes

Request
GETapi.apiverve.com/v1/salestax?zip=64082
Query parameters
Verification
Format

No key required to try it. Get a key to use it in your app.

Example
{
  "status": "ok",
  "error": null,
  "data": {
    "state": "CA",
    "zip": 90210,
    "region": "WEST HOLLYWOOD TOURISM IMPROVEMENT DISTRICT",
    "rate": 0.1025,
    "county": 0.0025,
    "city": 0.0075,
    "special": 0.0325,
    "stateRate": 0.06,
    "cityName": "Beverly Hills",
    "stateName": "California",
    "sourcing": "mixed"
  }
}

Build your own with Sales Tax Lookup. Start with 200 free credits. One key unlocks all 300+ APIs.

Explore the catalog

300+ APIs on the same key and the same response shape.

Browse all APIs