device-detector
Python3 port of matomo's Device Detector
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-detectoruv
uv add device-detectorpoetry
poetry add device-detectorInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
crawlerdetectIdentifies bots, crawlers, and spiders by…
permissive · top 15,000 on PyPI
user-agentsParses browser user agent strings to identify…
permissive · top 5,000 on PyPI
httpagentparserParses HTTP User-Agent strings to extract and…
unclear · top 15,000 on PyPI
ua-parserParses user-agent strings to extract browser,…
permissive · top 1,000 on PyPI
pymobiledetectDetects mobile phones and tablets from HTTP…
agpl · top 15,000 on PyPI
django-user-agentsParses HTTP User-Agent headers in Django to…
permissive · top 15,000 on PyPI
ua-generatorGenerates realistic, randomized user-agent…
permissive · top 5,000 on PyPI
browserforgeGenerates realistic browser headers and device…
permissive · top 5,000 on PyPI
play-scraperScrapes application metadata and listings from…
permissive · top 15,000 on PyPI
Adafruit-PlatformDetectDetects the chip and board type of single-board…
permissive · top 15,000 on PyPI