# DeviceAtlas Device API Upgrade #
This document is intended for users of the 2.x APIs to assist in upgrading.
It has four main sections:
1. Why upgrade?
2. Upgrading from 2.x to 3.2.1
3. Data differences
4. Running comparison tests
## 1. Why upgrade? ##
Version 3.2.1 of the API has higher identification speed, reduced memory and
improved identification capabilities including full support for Client Hints.
## 2. Upgrading From 2.x To 3.2.1 ##
The upgrade from the 2.x API to the 3.2.1 API is straightforward with minimal
code changes required.
The 3.2.1 API uses a new improved data file format. Data files in use with
the 2.x API are not compatible.
### API Changes ###
API changes between 2.x and 3.2.1 APIs are as follows:
#### Change 1 - Loading API and data file ####
- Change in require
v2 allows the following way to create the object of DeviceApi:
```javascript
const DeviceApi = require('deviceatlas-deviceapi').DeviceApi; // <---- v3 way
const DeviceApi = require('deviceatlas-deviceapi/src/deviceapi'); // <---- won't work in v3
```
- Change in loading data file
`deviceApi.loadDataFromFile` is removed, please use fs and pass json data file contents string
to `deviceApi.loadDataFromString` or `deviceApi.loadData`.
Below is a singleton short example usage of DeviceApi
```javascript
var deviceApi = (function(){
var DeviceApi = require('deviceatlas-deviceapi').DeviceApi;
/* Use the singleton pattern and export so that only 1 instance exists
in the application. */
module.exports.deviceApi = (function() {
/* Create an instance of DeviceApi with default config */
var deviceApi = new DeviceApi();
var dataFileAsString = require('fs').readFileSync('path/to/datafile.json')
/* Load data. */
try {
deviceApi.loadDataFromString(dataFileAsString);
} catch(e) {
console.log("Could not load the data file", e);
}
return deviceApi;
})();
```
#### Change 2 - Config Options ####
The following Config options have been removed:
* includeUaProps
* includeLangProps
* includeMatchInfo
The language and languageLocale properties are no longer configurable via the
Device API config, instead they are configured via "Data File Options" page
on the DeviceAtlas account.
#### Change 3 - Method Updates ####
Following Classes have been removed:
* DeviceApiWeb (replacement use DeviceApi.getPropertiesFromRequest)
Following Methods have been removed:
* DeviceApi.getPropertiesSync (replacement DeviceApi.getProperties)
Following Methods have been updated:
* DeviceApi.getProperties = function (userAgentOrHeaders, clientSideProperties, callback): void
* DeviceApi.getProperties = function (userAgentOrHeaders, clientSideProperties): Properties
Following Methods have been added to DeviceApi:
* getPropertiesFromRequest
* getPropertyNames
* getApiVersion
* getDataVersion
* getDataCreationIso8601
## 3. Data Differences ##
The 3.2.1 API contains some data differences when compared
to the 2.x APIs.
#### Chrome Mobile ####
The `Chrome Mobile` browser name has been changed to `Chrome` to be consistent
with Google's naming policy.
#### macOS & iOS osVersion ####
The 2.x API returns the osVersion for macOS and iOS User-Agents in the form it
is found in the User-Agent. For these User-Agents, it appears like `10_5_7`. For
consistency with other version numbers, the 3.2.1 API converts
the osVersion to have dot-notation so the example `10_5_7` becomes `10.5.7`.
#### Browser Vendor & Model ####
In the 2.x API some desktop browsers set the device vendor and model to be the
browser vendor and browser name if no device was identified. The 3.2.1 API no
longer has this behaviour. Please use the `browserVendor` and `browserName`
properties instead.
#### Android Browser ####
The 2.x API incorrectly returned the browser name `Android Browser` for some
app WebView and Set Top box User-Agents. This has been corrected in the 3.2.1
API. The API returns `Chrome` instead
The 2.x API incorrectly returned the browser name `Android Browser` for some
Amazon devices running the Silk browser. This has been corrected in the 3.2.1
API. The API returns `Amazon Silk` instead
#### HuaweiBrowser ####
The Huawei browser naming has changed from `HuaweiBrowser` to `Huawei Browser`.
#### macOS ####
The osName for the macOS family of operating systems has been updated to better
reflect the correct naming for each version of macOS. The names `Mac OS X`,
`OS X` and `macOS` will be returned depending on what osVersion is detected.
#### Linux ####
The osVersionName for Linux distros is not currently well populated and will
improve over time.
#### isApp / appName ####
The current version of the data provided with the API has limited support for
isApp and appName. Subsequent releases will correct this.
#### Other Properties ####
The 3.2.1 API has improved support for non-standard User-Agents.
Differences may be observed compared to the 2.x APIs.
## 4. Running Comparison Tests ##
If a comparison between the 2.x API and the 3.2.1 API is being performed. It
is recommended to compare some key properties such as:
* id
* vendor
* model
* primaryHardwareType
* osName
* browserName
## Support ##
Please get in touch if you have any questions about the data or the 3.2.1 API by
using the support email address:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_ Copyright (c) DeviceAtlas Limited 2024. All Rights Reserved. _
_ https://deviceatlas.com _