DeviceDetector

6.2.0 · active · verified Thu Apr 16

DeviceDetector is a precise and fast user agent parser and device detector for Python, backed by a large and frequently updated user agent database. It parses any user agent string to detect the browser, operating system, device used (desktop, tablet, mobile, TV, etc.), brand, and model. Optimized for speed through efficient code and in-memory caching, the library is currently at version 6.2.0 and maintains an active release cadence, primarily updating to incorporate upstream detection rules from the Matomo project.

Common errors

Warnings

Install

Imports

Quickstart

Initializes `DeviceDetector` with a user agent string, parses it, and demonstrates how to access various detected properties like OS, device type, brand, and browser.

from device_detector import DeviceDetector

# Example User Agent string
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'

# Initialize and parse the User Agent
device = DeviceDetector(ua).parse()

# Access detected information
print(f"Is bot: {device.is_bot()}")
print(f"OS name: {device.os_name()}")
print(f"OS version: {device.os_version()}")
print(f"Device type: {device.device_type()}")
print(f"Device brand: {device.device_brand()}")
print(f"Device model: {device.device_model()}")
print(f"Browser name: {device.client_name()}")
print(f"Browser version: {device.client_version()}")

view raw JSON →