Registry / http-networking / httpagentparser

httpagentparser

JSON →
library1.9.9pypypi✓ verified 84d ago

httpagentparser is a Python library (current version 1.9.9) that efficiently extracts operating system, browser, and other relevant information from HTTP User-Agent strings. It offers fast parsing and is primarily focused on detecting OS and browser details rather than being a full-featured agent parser. Releases are infrequent but have recently addressed maintenance and optimization.

pip install httpagentparser
INSTALL
IMPORT
SIG · HTTPAGENTPARSER
H
httpagentparser
http-networkingpythonv1.9.9
Install
1.5s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.9.9 · 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.103.920 runs
installs and imports cleanly · install 0.0s · import 0.002s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

httpagentparser
import httpagentparser

This quickstart demonstrates how to use `httpagentparser` to detect operating system and browser information from a user-agent string. It shows both the `simple_detect` method for a concise tuple output and the `detect` method for a more detailed dictionary result, including how to access specific fields like OS name and browser version.

import httpagentparser # Example user agent string user_agent_string = "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.307.11 Safari/532.9" # Basic detection returning (OS, Browser) tuple simple_result = httpagentparser.simple_detect(user_agent_string) print(f"Simple Detection (OS, Browser): {simple_result}") # Detailed detection returning a dictionary detailed_result = httpagentparser.detect(user_agent_string) print(f"Detailed Detection: {detailed_result}") # Accessing specific parts of the detailed result if detailed_result.get('os'): print(f"OS Name: {detailed_result['os'].get('name')}") if detailed_result.get('browser'): print(f"Browser Name: {detailed_result['browser'].get('name')}") print(f"Browser Version: {detailed_result['browser'].get('version')}") # Example with a mobile user agent mobile_ua = "Mozilla/5.0 (Linux; U; Android 2.3.5; en-in; HTC_DesireS_S510e Build/GRJ90) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1" mobile_result = httpagentparser.detect(mobile_ua) print(f"\nMobile User Agent Detailed Detection: {mobile_result}") if mobile_result.get('dist'): print(f"Mobile OS Distribution: {mobile_result['dist'].get('name')} {mobile_result['dist'].get('version')}")
Debug
Known issues
gotchaThe `detect()` method returns a standard Python dictionary. The order of keys in dictionaries is not guaranteed across Python versions or runs, which can lead to unexpected output order if you rely on it for consistent string representation or comparison.
fix
If a predictable order is required (e.g., for logging or consistent output), process the dictionary by sorting its items before representation: `OrderedDict(sorted(httpagentparser.detect(s).items()))` (requires `collections.OrderedDict`).
affects: All versions
gotchaThe library explicitly states it 'Does not aim to be a full featured agent parser.' It is optimized for fast OS and browser detection but may not provide granular device details, comprehensive bot detection, or cover all obscure user-agent strings as thoroughly as more extensive or commercial solutions.
fix
For highly granular device information, extensive bot detection, or parsing very obscure/malformed user-agent strings, consider alternative libraries like `ua-parser` or commercial services.
affects: All versions
gotchaOlder versions (e.g., 1.9.5) sometimes encountered `setup.py egg_info` errors during installation in certain environments, often related to setuptools packaging issues.
fix
Ensure you are using the latest version of `httpagentparser` (1.9.9+) and `pip` and `setuptools` are up-to-date, as recent updates aimed to 'Modernize setup' and 'Remove deprecated setuptools-tox integration.'
affects: <1.9.9
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'httpagentparser'
The 'httpagentparser' library has not been installed in the current Python environment.
fix
Install the library using pip: `pip install httpagentparser`
× python setup.py egg_info did not run successfully.
This error occurs during installation when pip attempts to build package metadata, often due to an outdated pip, setuptools, or an issue with the build environment.
fix
Upgrade pip and setuptools, then retry the installation: `python -m pip install --upgrade pip setuptools` followed by `pip install httpagentparser`
Nokia Lumia 920's OS system is recognised as Android..
The library's internal detection patterns are outdated or lack specific rules for certain user-agent strings, leading to misidentification of the operating system, browser, or device.
fix
Upgrade the library to the latest version (`pip install --upgrade httpagentparser`) to get updated detection patterns, or report the specific user-agent string as an issue on the library's GitHub page if the problem persists.
Upgrade
Version history
1.9.9latest on PyPI · released Mar 8, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
Resources
httpagentparser — pip install httpagentparser · libregistry