Every HTTP request carries a user agent string — a fingerprint of the browser, OS, and device making the request. Parsing these strings correctly is surprisingly hard.
Why Parse User Agents?¶
User agent parsing powers:
- Analytics dashboards — know which browsers and devices your users prefer
- Feature flags — serve different experiences to mobile vs desktop
- Bot detection — identify crawlers, scrapers, and automated tools
- Compatibility checks — warn users on unsupported browsers
Quick Start¶
A single API call gives you structured data from any UA string:
curl -X POST https://api.apicrate.io/api/v1/ua \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"}'
Response:
{
"status": "ok",
"data": {
"client": {
"type": "browser",
"name": "Chrome",
"version": "120.0.0.0"
},
"os": {
"name": "Mac",
"version": "10.15.7",
"family": "Mac"
},
"device": {
"type": "desktop"
}
}
}
Bulk Parsing¶
Need to process thousands of UAs? Use the bulk endpoint:
import requests
user_agents = [
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)...",
"Mozilla/5.0 (Linux; Android 14; Pixel 8)...",
"Googlebot/2.1 (+http://www.google.com/bot.html)",
]
resp = requests.post(
"https://api.apicrate.io/api/v1/ua/bulk",
headers={"X-API-Key": "YOUR_KEY"},
json={"ua_list": [{"ua": ua} for ua in user_agents]},
)
for result in resp.json()["data"]:
client = result["client"]["name"] if result["client"] else "Unknown"
os_name = result["os"]["name"] if result["os"] else "N/A"
print(f"{client} on {os_name}")
The bulk endpoint processes up to 100 user agents per request — much faster than individual calls.
Field Filtering¶
Only need the browser name? Use the fields parameter to reduce payload size:
curl -X POST "https://api.apicrate.io/api/v1/ua?fields=client,os" \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"ua": "..."}'
This returns only the fields you asked for, reducing response size and improving parsing speed.
What's Next?¶
In the next post, we'll cover secure hashing — from quick MD5 checksums to production-grade password hashing with argon2.