Skip to main content

wmclient - WURFL Microservice Client for Python

Differences between version 2.2.0 and previous ones.

Version 2.2.0 makes WURFL microservice client backward compatible with Python 2.7. To do that it replaces two libraries that are available for Python 3.x only:

  • pywurfl (replaced by urrllib3)
  • @lru_cache (replaced by pylru)

While in older versions cache was used by default, in this version you'll have to use the set_cache_size function of the client to ensure it is created and used.

Python WURFL Microservice Client

WURFL Microservice (by ScientiaMobile, Inc.) is a mobile device detection service that can quickly and accurately detect over 500 capabilities of visiting devices. It can differentiate between portable mobile devices, desktop devices, SmartTVs and any other types of devices that have a web browser.

This is the Python Client API for accessing the WURFL Microservice. The API is released under Open-Source and can be integrated with other open-source or proprietary code. In order to operate, it requires access to a running instance of the WURFL Microservice product, such as:

Python implementation of the WM Client api. Requires:

  • Python 3.x
  • pip
  • pycurl module (you can install it with pip install pycurl)
  • requests module (you can install it with pip install requests)
  • pylru module (you can install it with pip install pylru)

The Example project contains an example of client api usage for a script :

from wmclient import *
from requests import Request as HttpRequest

try:
    client = WmClient.create("http", "localhost", 8080, "")

    info = client.get_info()
    print("Printing WM server information")
    print("WURFL API version: " + info.wurfl_api_version)
    print("WM server version:  " + info.wm_version)
    print("Wurfl file info: " + info.wurfl_info)

    ua = "Mozilla/5.0 (Linux; Android 7.1.1; ONEPLUS A5000 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) " \
         "Chrome/56.0.2924.87 Mobile Safari/537.36 "

    req_headers = {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "en-US,en;q=0.9",
        "Referer": "http://itvv.net/",
        "User-Agent": "Mozilla/5.0 (Linux; U; Android 7.1.1; XT1635-02 Build/NPN26.107; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.127 Mobile Safari/537.36 OPR/51.0.2254.150807",
        "X-Forwarded-For": "157.32.186.226",
        "X-Requested-With": "com.opera.mini.native"
    }
    req = HttpRequest('GET', "http://mywebsite.com", headers=req_headers)

    client.set_requested_static_capabilities(["brand_name", "model_name"])
    client.set_requested_virtual_capabilities(["is_smartphone", "form_factor"])
    print()
    print("Detecting device for user-agent: " + ua)

    # Perform a device detection calling WM server API
    device = client.lookup_request(req)

    if device.error is not None and len(device.error) > 0:
        print("An error occurred: " + device.error)
    else:
        # Let's get the device capabilities and print some of them
        capabilities = device.capabilities
        print("Detected device WURFL ID: " + capabilities["wurfl_id"])
        print("Device brand & model: " + capabilities["brand_name"] + " " + capabilities["model_name"])
        print("Detected device form factor: " + capabilities["form_factor"])
        if capabilities["is_smartphone"] == "true":
            print("This is a smartphone")
            # Iterate over all the device capabilities and print them
            print("All received capabilities");
            for k in capabilities:
                print(k + ": " + capabilities[k])

            # Get all the device manufacturers, and print the first twenty
            print()
            limit = 20
            deviceMakes = client.get_all_device_makes()
            print("Print the first {} Brand of {} retrieved from server\n".format(limit, len(deviceMakes)))

            # Sort the device manufacturer names
            list.sort(deviceMakes)
            for i in range(limit):
                print(" - {}\n".format(deviceMakes[i]))

            # Now call the WM server to get all device model and marketing names produced by Apple
            print("Print all Model for the Apple Brand")
            devNames = client.get_all_devices_for_make("Apple")

            for model_mkt_name in devNames:
                print(" - {} {}\n".format(model_mkt_name.brand_name, model_mkt_name.model_name))

            # Now call the WM server to get all operative system names
            print("Print the list of OSes")
            oses = client.get_all_OSes()
            # Sort and print all OS names
            list.sort(oses)
            for os in oses:
                print(" - {}\n".format(os))

            # Let's call the WM server to get all version of the Android OS
            print("Print all versions for the Android OS")
            osVersions = client.get_all_versions_for_OS("Android")
            # Sort all Android version numbers and print them.
            list.sort(osVersions)
            for ver in osVersions:
                print(" - {}\n".format(ver))

except WmClientError as wme:
    # problems such as network errors  or internal server problems
    print("An error has occurred: " + wme.message)

Metadata

Release files for wmclient 2.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wmclient 2.3.2
File Size Uploaded Provenance Actions
wmclient-2.3.2.tar.gz 14.6 kB Without provenance Details for wmclient-2.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wmclient 2.3.2
File Interpreter ABI Platform Actions
wmclient-2.3.2-py3-none-any.whl Python 3 none any Details for wmclient-2.3.2-py3-none-any.whl

Total release size: 34.6 kB

Release files / wmclient-2.3.2.tar.gz

Download URL wmclient-2.3.2.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
936e26f780d9ec1f5a735894a682c3101739b240dfcb76efaa392ba5951cf14f
BLAKE2b-256 checksum
How to use checksums
8842c5fb74a140bd6a659e17fb1ee165c6599f87b166be33252d01ff376222b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / wmclient-2.3.2-py3-none-any.whl

Download URL wmclient-2.3.2-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e144aff8ea52c29908788fbc3155b4643061346f5e40253ba6eb9bab7c4cceb5
BLAKE2b-256 checksum
How to use checksums
0d2f9a9ca7260d24ed5261effaae7046051fe969540730fa37ca81ad07dc0f03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for wmclient 2.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page