Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

random-useragent

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-useragent

Get a random useragent (with an optional filter)

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
55K
increased by1.13%
Maintainers
1
Weekly downloads
 
Created
Source

random-useragent

NPM version Build Status Code Climate Coverage Status Dependency Status devDependency Status

NPM

Description

Get a random user agent (with an optional filter to select from a specific set of user agents).

Getting Started

Install the module with: npm install random-useragent

var random_useragent = require('random-useragent');
random_useragent.getRandom(); // gets a random user agent string

Documentation

.getRandom(filter)

Get a random user agent string (optionally using a filter).

Example Result:

'Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/20.0'
.getRandomData(filter)

Get a random user agent's parsed data (optionally using a filter).

Example Result:

{
	"folder": "/Browsers - Windows/Legacy Browsers",
	"description": "Firefox 20.0 (Win 8 32)",
	"userAgent": "Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/20.0",
	"appCodename": "",
	"appName": "",
	"appVersion": "",
	"platform": "",
	"vendor": "",
	"vendorSub": "",
	"browserName": "Firefox",
	"browserMajor": "20",
	"browserVersion": "20.0",
	"deviceModel": "",
	"deviceType": "",
	"deviceVendor": "",
	"engineName": "Gecko",
	"engineVersion": "20.0",
	"osName": "Windows",
	"osVersion": "8",
	"cpuArchitecture": ""
}
.getAll(filter)

Get an array of all the user agent strings (optionally using a filter).

.getAllData(filter)

Get an array of all the parsed user agent data (optionally using a filter).

Examples

Get a random user agent string:

random_useragent.getRandom();

Get a random Firefox user agent string:

random_useragent.getRandom(function (ua) {
	return ua.browserName === 'Firefox';
});

Get a random user agent with a version >= 20:

random_useragent.getRandom(function (ua) {
	return parseFloat(ua.browserVersion) >= 20;
});

Source Of User Agents

The collection of user agents is pulled from the large, regularly updated xml file provided by the author of User Agent Switcher, which is located here:

Release History

Version 0.1.0 (Released June 4, 2014)
  • initial release

License

Copyright (c) 2014 skratchdot
Licensed under the MIT license.

Keywords

FAQs

Package last updated on 30 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc