---
title: "API reference for the Device Detection service"
slug: "api-reference-for-the-device-detection-service"
abstract: "Customize your Sitecore experience further with this API reference topic."
---
# API reference for the Device Detection service

The Sitecore Device Detection module consists of the following assemblies:

- `Sitecore.CES.DeviceDetection` contains the API that enables detection of devices and provides information on the device's parameters.
- `Sitecore.CES.DeviceDetection.Rules` contains conditions that are used in Device Detection rules.

These assemblies enable you to use the following API references to further customize your Sitecore solution:

<details>
<summary><h2>Sitecore.CES.DeviceDetection</h2></summary>

This namespace contains the main Device Detection API classes.

| **Class name** | `DeviceInformationProviderBase` |
| --- | --- |
| **Description** | This is an abstract base class for the device information provider. You need to derive from this class to implement your own device information provider. |
| **Fields** | <ul><li>`DeviceCache`<br>Contains information about the device's cache instance.</li></ul> |
| **Methods** | <ul><li>`DeviceInformation GetDeviceInformation(string userAgent)`<br>Gets device information from the cache for the `userAgent`. If the cache does not contain the required device information, it calls the `DoGetDeviceInformation` method and adds the response to the cache.</li><li>`DeviceInformation DoGetDeviceInformation(string userAgent)`<br>Gets the device information based on a user agent string.</li><li>`string GetExtendedProperty(string userAgent, string propertyName)`<br>Gets the device's property from the cache for the `userAgent`. If the cache does not contain the required device property, it calls the `DoGetExtendedProperty` method and adds the response to cache.</li><li>`string DoGetExtendedProperty(string userAgent,``string propertyName)`<br>Gets a device property from the device database, in the case where this property is not a part of the `DeviceInformation` class.</li></ul> |
| **Properties** | <ul><li>`bool``IsEnabled`<br>Determines whether the provider is enabled and is usable. Override this property if your provider can be disabled, for example if it requires a subscription to the default provider.</li><li>`bool``IsInitialized`<br>Determines whether the provider is initialized. Override this property if your provider can be initialized asynchronously, and the initialize method only starts the initialization process.</li></ul> |

| **Class name** | `DeviceDetectionManager` |
| --- | --- |
| **Description** | This is the static class that resolves device information based on a user agent string. |
| **Methods** | <ul><li>`DeviceInformation GetDeviceInformation(string userAgent)`<br>Gets the device information based on the user agent string.</li><li>`string GetExtendedProperty(string userAgent, string propertyName)`<br>Gets an extended property from the device database if it is not found in `DeviceInformation`.</li><li>`bool``CheckInitialization(TimeSpan timeout)`<br>Tries to initialize the provider and waits until the provider is either initialized or timeout is expired. The method returns true if the provider is initialized, otherwise it returns false.</li><li>`bool``CheckInitialization()`<br>Tries to initialize the provider and waits until the provider is either initialized or the default timeout has expired. See `DeviceDetection.CheckInitializationTimeout`. The method returns true when the provider is initialized, otherwise it returns false.</li></ul> |
| **Properties** | <ul><li>`bool``IsEnabled`<br>Indicates whether the device detection service and the provider are enabled in the configuration. This property is true if you have a valid license and `DeviceDetectionEnabled = true` in the config file.</li><li>`bool``IsReady`<br>Gets the value that indicates whether device detection is enabled, and that the provider is initialized.</li></ul> |

| Class name | `DeviceDetectionManagerBase` |
| --- | --- |
| `Description` | This class resolves device information based on a user agent string. |
| **Methods** | <ul><li>`DeviceInformation GetDeviceInformation(string userAgent)`<br>Gets the device information based on the user agent string.</li><li>`string GetExtendedProperty(string userAgent, string propertyName)`<br>Gets an extended property from the device database if it is not found in `DeviceInformation`.</li><li>`boolCheckInitialization(TimeSpan timeout)`<br>Tries to initialize the provider and waits until the provider is either initialized or timeout is expired. The method returns *true*if the provider is initialized, otherwise it returns *false*.</li><li>`boolCheckInitialization()`<br>Tries to initialize the provider and waits until the provider is either initialized or the default timeout has expired. See `DeviceDetection.CheckInitializationTimeout`. The method returns<br>*true*when the provider is initialized, otherwise it returns *false*.</li></ul> |
| **Properties** | <ul><li>`boolIsEnabled`<br>Indicates whether the device detection service and the provider are enabled in the configuration. This property is true if you have a valid license and `DeviceDetectionEnabled = true` in the config file.</li><li>`boolIsReady`<br>Gets the value that indicates whether device detection is enabled, and that the provider is initialized.</li></ul> |

| Class name | `DefaultDeviceDetectionManager` |
| --- | --- |
| **Description** | This class is the default implementation of the service that resolves device information based on a user agent string. |
| **Methods** | <ul><li>`DeviceInformation GetDeviceInformation(string userAgent)`<br>Gets the device information based on the user agent string.</li><li>`string GetExtendedProperty(string userAgent, string propertyName)`<br>Gets an extended property from the device database if it is not found in `DeviceInformation`.</li><li>`boolCheckInitialization(TimeSpan timeout)`<br>Tries to initialize the provider and waits until the provider is either initialized or timeout is expired. The method returns *true*if the provider is initialized, otherwise it returns *false*.</li><li>`boolCheckInitialization()`<br>Tries to initialize the provider and waits until the provider is either initialized or the default timeout has expired. See `DeviceDetection.CheckInitializationTimeout`. The method returns *true*when the provider is initialized, otherwise it returns *false*.</li></ul> |
| **Properties** | <ul><li>`boolIsEnabled`<br>Indicates whether the device detection service and the provider are enabled in the configuration. This property is true if you have a valid license and `DeviceDetectionEnabled = true` in the config file.</li><li>`boolIsReady`<br>Gets the value that indicates whether device detection is enabled, and that the provider is initialized.</li></ul> |

| **Class name** | `DeviceInformation` |
| --- | --- |
| **Description** | This class contains basic information about a device. |
| **Properties** | <ul><li>`Browser`<br>Contains the browser name and version.</li><li>`BrowserCanJavaScript`<br>Specifies whether the browser supports JavaScript.</li><li>`BrowserHtml5AudioCanAudio`<br>Specifies whether the browser supports HTML5 audio.</li><li>`BrowserHtml5VideoCanVideo`<br>Specifies whether the browser supports HTML5 video.</li><li>`CanTouchScreen`<br>Specifies whether the browser and the device are touch screen enabled.</li><li>`DeviceIsSmartphone`<br>Specifies whether the device is a smartphone.</li><li>`DeviceModelName`<br>Specifies the model name of the device.</li><li>`DeviceOperatingSystemModel`<br>Specifies the model of the device's operating system.</li><li>`DeviceOperatingSystemVendor`<br>Specifies the vendor of the device's operation system.</li><li>`DeviceType`<br>Specifies the device type.</li><li>`DeviceVendor`<br>Specifies the vendor of the device.</li><li>`HardwareDisplayHeight`<br>Specifies the display height of the device. The value is 0 for a browser.</li><li>`HardwareDisplayWidth`<br>Specifies the display width of the device. The value is 0 for a browser.</li><li>`IsBot`<br>Specifies whether the device is, for example. a crawler, bot, robot, or spider.</li></ul> |

| Class name | `DeviceDetectionServicesConfigurator` |
| --- | --- |
| **Description** | This class represents the `IServicesConfigurator` for the `Sitecore.CES.DeviceDetection` assembly. |
| **Methods** | <ul><li>`void Configure(IServiceCollection serviceCollection)`<br>Registers the Device Detection services.</li></ul> |

- **Enumeration name**: `DeviceType`
- **Description**: This enumeration represents a type of device.
- **Members**: OtherMobilePhoneMobileConsoleEReaderTabletMediaPlayerSettopBoxCameraBotNoteThe enum DeviceType.Bot is now obsolete. To check robots, use the following code instead:WearableComputerComputer

```text
var isRobot = DeviceDetectionManager.GetExtendedProperty(HttpContext.Current.Request.UserAgent, "IsCrawler");

```

</details>

<details>
<summary><h2>Sitecore.CES.DeviceDetection.Cache</h2></summary>

This namespace contains **the Device Detection** cache class.

> [!note]
> The cache name is `DeviceDetection`

| **Class name** | `DeviceDetectionCache` |
| --- | --- |
| **Description** | This class implements a cache for device information and extended properties. |
| **Methods** | <ul><li>`DeviceInformation``GetDeviceInformation(string userAgent)`<br>Gets device information from cache</li><li>`string GetExtendedProperty(string userAgent, string propertyName)`<br>Gets an extended property from cache</li><li>`AddDeviceInformation(string userAgent and DeviceInformation deviceInfo)`<br>Adds device information to the cache</li><li>`AddExtendedProperty(string userAgent``and string propertyName``and string value)`<br>Adds an extended property to the cache</li></ul> |

</details>

<details>
<summary><h2>Sitecore.CES.DeviceDetection.Configuration</h2></summary>

This namespace contains the class that provides access to the settings of the Device Detection module.

| **Class name** | `DeviceDetectionSettings` |
| --- | --- |
| **Description** | This class provides access to the settings of the Device Detection module. |
| **Properties** | <ul><li>`Enabled`<br>Specifies whether the Device Detection module is enabled.</li><li>`DatabaseUpdateCheckInterval`<br>Specifies how frequently database update checks are performed.</li><li>`FailDatabaseCheckInterval`<br>Specifies how frequently the database tries to reinitialize in the case of an initialize fail.</li><li>`DeviceDetectionCacheSize`<br>Specifies the Device Detection cache size.</li><li>`DeviceDetectionServiceName`<br>Specifies the name of the Device Detection service.</li><li>`DatabasePath`<br>Specifies the path where the device databases are stored.</li></ul> |

</details>

<details>
<summary><h2>Sitecore.CES.DeviceDetection.Data</h2></summary>

This namespace contains the classes for communicating with the Sitecore cloud service.

| **Class name** | `KeyInfo` |
| --- | --- |
| **Description** | This class specifies information about the Device Detection database decryption key. |
| **Properties** | <ul><li>`Key`<br>Specifies the decryption key.</li><li>`RecommendedCacheTimeSpan`<br>Make recommendations for future cache timespans.</li></ul> |

| **Class name** | `UpdateInfo` |
| --- | --- |
| **Description** | This class contains information about database updates. |
| **Properties** | <ul><li>`DatabaseLink`<br>Specifies the link for an encrypted database file.</li><li>`DatabaseVersion`<br>Specifies the database version</li></ul> |

</details>

<details>
<summary><h2>Sitecore.CES.DeviceDetection.Diagnostics.PerformanceCounters</h2></summary>

This namespace contains the Device Detection performance counter classes.

| **Class name** | `DeviceDetectionCount` |
| --- | --- |
| **Description** | This is a static class that provides access to the Device Detection performance counters. |
| **Properties** | <ul><li>`RequestsTotal`<br>Counts the total number of requests for device information</li><li>`CacheHits`<br>Counts the number of cache hits</li><li>`CacheMisses`<br>Counts the number of cache misses</li><li>`AverageResolveTime`<br>Counts the average time it takes to resolve a request to the database.</li></ul> |

</details>

<details>
<summary><h2>Sitecore.CES.DeviceDetection.Diagnostics.Exceptions</h2></summary>

This namespace contains the Device Detection exception class.

| **Class name** | `DeviceDetectionException` |
| --- | --- |
| **Description** | This class represents a Device Detection exception. The API throws this exception when there is either no subscription for the Device Detection service or the provider is not initialized or it is disabled. |

</details>

<details>
<summary><h2>Sitecore.CES.DeviceDetection.Providers.FiftyOneDegrees</h2></summary>

This namespace implements the default provider.

| **Class name** | `DeviceInformationProvider51Degrees` |
| --- | --- |
| **Description** | This class implements the `DeviceInformationProviderBase` and ensures the database is updated. |
| **Methods** | <ul><li>`DeviceInformation GetDeviceInformation(string userAgent)`<br>Checks the license and calls the `GetDeviceInformation` method from the base class</li><li>`DeviceInformation DoGetDeviceInformation(string userAgent)`<br>Gets the information of the device, based on a user agent string from a database.</li><li>`string GetExtendedProperty(string userAgent, string propertyName)`<br>Checks the license and calls the `GetExtendedProperty` method from the base class</li><li>`string DoGetExtendedProperty(string userAgent, string propertyName)`<br>Gets a device property from the device database, in case the device property is not included in `DeviceInformation`</li><li>`Initialize(string name, NameValueCollection config)`<br>Initializes the provider and starts update monitoring</li></ul> |

</details>

<details>
<summary><h2>Sitecore.CES.DeviceDetection.Rules</h2></summary>

This namespace contains the helper interface for the condition classes.

| **Class name** | `IRuleDeviceInformationManager` |
| --- | --- |
| **Description** | This interface is used to get device information for rules. |
| **Methods** | <ul><li>`DeviceInformation GetDeviceInformation(RuleContext ruleContext)`<br>Gets the device information from context.</li><li>`string GetExtendedProperty( RuleContext ruleContext, string propertyName)`<br>Gets the extended property from context.</li></ul> |

</details>

<details>
<summary><h2>Sitecore.CES.DeviceDetection.Rules.Conditions</h2></summary>

This namespace contains the condition classes.

| **Class name** | `DeviceBoolConditionBase` |
| --- | --- |
| **Description** | This is an abstract class for creating rules with Boolean conditions. |
| **Methods** | <ul><li>`bool``Execute(T ruleContext)`<br>Gets information about the device from the `RuleDeviceInformationManager` and calls the `GetDeviceProperty` method</li><li>`bool``GetDeviceProperty(DeviceInformation deviceInformation)`<br>Gets the device's Boolean property</li></ul> |

| **Class name** | `DeviceBrowserCanJavaScriptCondition` |
| --- | --- |
| **Description** | This class implements a rule that checks whether the browser can execute JavaScript. |
| **Method** | <ul><li>`bool``GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `BrowserCanJavaScript` property from Device Information.</li></ul> |

| **Class name** | `DeviceBrowserCondition` |
| --- | --- |
| **Description** | This class implements a rule which specifies if the browser name and version meet the condition. |
| **Method** | <ul><li>`string GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `Browser` property from Device Information.</li></ul> |

| **Class name** | `DeviceBrowserHtml5AudioCanAudioCondition` |
| --- | --- |
| **Description** | This class implements a rule which defines whether the browser can play HTML5 audio. |
| **Method** | <ul><li>`bool``GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `BrowserHtml5AudioCanAudio` property from Device Information.</li></ul> |

| **Class name** | `DeviceBrowserHtml5VideoCanVideoCondition` |
| --- | --- |
| **Description** | This class implements a rule which defines whether the browser can play HTML5 video. |
| **Method** | <ul><li>`bool``GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `BrowserHtml5VideoCanVideo` property from Device Information.</li></ul> |

| **Class name** | `DeviceCanTouchScreenCondition` |
| --- | --- |
| **Description** | This class implements a rule which defines whether the device and browser support touch screen. |
| **Method** | <ul><li>`bool``GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `CanTouchScreen` property from Device Information.</li></ul> |

| **Class name** | `DeviceModelNameCondition` |
| --- | --- |
| **Description** | This class implements a rule which defines whether the browser model name meets the condition. |
| **Method** | <ul><li>`string GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `DeviceModelName` property from Device Information.</li></ul> |

| **Class name** | `DeviceHardwareDisplayHeightCondition` |
| --- | --- |
| **Description** | This class implements a rule which defines whether the device height meets the condition. Note that this does not work correctly for a browser. |
| **Method** | <ul><li>`int GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `HardwareDisplayHeight` property from Device Information.</li></ul> |

| **Class name** | `DeviceHardwareDisplayWidthCondition` |
| --- | --- |
| **Description** | This class implements a rule which defines whether the device width meets the condition. Note that this does not work correctly for a browser. |
| **Method** | <ul><li>`int GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `HardwareDisplayWidth` property from Device Information.</li></ul> |

| **Class name** | `DeviceIntegerConditionBase` |
| --- | --- |
| **Description** | This is an abstract class for creating rules with an integer condition. |
| **Method** | <ul><li>`bool``Execute(T ruleContext)`<br>Gets information about the device from the `RuleDeviceInformationManager` and calls the `GetDeviceProperty` method.</li><li>`int GetDeviceProperty(DeviceInformation deviceInformation)`<br>Gets the device's Integer property.</li></ul> |

| **Class name** | `DeviceOperatingSystemModelCondition` |
| --- | --- |
| **Description** | This class implements a rule which defines whether the device operating system model meets the condition. |
| **Method** | <ul><li>`string GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `DeviceModelName` property from Device Information.</li></ul> |

| **Class name** | `DeviceOperatingSystemVendorCondition` |
| --- | --- |
| **Description** | This class implements a rule which defines whether the vendor of the operating system meets the condition. |
| **Method** | <ul><li>`string GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `DeviceOperatingSystemVendor` property from Device Information.</li></ul> |

| **Class name** | `DevicePropertyCondition` |
| --- | --- |
| **Description** | This class implements a rule which defines whether the extended property meets the condition. |
| **Method** | <ul><li>`bool``Execute(T ruleContext)`<br>Gets the extended property from the `RuleDeviceInformationManager` and compares it with the value of the condition.</li></ul> |
| **Properties** | <ul><li>`Value`<br>The value of the condition</li><li>`PropertyName`<br>The extended property name.</li></ul> |

| **Class name** | `DeviceStringConditionBase` |
| --- | --- |
| **Description** | This is an abstract class that you use to create rules with a String condition. |
| **Method** | <ul><li>`bool``Execute(T ruleContext)`<br>Gets the device information from the `RuleDeviceInformationManager` and calls the `GetDeviceProperty` method.</li><li>`string GetDeviceProperty(DeviceInformation deviceInformation)`<br>Gets the device string property.</li></ul> |
| **Properties** | <ul><li>`Value`<br>The value of the condition.</li></ul> |

| **Class name** | `DeviceTypeCondition` |
| --- | --- |
| **Description** | This class implements a rule that checks whether the device type meets the condition. |
| **Method** | <ul><li>`bool``Execute(T ruleContext)`<br>Gets information about the device from the `RuleDeviceInformationManager` and compares it with the condition value.</li></ul> |
| **Properties** | <ul><li>`Value`<br>The value of the condition.</li></ul> |

| **Class name** | `DeviceVendorCondition` |
| --- | --- |
| **Description** | This class implements a rule that defines whether the device vendor meets the condition. |
| **Method** | <ul><li>`string GetDeviceProperty(DeviceInformation deviceInformation)`<br>Returns the `DeviceVendor` property from `Device Information`</li></ul> |

| **Class name** | `DeviceTypeIds `- *Obsolete*, use `Sitecore.ContentTesting.Rules.Conditions.DeviceTypeIDs` instead. |
| --- | --- |
| **Description** | This class comes from `Sitecore.ContentTesting` and contains the item IDs that corresponds to the device type. |
| **Constants** | <ul><li>`MobilePhone`</li><li>`FeaturePhone`</li><li>`Smartphone`</li><li>`MobileConsole`</li><li>`EReader`</li><li>`Tablet`</li><li>`MediaPlayer`</li><li>`SettopBox`</li><li>`Camera`</li><li>`Bot`</li><li>`WearableComputer`</li><li>`Computer`</li><li>`Other`</li></ul> |

</details>