Obtain detailed information about the browser, device, and operating system by parsing a User Agent String. It also provides information about crawlers and attach sources.
Check if the user-agent belongs to a robot, spider, crawler, or any other type of automated software.
Determine the OS family, full OS name and version information.
Get the name, engine, version and release year of the browser software.
Determine the general user-agent type e.g. check if the user-agent is a phone, tablet or desktop device.
Determine if the user-agent belongs to a mobile device and get brand and model information.
Retrieve device specs such as the release year, price and physical display properties.
The User-Agent API from APIFreaks takes a complex user agent string and parses it into a detailed, readable format. This helps developers understand the browser, device, and operating system details effortlessly.
Utilize our User Agent Parser API to identify and block malicious actors. Detect malformed user-agent strings and prevent attackers from accessing your website, ensuring a secure user experience.
$ pip install requests
Header | Required | Type | Default | Description |
---|---|---|---|---|
User-Agent | Yes | String | user-agent string to parse |
Field | Type | Requirement | Description |
---|---|---|---|
userAgentString | String | Mandatory | User-agent string that is parsed for browser, device and operating system details. |
name | String | Mandatory | Agent name or the actual browser name that was used. |
type | String | Mandatory | Agent type or the browser type that was used. Possible values are:
(1) Browser - Regurlar Web Browser
(2) Browser Webview - Regular browser being used in a mobile app
(3) Mobile App - A mobile app accessing the website
(4) Robot Mobile - A web crawler who want to be detected as mobile
(5) Cloud Application - Something running in the cloud (can be web scrapper etc.)
(6) Email Client - An email client
(7) Voice - Voice enabled browser that reads out loud
(8) Special - Somethig special we can't classify
(9) Testclient - Website testing tool
(10) Hacker - Someone with malicious stuff in useragent string or malformed UA string
(11) Unknown - We don't know |
version | String | Mandatory | Agent version or the browser version |
versionMajor | String | Mandatory | Agent version majore or the browser version majore |
device.name | String | Mandatory | Device name or the hardware that was used |
device.type | String | Mandatory | Device type or the hardware type. Possible values are:
(1) Desktop - This device is a Desktop/Laptop
(2) Mobile - This device is a mobile device however we are not sure if its a tablet, watch, e-reader or phone
(3) Tablet - This device is a Tablet
(4) Phone - This device is a mobile Phone
(5) Watch - This device is a watch or device with tiny screen <2"
(6) Virtual Reality - This is VR capable mobile device
(7) eReader - Device with e-ink screen
(8) Set-top box - A connected device that can interact with TV screen
(9) TV - Smart TV
(10) Game Console - Fixed game consoles like PS and XBox
(11) Handheld Game Console - 'Mobile' game systems like the 3DS
(12) Voice - A voice driven device that reads the page loud
(13) Robot - Robot crawler
(14) Robot Mobile - Mobile device Robot crawler
(15) Robot Imitator - Robots that pretend to be Google or Bing crawlers but they usually are not official crawlers.
(16) Hacker - Either the User Agent String is malformed or some kind of scripting is detected in it.
(17) Anonymized - The User Agent has been altered by anonymization software.
(18) Unknown - We can't extract the device information from the User Agent. |
device.brand | String | Mandatory | Device brand or the hardware brand name |
devide.CPU | String | Mandatory | Device's CPU model or machine CPU |
engine.name | String | Mandatory | Layout engine name or the underlying core that converts the HTML into visual |
engine.type | String | Mandatory | Layout engine type. Possible values are:
(1) Browser - Regurlar Web Browser
(2) Mobile App - A mobile app with webview or an app that includes regular browser
(3) Hacker - Someone with malicious stuff in useragent string or malformed UA string
(4) Robot - A web crawler
(5) Unknown - We don't know anything about the identity of this device |
engine.version | String | Mandatory | Layout engine version |
engine.versionMajor | String | Mandatory | Layout engine version major |
engine.build | String | Mandatory | Layout engine build |
operatingSystem.name | String | Mandatory | Operating system name or the base software name that runs on the hardware. |
operatingSystem.type | String | Mandatory | Operating system type. Possible values are:
(1) Desktop - A Desktop OS (Desktop/Laptop)
(2) Mobile - A Mobile OS (Tablet/Mobile/Watch)
(3) Game Console - Game Console like PlayStation
(4) Embedded - An Embedded device (TV, RTOS etc)
(5) Cloud - Something running in the cloud environment
(6) Hacker - A hacker
(7) Anonymized - Explicitly hidden with some software
(8) Unknown - We really don't know about this OS |
operatingSystem.version | String | Mandatory | Operating system version |
operatingSystem.versionMajor | String | Mandatory | Operating system version major |
HTTP Status | Reasons |
---|---|
400 | userAgentString' must not be empty or null |
Pass the user agent string in the User-Agent header to get details about the user agent in a very readable json format.
# Get User-Agent Details for User-Agent header# Response { "userAgentString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9", "name": "Safari", "type": "Browser", "version": "9.0.2", "versionMajor": "9", "device": { "name": "Apple Macintosh", "type": "Desktop", "brand": "Apple", "CPU": "Intel" }, "engine": { "name": "AppleWebKit", "type": "Browser", "version": "601.3.9", "versionMajor": "601", "build": "Unknown" }, "operatingSystem": { "name": "Mac OS X", "type": "Desktop", "version": "10.11.2", "versionMajor": "10" } }$ curl --location --request GET ' https://api.apifreaks.com/v1.0/user-agent/lookup?apiKey=API-KEY' --header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'
Crawlers and bots pass their User Agent Strings with header and our API can parse that as well and detects the type of crawler. Below is a User Agent String of Google Bot with Nexus mobile device. “Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)” A curl request with this header will yield:
# Response { "userAgentString": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)", "name": "Googlebot", "type": "Robot Mobile", "version": "2.1", "versionMajor": "2", "device": { "name": "Google", "type": "Robot Mobile", "brand": "Google", "CPU": null }, "engine": { "name": "Googlebot", "type": "Robot", "version": "Googlebot", "versionMajor": "Googlebot" }, "operatingSystem": { "name": "Google", "type": "Cloud", "version": "Google", "versionMajor": "Google" } }$curl --location --request GET ' https://api.apifreaks.com/v1.0/user-agent/lookup?apiKey=API-KEY' --header 'User-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' '
The hackers usually malform the user agent strings and append their custom scripts with it. Whenever our API detects such anomalies, it reports back with an appropriate message. Here is an example of a malformed Google bot user agent. “Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) select name” Notice that a SQL query select name is appended to the string. Here is how our API reacts to it
# Response { "userAgentString": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) select name", "name": "Hacker", "type": "Hacker", "version": "Hacker", "versionMajor": "Hacker", "device": { "name": "Hacker", "type": "Hacker", "brand": "Hacker", "CPU": null }, "engine": { "name": "Hacker", "type": "Hacker", "version": "Hacker", "versionMajor": "Hacker" }, "operatingSystem": { "name": "Hacker", "type": "Hacker", "version": "Hacker", "versionMajor": "Hacker" } }curl --location --request GET ' https://api.apifreaks.com/v1.0/user-agent/lookup' --header 'User-Agent: Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) select name'
To use the user-agent parser API, API credits are required. Charges apply only for successful queries, defined by a 2xx status code. If a request results in a 4xx or 5xx status code, no credits will be deducted, and any credits already charged will be refunded.
For each successful request, 1 credit will be charged to parse a user agent string. Utilize the Credits Usage API to efficiently monitor your recent consumption of both one-off and subscription credits. This API provides a streamlined way to track and manage your credit usage, ensuring you stay informed about your remaining balance and can optimize your resource allocation effectively.