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 |
For a comprehensive view of the API response structure and detailed field descriptions, explore the interactive Response Table by clicking here.
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 -X 'GET' 'https://api.apifreaks.com/v1.0/user-agent/lookup?apiKey=API-KEY' -H 'User-Agent: 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 -X 'GET' 'https://api.apifreaks.com/v1.0/user-agent/lookup?apiKey=API-KEY' -H '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 -X 'GET' 'https://api.apifreaks.com/v1.0/user-agent/lookup?apiKey=API-KEY' -H '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'