This repository has been archived by the owner. It is now read-only.
WURFL Python: Matching user agent strings with devices in the WURFL database using Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


WURFL Python allows matching user agent strings with devices in the WURFL database (Wireless Universal Resource File) using Python. Matching strategies have been directly ported from WURFL PHP library (v1.4.1 at the moment). However, unlike WURFL PHP, WURFL Python focus only on matching user agents with devices in the WURFL database. Specifically,

  • No caching infrastructure is provided, but you can implement it trivially in your application. You know better than me what's the best caching strategy in your scenario.
  • Only 'accuracy' matching mode is provided. You don't need 'performance' mode. No, you don't. What you need is a reasonable caching layer.
  • Facilities for editing or making creative queries on the WURFL database are not provided. Use something else for that. That's out of the scope of this project.

In order to make life easier when syncing with future changes in WURFL PHP, WURFL Python intentionally mimics the implementation of the core matching features in WURFL PHP. If you notice any different behavior between WURFL PHP and WURFL Python, please, post an issue providing some user agent example.

Current reference PHP implementation (1.4.1) is available in extras/wurfl-php.

Closest Python alternative project is pywurfl. Unfortunately, pywurfl has not received maintenance for some years.

Dual Licensing Scheme

As of August 30, 2011, WURFL is licensed under a dual-license model, using the AGPL license for non-commercial use and a proprietary commercial license. The current version of the WURFL database itself is no longer open source.

Due to the new WURFL licence model and the cloud detection service provided by ScientaMobile, future versions of WURFL PHP are not expected. Therefore, future versions of WURFL Python are also not expected. As a consecuence, the number of wrong detections will keep growing as times goes by.

Usage of WURFL (WURFL Python included) is not recommended for new projects. Please, check out alternative open projects like Apache DeviceMap.


  1. Install WURFL Python:

    ~$ pip install wurfl-python
  2. Download the latest version of the WURFL database.

  3. Convert the XML database in a convenient Python module. If you're not interested in all the capabilities in the database, you can reduce the size of the output Python module selecting only those capability groups you are interested in:

    ~$ wurfl-python-processor /path/to/wurfl.xml --group product_info --group display
  4. Copy the generated module into your project and start matching user agents:

    >>> import wurfl
    >>> device = wurfl.match(u'Mozilla/5.0 (iPad; CPU OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B141 [FBAN/FBIOS;FBAV/6.0.1;FBBV/180945;FBDV/iPad3,4;FBMD/iPad;FBSN/iPhone OS;FBSV/6.1;FBSS/2; FBCR/;FBID/tablet;FBLC/zh_TW;FBOP/1]')
    >>> print
    >>> print device.brand_name
    >>> print device.model_name
    >>> device = wurfl.find(u'samsung_gt_i7500_ver1')
    >>> print device.model_name
    GT i7500