loading-img

API Reference

Welcome to the documentation page for the UserAgent.app parsing API. This page will walk you through the process of authentication to, and consuming our service via the RESTful API. If you have any questions or concerns please contact us.

API end-point

To consume our API please make all requests to the following base API end-point.

https://api.useragent.app/parse

Authentication

API authentication is performed by appending the 'key' GET request parameter to all requests. Your unique API key can be found and regenerated in your account. The URI below

https://api.useragent.app/parse?key=YOUR_KEY_HERE

Response codes

We've tried to map our response codes as close as possible to the oringial meaning of the HTTP response codes.

HTTP Code Label Meaning
200 Processed The command was processed successfully.
422 Unprocessable Well formatted request however some technical issue is preventing the serving of the request
400 Command unknown The end-point you have sent the request to is not valid (for example, the end point should be /praser instead of /nonExistentEndPoint)
405 Command invalid The HTTP request method used is not compatible with the selected end-point. This can occur when using POST rather than GET for example.
409 Command malformed The request has been incorrectly constructed. This can occur when omitting required parameters or providing them in the wrong type.
401 Unauthorized The request was not authorised. This can occur when using an incorrect key, if the server IP is not on the account whitelist, or if the account is banned.
402 Billing The request was refused due to a billing issue with the associated account.
429 Too many requests You have exceeded your allocated concurrent request allowance.
500 Internal Server Error The client did everything correctly, but we've had an internal issue.

Parse a User Agent

This section provides example code snippets to help you use our API as quickly as possible.

cURL

curl https://api.useragent.app/parse?key=YOUR_KEY_HERE&ua=RAW_USER_AGENT_STRING

PHP


$key = 'YOUR-KEY-HERE';
$ua = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36';
$ua = urlencode($ua);

$raw = file_get_contents('https://api.useragent.app/parse?key=' . $key . '&ua=' . $ua);
if (!$raw) {
  die('Parse error');
}

$result = json_decode($raw, true);
print_r($result);

Response

A parsing request to our API is always responded to with a json object. Below, you will find an example response that is typical of a UA parsing request.

Json


{
   "client_summary":"Mobile Safari 10.0\/iOS 10.0.1",
   "ua_family":"Mobile Safari",
   "ua_type":"browser",
   "ua_version":{
      "major":10,
      "minor":0,
      "patch":0,
      "summary":"Mobile Safari 10.0"
   },
   "os_family":"iOS",
   "os_version":{
      "major":10,
      "minor":0,
      "patch":1,
      "summary":"iOS 10.0.1"
   },
   "bot_info":{
      "name":null,
      "category":null,
      "url":null,
      "vendor":{
         "name":null,
         "url":null
      }
   },
   "os_meta":{
      "name":"iOS",
      "short_name":"IOS",
      "version":"10.0",
      "platform":null
   },
   "ua_rendering_engine":"WebKit",
   "ua_rendering_engine_version":{
      "major":"602",
      "minor":"1",
      "patch":"50",
      "summary":"WebKit 602.1.50"
   },
   "device":{
      "is_mobile":true,
      "is_tablet":false,
      "is_desktop":false,
      "brand":"Apple",
      "model":"iPhone"
   },
   "client":{
      "bot":false,
      "user":true
   }
}
                                      

Native API Bindings

We've built a native binding in PHP for our API and we are more than happy to post community libraries to this page too.

Language Repository
PHP https://github.com/UserAgentApp/PHP