# DeviceAtlas Device Detection for Apps # The DeviceAtlas Device Detection API for Apps provides a way to detect devices based on make/model strings. Using the make and model information, the API returns device information such as screen width, screen height, is mobile, vendor, model etc. To see a full list of properties in DeviceAtlas please visit: https://deviceatlas.com/resources/available-properties . ### Make-Model String Format ### DeviceAtlas expects the make/model string in a specific format. This format consists of values separated by a space character, where the mandatory values are manufacturer and model. The string is the same for all platforms: ``` "Make Model" ``` The term "Make" stands for manufacturer and the term "Model" stands for a model number. It is important to pass the string to the DeviceAtlas API in the lowercase form when using lowercased data file. Other modifications to the make or model strings obtained from the device may result in non-identification or mis-identification. For more information please visit: https://deviceatlas.com/resources/getting-started-enterprise-for-apps ### Data File ### The DeviceAtlas API relies on a device data file to function. DeviceAtlas provides daily data file updates so it is recommended to download the data file on a regular basis. This can be done manually from your account page or in an automated way via the https://deviceatlas.com/getJSON page. For more information please see: https://deviceatlas.com/resources/getting-the-data ### Dependencies ### This library does not depend on any third party libraries. ### Library ### The DeviceAtlas API consists of one package that contains modules with all common API classes plus the additional modules for the Device Detection API. #### DeviceAtlas Common (Api/mobi/mtld/da/*) #### Contains the shared classes which are common between the DeviceAtlas APIs. When using DeviceApi this module must be accessible from your code. #### DeviceApi (Api/mobi/mtld/da/device/device_api/DeviceApi) #### The main class that loads the Device data and detects and returns the properties for a set of request headers or the user-agent. Client-side properties can be optionally passed to this library to get more accurate results. ### Basic Usage ### The API can be used as follows: To lookup the properties by passing the make/model string to the API: ```python # (1) create an instance with default API settings device_api = DeviceApi() # (2) load the data file try: device_api.load_data_from_file("/path/to/apps_datafile_lowercased.json") except: # handle the exceptions related to loading the data file # (3) look up device properties based on a particular make/model string make_model = "samsung SM-N9005".lower() properties = device_api.get_properties(make_model) # (4) use the properties - e.g. detect mobile device # if there is a property named "mobileDevice" and the value is true if properties.contains("mobileDevice", True): # example 1: Get the screen width for image optimization if "displayWidth" in properties: display_width = int(properties["displayWidth"]) else: display_width = 100 # example 2: Get the device vendor name if "vendor" in properties: vendor = properties.get("vendor") else: vendor = "" # example 3: Touch screen optimization use_bigger_icons = properties.contains("touchScreen", True) # example 4: Send Geo Location JS to client? supports_geo_location = properties.contains("js.geoLocation", True) ``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _ Copyright (c) DeviceAtlas Limited 2021. All Rights Reserved. _ _ https://deviceatlas.com _ <!-- HTML+JS for document formatting when opened in browser --> <div class="btn-group" id="main-menu" style="float:right"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Menu<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="README.html">Main</a></li><li><a href="README.DeviceApi-Web.html">Device Detection for Web</a></li><li class="disabled"><a href="README.DeviceApi-Apps.html">Device Detection for Apps</a></li><li><a href="README.DeviceApi-Config.html">Device Detection API Config</a></li><li><a href="README.Upgrade.html">Device Detection API Upgrade</a></li><li><a href="ApiDocs/mobi.mtld.da.device.device_api.DeviceApi-class.html">Device API Docs</a></li><li class="divider"></li><li><a href="README.CarrierApi.html">Carrier Identification API</a></li><li><a href="ApiDocs/mobi.mtld.da.carrier.carrier_api.CarrierApi-class.html">Carrier API Docs</a></li><li class="divider"></li><li><a href="README.ClientSide.html">Client-side Component</a></li><li><a href="README.ConnectivityAnalyser.html">Connectivity Analyser</a></li></ul></div>