# DeviceAtlas Device Detection API Config # DeviceAtlas DeviceApi Config class provides options to customize the API behaviour in terms of memory use, caching, performance and device properties. #### Client-side cookie name #### Name of the cookie where the Client-side properties will be saved in. When using getProperties() method in a web application (DeviceApiWeb), the detection will automatically use the content of this cookie, if it exists. If you want the Client-side properties to be used add the DeviceAtlas client side component (JavaScript lib) to your web-site pages. When the User-Agent or HTTP headers are passed manually to getProperties(), the Client-side properties can be also manually passed to this method as second parameter. Please see the [ClientSide readme file](https://docs.deviceatlas.com/apis/clientside/latest/README.ClientSide.html) for more information. Note that this config is only used as an argument of getProperties(). If you set the cookie name to NULL, then the Client-side properties cookie will be ignored. DeviceAtlas Client-side CDN include. ```html <script type="text/javascript" src="https://cs.deviceatlas-cdn.com/dacs.js" async></script> ``` **Config variable** ``` cookieName ``` **Default value** "DAPROPS" ### How it works ### Translating into code how the API settings are used, it is as simple as having an instance of the mobi.mtld.da.device.Config class into the mobi.mtld.da.device.DeviceApi object and the respective Config public methods to check the wished settings and make the API work according to them. #### Use of the default settings #### When a new instance of the mobi.mtld.da.device.DeviceApi class is created, internally another instance of the mobi.mtld.da.device.Config class is generated with the default settings. ```javascript var DeviceApi = require('deviceatlas-deviceapi').DeviceApi; var deviceApi = new DeviceApi(); ``` #### Use of custom settings #### In order to use custom settings, You may create a json in which the Config object is created inside the deviceapi. ```javascript var DeviceApi = require('deviceatlas-deviceapi').DeviceApi; /* Preferred method */ deviceApi = new DeviceApi({maxCacheEntries: 4096}); ``` Alternatively you may to explicitly create a Config object, set the settings and pass it to the DeviceApi instance. ```javascript var DeviceApi = require('deviceatlas-deviceapi').DeviceApi; var Config = require('deviceatlas-deviceapi').Config; /* Alternative method */ config = new Config(); config.maxCacheEntries = 1024; deviceApi = new DeviceApi(config); ``` ```javascript var DeviceApi = require('deviceatlas-deviceapi').DeviceApi; var Config = require('deviceatlas-deviceapi').Config; /* Alternative method */ deviceApi = new DeviceApi(); config = new Config(); deviceApi.config = config; ``` ### Example of use case ### For the scenario your system works, it is highly recommended to configure the API with the most convenient settings in order to enhance performance, memory footprint and, in general, provide a better user experience. ```javascript var DeviceApi = require('deviceatlas-deviceapi').DeviceApi; var Config = require('deviceatlas-deviceapi').Config; /* Reduce response time and memory footprint for a web application */ config = new Config(); // Set the number of maximum entries held in the internal cache. config.maxCacheEntries = 4096; // Boost API performance by ignoring dynamic properties if they are not part of // the property set you expect. // Finally set the config to our new instance of the DeviceAtlas API. deviceApi = new DeviceApi(config); ``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _ Copyright (c) DeviceAtlas Limited 2024. 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.Installation.html">Enterprise API Installation</a></li><li><a href="README.DeviceApi.html">Device API Usage</a></li><li class="disabled"><a href="README.DeviceApi-Config.html">Device Detection API Config</a></li><li><a href="README.ClientHints.html">Client Hints Support</a></li><li><a href="README.Upgrade.html">Device API Upgrade</a></li><li class="divider"></li><li><a href="./DeviceAtlasApiDocs/index.html">DeviceAtlas API JS Docs</a></li></ul></div>