Precompiled rules for User Agent Parser
ua-parser-builtins provides a precompiled ruleset for the `ua-parser` library, aiming to decrease its initialization times. This package itself does not expose any API; it solely contains the data. The precompiled ruleset is released monthly, synchronized with the `uap-core` project's default branch. The current version is 202603, released March 2026.
Warnings
- gotcha ua-parser-builtins has no direct API or functionality. It is purely a data package designed to be used by the 'ua-parser' library to speed up its initialization. Installing it alone will not provide user agent parsing capabilities.
- gotcha For optimal parsing performance, especially with high-volume user agent strings, consider installing 'ua-parser' with its optional 'regex' or 're2' dependencies. Even with 'ua-parser-builtins' reducing initialization time, the underlying parsing engine within 'ua-parser' affects speed.
- gotcha The versioning scheme for ua-parser-builtins is date-based (YYYYMM). This indicates a refresh of the underlying ruleset, but unlike semantic versioning, it doesn't directly signal API or functionality changes, as the package has no API. Users should be aware that frequent updates reflect new user-agent patterns.
Install
-
pip install ua-parser-builtins -
pip install 'ua-parser[regex]' ua-parser-builtins
Imports
- parse
from ua_parser import parse
Quickstart
from ua_parser import parse
# ua-parser-builtins implicitly provides the data used by parse()
user_agent_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
parsed_ua = parse(user_agent_string)
print(f"User Agent Family: {parsed_ua.user_agent.family}")
print(f"OS: {parsed_ua.os.family} {parsed_ua.os.major}.{parsed_ua.os.minor}")
print(f"Device Family: {parsed_ua.device.family}")