Package 'uaparserjs'

Title: Parse 'User-Agent' Strings
Description: Parses HTTP user agent strings and returns user agent, device and OS information. This is a 'V8'-backed package based on the 'ua-parser' project <https://github.com/ua-parser>.
Authors: Bob Rudis [aut, cph], Greg Hunt [aut, cre, cph], Lindsey Simon [aut] (uap-core), Tobie Langel [aut] (uap-core), Colman Humphrey [ctb], Jim Vine [ctb]
Maintainer: Greg Hunt <[email protected]>
License: Apache License 2.0 | file LICENSE
Version: 0.4.0
Built: 2026-07-03 00:07:04 UTC
Source: https://github.com/cran/uaparserjs

Help Index


Parse a vector of user agents into a data frame

Description

Takes in a character vector of user agent strings and returns a data frame (classed as tibble) of parsed user agent attributes.

Usage

ua_parse(user_agents, .progress = FALSE, useNA=FALSE)

get_cache()

Arguments

user_agents

a character vector of user agents

.progress

if 'TRUE' will display a progress bar in interactive mode

useNA

If 'TRUE' will ensure that for each user agent passed in a parsed result is returned and NA values will be returned for all attributes. The default value is FALSE for compatibility with existing behaviour. TRUE is recommended. When FALSE, NULL or zero length string user agent strings are not parsed and are not returned in the data frame and under some circumstances not all attributes are returned.

Value

a data frame classed as tibble with columns for:

  • user agent string (note that with useNA=TRUE a null string is returned as an NA value not a null)

  • user agent family (ua.family)

  • major & minor versions (ua.major, ua.minor)

  • patch level (ua.patch)

  • OS family (os.family)

  • major & minor OS versions (os.major, os.minor)

  • OS patch (os.patch)

  • device family (device.family)

  • device brand (device.brand) device model (device.model)

The Family values are identified as "Other" for unrecognised or unparseable user agent strings.

When useNA is true and the tibble package is available, an actual tibble is returned.

Note

The regex YAML from uap-core is updated when the package is rebuilt. The date amd abbreviated hash of the last uap-core commit can be found in the NEWS file.

References

<https://github.com/ua-parser/uap-core/>

Examples

ua_parse(paste0("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, ",
                "like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 ",
                "Chrome/15.0.874.106 Safari/535.2", collapse=""))

Parse 'User-Agent' Strings

Description

This package parses HTTP user agent strings and returns user agent, device and OS information. It does this by providing a wrapper around the user agent parser provided by the ua-parser project's Javascript reference parser (<https://github.com/ua-parser>)

Details

The package incorporates regular expressions and test data from the ua parser project that are copyrighted by Google and the UA Parser contributors and are used under an Apache 2 license. See the UA parser project for details.

Author(s)

Bob Rudis (@hrbrmstr) Greg Hunt

See Also

Useful links: