API Kit Configuration

All API kits are broadly the same and follow similar design patterns, however sometimes config options can vary a bit from kit to kit.

PHP
<?php
$hdconfig['username'] = "***API-USERNAME***";
$hdconfig['secret'] = "***API-SECRET***";
$hdconfig['site_id'] = "***SITE-ID***";
$hdconfig['use_local'] = false;
$hdconfig['filesdir'] = '/tmp';
$hdconfig['debug'] = false;
$hdconfig['api_server'] = 'api.handsetdetection.com';
$hdconfig['cache_requests'] = false;
$hdconfig['geoip'] = true;
$hdconfig['timeout'] = 10;
$hdconfig['use_proxy'] = false;
$hdconfig['proxy_server'] = '';
$hdconfig['proxy_port'] = '';
$hdconfig['proxy_user'] = '';
$hdconfig['proxy_pass'] = '';
$hdconfig['retries'] = 3;
?>
Java
#common
common.username=***API-USERNAME***
common.secret=***API-SECRET***
common.site_id=***SITE-ID***
common.non_mobile=
common.match_filter=
common.use_local=false

#socket connection timeouts
connection.connect_timeout=5
connection.read_timeout=5

#proxy
proxy.enabled=false
proxy.address=
proxy.port=
proxy.username=
proxy.password=

#local directory for downloaded files (Ultimate only)
local.files.directory=/tmp

#logging
logger.enabled=true
Python
config:
  api_username: ***API-USERNAME***
  api_secret: ***API-SECRET***
  site_id: '***SITE-ID***'
  use_local: False
  filesdir: /tmp
  debug: false
  api_server: api.handsetdetection.com
  cache_requests: False
  timeout: 10
  use_proxy: false
  proxy_server:
  proxy_port:
  proxy_user:
  proxy_pass:
  retries: 3

#
# Dogpile.cache settings.
# The cache defaults to backend: dogpile.cache.memory, expiry: 3600, arguments: { cache_dict: hd40cache }
#
cache:
  backend: dogpile.cache.memcached
  expiry: 3600
  arguments:
    url: 127.0.0.1:11211
.NET
// dotNet 4.0
{  
   "username":"***API-USERNAME***",
   "secret":"***API-SECRET***",
   "site_id":"***SITE-ID***",
   "use_local":"false",
   "filesdir":"",
   "debug":"false",
   "api_server":"api.handsetdetection.com",
   "cache_requests":"false",
   "geoip":"true",
   "timeout":"10",
   "use_proxy":"false",
   "proxy_server":"",
   "proxy_port":"",
   "proxy_user":"",
   "proxy_pass":"",
   "retries":"3",
   "log_unknown":"true"
}

username and secret are your API connection credentials. You can find them either from the dashboard (Click on your Avatar, Select Change Settings and scroll down a little to API Connection Information, where you can also modify the details if desired), or from the site settings icon (from your main dashboard page scroll down to 'Manage Sites', then look across to the Actions section, click the 3 little orange cogs or gears, once the site settings page has loaded click the 'Ultimate' tab).

site_id, is the id of the site you wish to perform detections or downloads for.

use_local, set this to true to flip your API kit into Ultimate (local detection) mode. Set to false for cloud detection. Note : Cloud and Ultimate detection replies are virtually identical (ultimate has no GeoIP information), so you can switch between modes at the flick of a switch.

debug, set this to false, its used while debugging api kit issues and has a bit of performance overhead.

api_server, this should always be api.handsetdetection.com

cache_requests, a new option in api v4.0, set this to true to locally cache detection replies. Setting this to true will cause 'hot' http headers to be locally cached. This will reduce detection lookups and speed up performance in cloud mode, however as side effect it will distort analytics as cache 'hits' will not be tracked.

geoip, deprecated, this enables geoip lookups in cloud mode.

timeout, maximum duration for a cloud web service request.

retires, how many times to re-try a cloud request (if it fails or timeouts).

proxy options, set these if you're making cloud queries through a web proxy.

The default config filenames differ from kit to kit and the main detection classes in each language have a method of supplying a custom config file name, making switching credentials from test to production easy. See your kit of choice for examples and information.

All API kits can be found at our Device Detection GitHub Repo

Still need help? Contact Us Contact Us