User-Agent Info is a simple free web service API that do OS detection, Browser detection and Device detection via User-Agent string. The core of this api is based on uap-core Browserscope’s user agent parser which is good enough for most use cases. The excellent open source uap-core project has a single YAML file that contains regular expression patterns for parsing user-agent strings and can be easily integrated in most web applications that runs on PHP, Java, Ruby, Python, Perl, C# and more.


  • OS Detection
  • Browser Detection
  • Device Detection
  • SSL Encryption

Various Use Cases

  • Tailored Advertising
  • Targeted Content
  • User Exeperience

API Usage via Bash/cURL

curl -X POST -H "Content-Type: application/json" \
  -d '{"ua":"Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176"}' \

API Response

  "browser":"Mobile Safari UI/WKWebView",
Need to deploy your awesome Python, PHP or Ruby web application to the cloud? Check out Digital Ocean, they provide realiable and affordable servers. Their tutorials are also a great resource so you can deploy webapps easily.

How to do device detection in various programming languages?

Device detection in PHP

You can get your website visitor user-agent string via $_SERVER['HTTP_USER_AGENT'].

// $useragent = $_SERVER['HTTP_USER_AGENT'];
$useragent = 'Mozilla/5.0 (iPad; CPU OS 9_3_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13F69 Safari/601.1';
$url = "";

$data = array('ua' => $useragent);

$headers = array();
$headers[] = "Content-Type: application/json";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));

$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ($status != 200 ) {
    die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));

$result = json_decode($json_response, true);

if ($result['device_type'] === 'iPad') {
  echo "It's an iPad\n";

echo $json_response;

Device detection in Python

Flask and Django are two of the most popular Python web frameworks. With Flask you can get the user-agent string via request.headers.get('User-Agent'). In Django via request.META.get('HTTP_USER_AGENT', '').

# python-requests must be installed
import requests

headers = {
    "Content-Type": "application/json",
payload = {
    "ua": "Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176"
url = ""
r =, headers=headers, json=payload)
result = r.json()
if result["device_type"] == "iPad":
    print("It's an iPad")

Device detection in Ruby

In Ruby on Rails, you can get the user-agent string via request.user_agent.

require 'net/https'
require 'json'
require 'uri'

useragent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1'

body = {"ua" => useragent}

uri = URI.parse("")
http =, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request ="/device")
request.add_field('Content-Type', 'application/json')
request.body = body.to_json
response = http.request(request)
json = JSON.parse(response.body)

if json['device_type'] == 'iPhone'
  print("It's an iPhone\n")

puts response.body