SerpBase
Back to Blog

User-Agent Generator API: Get Browser User-Agent Strings as JSON

Get up to five realistic desktop or mobile browser user-agent strings per request as JSON, for testing how your pages and code respond to different devices. Tested.

November 26, 2026
By SerpBase Team3 min read

Short answer: POST a device type and a count to /web/user-agent and you get up to five realistic browser user-agent strings as JSON.

A user-agent string is the line a browser sends to say what it is. You need believable ones when you test how a site responds to phones versus desktops, when you write fixtures for analytics or bot-detection code, or when a QA job has to cover several browsers without a device lab.

The request

curl -X POST 'https://api.serpbase.dev/web/user-agent' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -d '{"user_agent_type":"mobile","user_agent_count":5}'

user_agent_type is desktop or mobile; user_agent_count is 1 to 5.

What comes back

We ran this on 26 November 2026. The request above answered in about a tenth of a second with five strings in user_agents:

Mozilla/5.0 (iPhone; CPU iPhone OS 16_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1
Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Mobile Safari/537.36
Mozilla/5.0 (Android 14; Mobile; rv:123.0) Gecko/123.0 Firefox/123.0
Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Mobile Safari/537.36
Mozilla/5.0 (Android 13; Mobile; rv:122.0) Gecko/122.0 Firefox/122.0

That is Safari on iPhone, Chrome on two Pixel models and Firefox on Android. A second request, {"user_agent_type":"desktop","user_agent_count":1}, returned Chrome on Windows:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

The response is small: status, user_agents (a list of strings), credits_charged and request_id.

Python: test one page as five phones

import requests

r = requests.post(
    "https://api.serpbase.dev/web/user-agent",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={"user_agent_type": "mobile", "user_agent_count": 5},
    timeout=30,
).json()

if r["status"] != 0:
    raise SystemExit(r.get("error"))

for ua in r["user_agents"]:
    page = requests.get("https://your-site.example/", headers={"User-Agent": ua}, timeout=30)
    print(page.status_code, len(page.text), ua[:60])

Point it at your own site to see whether every phone browser gets the same status code and page size.

Things that trip people up

  • Five per request is the limit. For a bigger pool, call it a few times and remove duplicates.
  • A user-agent is only one header. Modern browsers also send client hints (Sec-CH-UA...) and have their own header order. A string alone does not make a script look like that browser; use it for testing how your own pages and code branch on it.
  • Fetch once, reuse. The strings do not expire the minute you get them. Cache a batch for a test run and spend one credit, not one per page.
  • Versions are what the generator returns, not "latest". Our strings named Chrome 122 and Firefox 122–123. If your test needs a specific browser version, check the string before you rely on it.
  • mobile mixes platforms. One batch held iOS and Android. Filter on iPhone or Android if you need one.

Related endpoints

To see what Google returns to a phone versus a desktop, the Google web search endpoint takes a device parameter; there is more on that in location, language and device.

Cost and limits

Each request costs 1 credit, whether you ask for one string or five; failed requests are not charged. The response is always HTTP 200 with a status field: 0 means success, anything else comes with an error string. Credits cost $0.25–$0.50 per 1,000 depending on the plan, and new accounts get 500 free credits without a card.