Get your API Token

  1. Signup and login to User-Agent Info
  2. Once logged in, click "Billing" link and get your api token.

How to do device, OS and browser detection in various programming languages

$useragent = $_SERVER['HTTP_USER_AGENT'];
// get api token at
$token = "your api token";
$url = "";

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

$headers = array();
$headers[] = "Content-type: application/json";
$headers[] = "Authorization: Token " . $token;

$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));


echo $json_response;
import json
import requests

token = "your-api-token"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Token {}".format(token)
payload = {
    "useragent": "Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176"
url = ""
r =, headers=headers, data=json.dumps(payload))
result = r.json()
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'
token = 'your api token'

uri = URI.parse("")
header = {"Authorization": "Token #{token}"}
http =, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request =, header)
request.set_form_data({"useragent" => useragent})

response = http.request(request)
puts response.body 
curl -X POST '' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token {api_token}' \
-d '{"useragent":"Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176"}'

Sample Response:

  "browser":"Mobile Safari",

Sponsored Links

  • Note: When you click on the affiliate links above and you make a purchase, I will have a commission and that will help keeping this service ( alive. Those services above are affordable and trusted when you need to spin up servers for your favorite web applications and are highly recommended.