Package src :: Package com :: Package deviceatlas :: Package device :: Module device_api :: Class DeviceApi
[frames] | no frames]

Class DeviceApi

Instance Methods
 
__init__(self, config=None)
Constructs a DeviceApi instance with default or an optional custom config.
 
load_data_from_file(self, json_data_file_path)
Load the DeviceAtlas device detection data into the API from a JSON file.
 
load_data_from_string(self, json_data_string)
Load the DeviceAtlas device detection data into the API from a string.
 
get_properties(self, user_agent_or_headers, client_side_properties=None)
Get the properties for a User-Agent or a dictionary of HTTP headers optionally merged with the client side properties (provided by the DeviceAtlas Client-side component).
 
get_property_names(self)
Get a list of all possible property names.
 
get_data_version(self)
Returns the device data (JSON file) version.
 
get_api_version(self)
 
get_data_creation_timestamp(self)
The creation date/time of the loaded data file as a Unix timestamp.
 
get_data_creation_iso8601(self)
The creation date/time of the loaded data file in ISO 8601 format.
Method Details

__init__(self, config=None)
(Constructor)

 

Constructs a DeviceApi instance with default or an optional custom config.

Parameters:
  • config - An instance of Config, you can change the DeviceAtlas API config by creating an instance or Config and setting your custom config values then passing the instance to the DeviceApi constructor.

See Also: You can see the default configs in the class Config.

load_data_from_file(self, json_data_file_path)

 

Load the DeviceAtlas device detection data into the API from a JSON file. The JSON data file is provided from the DeviceAtlas website.

Parameters:
  • json_data_file_path - Path to the JSON data file.
Raises:
  • e - DataFileException

load_data_from_string(self, json_data_string)

 

Load the DeviceAtlas device detection data into the API from a string.

Parameters:
  • json_data_string - JSON data file represented as a string.

get_properties(self, user_agent_or_headers, client_side_properties=None)

 

Get the properties for a User-Agent or a dictionary of HTTP headers optionally merged with the client side properties (provided by the DeviceAtlas Client-side component). The DeviceAtlas Client-side component (JavaScript library) collects the client-side properties and puts them in a cookie. The content of this cookie can be passed to this method. The client properties will override any properties discovered from the main JSON data file.

Parameters:
  • user_agent_or_headers - User-Agent string or a dictionary of HTTP headers.
  • client_side_properties - The content of the cookie containing the client side properties. If None is passed, the API will try to get the cookie from the headers.
Returns:
A dictionary of properties (Property objects) wrapped in a Properties object.

get_property_names(self)

 

Get a list of all possible property names. Note that the client side properties are not included in this list.

Returns:
A list of all possible device property names as PropertyName objects. A PropertyName object holds a property-name and its data-type.

get_data_version(self)

 

Returns the device data (JSON file) version.

Returns:
The version of the data file.

get_data_creation_timestamp(self)

 

The creation date/time of the loaded data file as a Unix timestamp.

Returns:
The creation date/time of this data file as a Unix timestamp.

get_data_creation_iso8601(self)

 

The creation date/time of the loaded data file in ISO 8601 format.

Returns:
The creation date/time of the loaded data file in ISO 8601 format.