• About Us
  • Blog
  • Basket
  • Account
  • Sign In
  •  

Python API

Configuring the Python API

Before start matching User-Agents, you may wish to configure the solution to use a different database for example. You can easily generate a sample settings file by running the following command

$ 51degrees-mobile-detector settings > ~/51degrees-mobile-detector.settings.py

Edit the generated settings setting your preferences. Ensure you set DETECTION_METHOD and V3_WRAPPER_DATABASE, or TRIE_V3_WRAPPER_DATABASE (if using the trie-based detection method).

Finally, link your settings file from the FIFTYONE_DEGREES_MOBILE_DETECTOR_SETTINGS environment variable

$ export FIFTYONE_DEGREES_MOBILE_DETECTOR_SETTINGS=~/51degrees-mobile-detector.settings.py

This can be permanently set by adding this line to your ~/.profile file.

Setting Default Description
General Settings
DETECTION_METHOD 'v3-wrapper' Sets the preferred mobile device detection method. Available options are v3-wrapper (requires 51degrees-mobile-detector-v3-wrapper package), v3-trie-wrapper (requires 51degrees-mobile-detector-v3-trie-wrapper package).
PROPERTIES '' List of case-sensitive property names to be fetched on every device detection. Leave empty to fetch all available properties.
LICENSE '' Your 51Degrees license key. This is required if you want to set up the automatic 51degrees-mobile-detector-premium-pattern-wrapper package updates.
Trie Detector Settings
V3_TRIE_WRAPPER_DATABASE os.path.expanduser('~/51Degrees/51Degrees-LiteV3.2.trie') Location of the Trie database file.
Pattern Detector Settings
V3_WRAPPER_DATABASE os.path.expanduser('~/51Degrees/51Degrees-LiteV3.2.dat') Location of the Pattern database file.
CACHE_SIZE 10000 Sets the size of the workset cache.
POOL_SIZE 20 Sets the size of the workset pool.
USAGE_SHARER_ENABLED True Indicates if usage data should be shared with 51Degrees.com. We recommended leaving this value unchanged to ensure we're improving the performance and accuracy of the solution.

Adavanced usage sharer settings are detailed in your settings file.