# random-useragent

> Get a random useragent (with an optional filter)

Latest version **0.5.0** (published 2020-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install random-useragent
pnpm add random-useragent
yarn add random-useragent
bun add random-useragent
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2020-09-03 |
| First published | 2014-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/random-useragent) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 495.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 257 |
| Author | skratchdot |
| Maintainers | skratchdot |
| Keywords | random, useragent, user-agent, user, agent, data, web, developer |

## Links

- npm: https://www.npmjs.com/package/random-useragent
- Repository: https://github.com/skratchdot/random-useragent
- Issues: https://github.com/skratchdot/random-useragent/issues
- npm.io page: https://npm.io/package/random-useragent

## Dependencies (1)

- [random-seed](https://npm.io/package/random-seed.md) ^0.3.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2020-09-03
- 0.4.0 — 2020-08-07
- 0.3.1 — 2016-10-15
- 0.3.0 — 2016-04-18
- 0.2.1 — 2015-11-30
- 0.2.0 — 2015-11-30
- 0.1.1 — 2015-04-24
- 0.1.0 — 2014-06-04

## README

# random-useragent

[![NPM version](https://badge.fury.io/js/random-useragent.svg)](http://badge.fury.io/js/random-useragent)
[![Build Status](https://travis-ci.org/skratchdot/random-useragent.png?branch=master)](https://travis-ci.org/skratchdot/random-useragent)
[![Code Climate](https://codeclimate.com/github/skratchdot/random-useragent.png)](https://codeclimate.com/github/skratchdot/random-useragent)
[![Coverage Status](https://coveralls.io/repos/skratchdot/random-useragent/badge.svg?branch=master&service=github)](https://coveralls.io/github/skratchdot/random-useragent?branch=master)
[![Dependency Status](https://david-dm.org/skratchdot/random-useragent.svg)](https://david-dm.org/skratchdot/random-useragent)
[![devDependency Status](https://david-dm.org/skratchdot/random-useragent/dev-status.svg)](https://david-dm.org/skratchdot/random-useragent#info=devDependencies)

[![NPM](https://nodei.co/npm/random-useragent.png)](https://npmjs.org/package/random-useragent)


## 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`

```javascript
const randomUseragent = require('random-useragent');
randomUseragent.getRandom(); // gets a random user agent string
```

- [Live example on Tonic](https://tonicdev.com/npm/random-useragent)


## Documentation

#### .getRandom(filter)

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

Example Result:
```javascript
'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:
```javascript
{
	"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:
```javascript
randomUseragent.getRandom();
```

Get a random Firefox user agent string:
```javascript
randomUseragent.getRandom(function (ua) {
	return ua.browserName === 'Firefox';
});
```

Get a random user agent with a version >= 20:
```javascript
randomUseragent.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](http://chrispederick.com/work/user-agent-switcher/),
which is located here:

- [Forum Post](http://techpatterns.com/forums/about304.html)
- [Direct Link](http://techpatterns.com/downloads/firefox/useragentswitcher.xml)


## Links

- [Source Code](https://github.com/skratchdot/random-useragent)
- [Changelog](https://github.com/skratchdot/random-useragent/blob/master/CHANGELOG.md)
- [Live example on Tonic](https://tonicdev.com/npm/random-useragent)


## License

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

---
_Source: https://npm.io/package/random-useragent · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
