user-agents
A library to identify devices (phones, tablets) and their capabilities by parsing browser user agent strings.
What it is and what it does
user-agents is a Python library that wraps ua-parser to parse HTTP user agent strings and classify the requesting device. It identifies whether a user agent belongs to a mobile phone, tablet, or desktop PC; detects touch capabilities; and extracts structured information about the browser family, OS, device brand, and model. The library exposes convenience methods like is_mobile, is_tablet, is_pc, is_touch_capable, and is_bot to make device detection straightforward in web applications.
The package relies entirely on ua-parser to do the actual parsing work and maintains a thin, user-friendly API on top. It has been stable since its 2.0 release in 2019 and is classified as Production/Stable, but development has stalled—the last update was in August 2020, and the repository shows no activity since February 2023. This means the underlying device and browser database will become increasingly outdated as new devices and user agent formats emerge.
Use it for:
- Serve mobile-optimized content or layouts based on device type detection in web frameworks.
- Block or flag bot traffic by identifying search engine crawlers and spiders in request logs.
- Customize user experience by detecting touch-capable devices and enabling touch-friendly interactions.
- Log and analyze visitor device demographics (mobile vs. tablet vs. desktop) for analytics.
- Implement device-specific feature flags or API responses in REST or GraphQL backends.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses browser user agent strings to identify device type (mobile, tablet, PC), detect touch capabilities, and extract browser and OS information.
Yes, with conditions. Install if you need straightforward user agent parsing for a stable, mature codebase and can tolerate outdated device/browser data. The low install friction, permissive MIT license, and zero known vulnerabilities make it safe to add. However, do not install if you require current detection of recent devices, browsers, or user agent formats—the package is abandoned and will not track new user agents. For new projects, evaluate whether ua-parser alone or a more actively maintained alternative better suits your needs.
Install
user-agents on PyPI
pip
pip install user-agentsuv
uv add user-agentspoetry
poetry add user-agentsInstalling user-agents
Before you install
Low install friction with a single runtime dependency (ua-parser). However, the package is abandoned—last release was 2020-08-23 and last commit 2023-02-16—so it will not receive bug fixes or updates for newer user agents or Python versions.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions. You may use, modify, and distribute this package freely as long as you include the original license notice.
Quickstart
pip install user-agents
from user_agents import parse
ua_string = 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46'
user_agent = parse(ua_string)
print(user_agent.is_mobile) # True
print(user_agent.device.family) # 'iPhone'
Verify before relying
- Whether ua-parser's bundled device database is current enough for modern user agents (package has not been updated since 2020).
- Compatibility with Python versions beyond 3.8 (classifiers only list up to 3.8; no explicit support statement for newer versions).
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — ua-parser |
| Maintenance | abandoned — 2,182 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 11,641,606/month — #1,374 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: user_agents-2.2.0-py3-none-any.whl
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
device-detectorParses user agent strings and client hints to…
unclear · top 15,000 on PyPI
django-user-agentsParses HTTP User-Agent headers in Django to…
permissive · top 15,000 on PyPI
pymobiledetectDetects mobile phones and tablets from HTTP…
agpl · top 15,000 on PyPI
ua-parserParses user-agent strings to extract browser,…
permissive · top 1,000 on PyPI
wootheeWoothee parses user-agent strings to identify…
permissive · top 15,000 on PyPI
crawlerdetectIdentifies bots, crawlers, and spiders by…
permissive · top 15,000 on PyPI
ua-parser-rsProvides a Rust-accelerated user-agent parser…
permissive · top 5,000 on PyPI
httpagentparserParses HTTP User-Agent strings to extract and…
unclear · top 15,000 on PyPI
python-fullykioskProvides a Python interface to the Fully Kiosk…
permissive · top 15,000 on PyPI
fake-useragentGenerates random or browser-specific user-agent…
permissive · top 5,000 on PyPI