Registry / testing / user-agent

user-agent

JSON →
library0.1.14pypiunverified

The user-agent library (version 0.1.14) is a Python module designed for generating random, valid User-Agent HTTP headers and `window.navigator` JavaScript objects. It's particularly useful for web scraping or testing scenarios where mimicking various browser and device user agents is required. The library is currently in a beta development status, with its last update on September 10, 2025.

pip install user-agent
INSTALL
IMPORT
SIG · USER-AGENT
U
user-agent
testingenv0.1.14
Install
1.8s avg
Import
39ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.1.14 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.041s · 20.9MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 1.8s · import 0.036s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

generate_user_agent
✓ from user_agent import generate_user_agent
generate_navigator
✓ from user_agent import generate_navigator

This quickstart demonstrates how to generate random user agent strings and navigator objects using `generate_user_agent` and `generate_navigator` functions. It also shows how to filter generation by operating system or navigator type.

from user_agent import generate_user_agent, generate_navigator # Generate a random user agent string random_ua = generate_user_agent() print(f"Generated User-Agent: {random_ua}") # Generate a navigator object (dictionary) navigator_obj = generate_navigator() print(f"Generated Navigator Object: {navigator_obj}") # Example of generating a user agent for a specific OS/browser mac_firefox_ua = generate_user_agent(os=('mac',), navigator='firefox') print(f"Mac Firefox User-Agent: {mac_firefox_ua}")
Debug
Known issues
betaThe library is currently in 'Development Status :: 4 - Beta', which means its API might not be entirely stable and could undergo changes in future releases. It may not be fully production-ready for critical applications.
fix
Review the project's PyPI page and any potential GitHub repository for updates on stability and breaking changes. Consider locking the dependency version tightly.
affects: <=0.1.14
gotchaThis library is solely for *generating* user agent strings and navigator objects, not for *parsing* an existing user agent string to extract browser, OS, or device information. Attempting to use its functions for parsing will not work. For parsing, consider libraries like `user-agents` (plural) or `ua-parser`.
fix
Ensure you use the correct library for your task: `user-agent` for generation, `user-agents` or `ua-parser` for parsing.
affects: All
gotchaWhile the package's metadata indicates compatibility with `Python >=2.7`, Python 2.7 has reached its End-of-Life. Using this library in environments that rely on Python 2.7 might introduce compatibility issues or security vulnerabilities in modern projects. It's recommended to use it with Python 3.x.
fix
Ensure your project runs on Python 3.x. If Python 2.7 is a hard requirement, be aware of the associated risks.
affects: All
gotchaThe `generate_user_agent()` function produces valid, random user agents, but there is no explicit mechanism documented on its PyPI page to ensure these are always the *latest* or most current browser versions. Websites frequently update their anti-bot measures, and using outdated user agents can lead to requests being blocked or flagged.
fix
For applications requiring highly current user agents (e.g., intensive web scraping), consider combining this library with a regularly updated list of user agents or using libraries like `fake-useragent` that specialize in keeping their user agent database up-to-date.
affects: All
gotchaA common mistake in web scraping is to generate a single user-agent string and reuse it for all requests. Even a realistic user-agent will eventually get flagged if it makes too many requests from the same IP address in a short period, signaling automated behavior.
fix
Implement a user-agent rotation strategy by calling `generate_user_agent()` for each request or regularly rotating from a list of generated user agents.
affects: All
Upgrade
Version history
0.1.14latest on PyPI · released Sep 10, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources

No resource links recorded.

user-agent — pip install user-agent · libregistry