skillfed

device-detector

Python3 port of matomo's Device Detector

device-detector v6.4.0 251.6K downloads/30d#8,576 on PyPI148
License unclear Active released

What it is and what it does

DeviceDetector is a Python user agent parser that identifies browsers, operating systems, device types (desktop, mobile, tablet, TV, console, etc.), and hardware brands and models from HTTP user agent strings and client hints. It is a port of the Matomo Universal Device Detection library and uses the same regex YAML database, so it benefits from updates to the original project. The package is optimized for speed through in-memory caching and provides both a full DeviceDetector class for comprehensive detection and a lighter SoftwareDetector class for OS and browser extraction only.

The package depends on ahocorasick-rs, regex, yaml-rs, backports.strenum, and typing_extensions. It supports Python 3.10 and later and is actively maintained with recent releases. The main caveat is that the license treatment is unclear—no SPDX identifier or license text is declared in the package metadata.

Use it for:

  • Classify incoming HTTP requests by device type to serve responsive or device-specific content.
  • Detect bot traffic using the is_bot() method to filter automated requests from analytics or logs.
  • Extract browser and OS details from user agent strings for analytics, logging, or compatibility checks.
  • Parse client hints headers to identify the application or browser making requests, especially for mobile apps.
  • Build device-aware feature flags or A/B tests by detecting hardware brand, model, or OS version.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses user agent strings and client hints to detect the browser, operating system, device type, brand, and model of client requests.

Yes, with a caveat on license clarity. The package is actively maintained, has low install friction, supports Python 3.10–3.14, and solves a real problem. However, verify the actual license in the repository before use in proprietary or restricted-license contexts, since the package metadata declares no license.

Install

device-detector on PyPI

pip

pip install device-detector

uv

uv add device-detector

poetry

poetry add device-detector

Installing device-detector

Before you install

Low install friction with a pure-Python wheel distribution. Actively maintained with a recent release and steady commit activity. Supports Python 3.10 through 3.14.

License in practice

License status is unclear; the package declares no SPDX identifier or raw license text in its metadata. Verify the actual license terms in the repository before use in proprietary or restricted contexts.

Quickstart

from device_detector import DeviceDetector

ua = 'Mozilla/5.0 (Linux; Android 4.3; C5502 Build/10.4.1.B.0.101) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.136 Mobile Safari/537.36'
device = DeviceDetector(ua).parse()
print(device.device_brand())  # Sony
print(device.device_type())   # smartphone

Verify before relying

  • Whether the package's actual license (if any) is permissive or restrictive—metadata shows no license declaration.
  • Performance characteristics and detection accuracy compared to the original Matomo library.
  • Whether the in-memory caching mentioned in the description is configurable or automatic.

Package facts

License not declared (unclear)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 5 — ahocorasick-rs, regex, yaml-rs, backports.strenum, typing_extensions
Maintenance actively maintained — 3 days since the last release
Last repo commit
First released
Downloads 251,566/month — #8,576 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: device_detector-6.4.0-py3-none-any.whl

Keywords: user agent, app detection, device detection, client hints

Environment :: Web EnvironmentIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: Internet :: WWW/HTTPTopic :: Software Development :: Libraries :: Python Modules

Tags

user agent parserdevice detectionbrowser detectionclient hints parsingdevice type classifiermobile vs desktop detectionoperating system detection
user-agent-parsingdevice-classification

More Python Modules packages