# 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 a single `device` package.
#### DeviceApi (deviceatlas/device) ####
The device package loads the Device data file, detects and returns the
properties for a set of request headers or the user-agent. Client-side
properties can be optionally passed to this package 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:
```go
import (
"deviceatlas/device"
"strings"
)
// (1) create an instance with default API settings
da := device.New()
defer da.Free()
// (2) load the data file
_, err := da.LoadDataFromFile("/path/to/apps_datafile_lowercased.json")
if err != nil {
// handle the errors related to loading the data file
}
// (3) look up device properties based on a particular make/model string
make_model := strings.ToLower("samsung SM-N9005")
properties, err := da.DetectV(make_model)
if err != nil {
// handle the errors related to properties detection
}
// (4) use the properties - e.g. detect mobile device
// if there is a property named "mobileDevice" and the value is true
if mobileDevice, ok := properties["mobileDevice"]; ok {
// example 1: Get the screen width for image optimization
displayWidth := 100
use_bigger_icons := false
supports_geo_location := false
if displayWidth, ok := properties["displayWidth"] {
display_width = displayWidth.(int64)
}
// example 2: Get the device vendor name
vendor := properties["vendor"].(string)
// example 3: Touch screen optimization
if _, ok := properties["touchScreen"]; ok {
use_bigger_icons = true
}
// example 4: Is Geo Location enabled on the device?
if _, ok := properties["js.geoLocation"]; ok {
supports_geo_location = true
}
}
```
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_ Copyright (c) DeviceAtlas 2022. All Rights Reserved. _
https://deviceatlas.com