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

User Agent Parser Template

  • Next.js
  • TypeScript

See the browser, operating system and device behind any user agent string, or your visitor's own.

A Next.js app that reads user agent strings. It opens on the visitor's own browser, then parses any string you paste into browser, operating system, device and engine, flags bots and crawlers, and says whether the browser is out of date. Use it as a debugging tool, or lift the route to tailor your site to each device.

The user agent parser app running

What it does

Starts with yours
On load the route reads the visitor's own User-Agent header, so a deployed copy shows each person their browser.
Browser, OS and device
Names the browser and version, operating system, device vendor and model, and rendering engine.
Spots bots
Tells crawlers like Googlebot apart from real browsers, with its own look for bots.
Out-of-date check
Shows how many versions behind the browser is, and whether its OS version still gets updates.
Keeps your key private
The browser only talks to your own API route, which holds the key, caches answers for a day and rate-limits visitors.

How it works

The route: use the pasted string or the visitor's own header, then call User Agent Parser.

app/api/parse/route.ts
export async function POST(request: Request) {
  const body = await request.json().catch(() => ({}));
  const ua = body?.mine ? str(request.headers.get('user-agent'), 1000) : str(body?.ua, 1000);
  if (!ua) return fail('Paste a user agent string to parse');

  const key = `ua:${createHash('sha1').update(ua).digest('hex')}`;
  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('useragentparser', { json: { ua } });
    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 User Agent Parser API — the call this template makes

Request
POSTapi.apiverve.com/v1/useragentparser
Body
Verification
Format

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

Example
{
  "status": "ok",
  "error": null,
  "data": {
    "ua": "Mozilla/5.0 (Windows NT 6.4) AppleWebKit/537.36.0 (KHTML, like Gecko) Chrome/60.0.0.0 Safari/537.36.0",
    "browser": {
      "name": "Chrome",
      "version": "60.0.0.0",
      "major": "60"
    },
    "engine": {
      "name": "Blink",
      "version": "60.0.0.0"
    },
    "os": {
      "name": "Windows",
      "version": "10"
    },
    "device": {},
    "cpu": {},
    "isMobile": false,
    "isBot": false,
    "deviceType": "desktop",
    "clientType": "browser",
    "library": null,
    "isSuspicious": false,
    "suspiciousReasons": [],
    "osVersionFrozen": true,
    "versionCheck": {
      "browserFamily": "Chrome",
      "latestVersion": "156",
      "majorsBehind": 95,
      "isOutdated": true,
      "osEndOfLife": null
    },
    "summary": "Chrome 60 on Windows 10"
  }
}

Build your own with User Agent Parser. 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