You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🚀 High-performance, weighted distribution, batch generation User-Agent spoofing library. Supports multiple browsers, devices, realistic probability distribution, dynamic webkit/safari number concatenation, ultimate anti-crawling protection. Perfect for web scraping, automated testing, proxy pools and more.
✨ Key Features
✅ Smart Weighted Distribution: Based on real usage data, mainstream versions/systems/kernels have high weights, niche ones have low weights, realistic probability distribution, extremely difficult to detect by frequency analysis
✅ Optional Meta Information: Can return structured meta information for secondary processing
✅ Extensible Data Pool: All data can be customized and extended, supports weighted distribution
✅ Automated Testing: Full coverage of functionality, performance, and data consistency tests, ensuring robustness
📦 Installation
npm i @imaginerlabs/user-agent-generator
🔧 Quick Start
import{generateUserAgent}from'@imaginerlabs/user-agent-generator';// Generate Chrome + Mac style UAconstua=generateUserAgent({browser: 'chrome',device: 'mac',});console.log(ua);// Example output: Mozilla/5.0 (Macintosh; Intel Mac OS X 14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.91 Safari/537.36// Generate Safari + iPhone style UAconstua2=generateUserAgent({browser: 'safari',device: 'iphone',});console.log(ua2);// Example output: Mozilla/5.0 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1// Generate Firefox + Windows style UAconstua3=generateUserAgent({browser: 'firefox',device: 'windows',});console.log(ua3);// Example output: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0
✅ Batch Generation Example
import{generateUserAgent}from'@imaginerlabs/user-agent-generator';// Generate 3 Chrome + Mac style UAs in batchconstuas=generateUserAgent({browser: 'chrome',device: 'mac',count: 3,});console.log(uas);// Example output:// [// "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.91 Safari/537.36",// "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.92 Safari/537.36",// "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.93 Safari/537.36"// ]
✅ Generation with Meta Information Example
import{generateUserAgent}from'@imaginerlabs/user-agent-generator';// Generate Chrome + Mac UA with meta informationconstresult=generateUserAgent({browser: 'chrome',device: 'mac',withMeta: true,});console.log(result);// Example output:// {// "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.6367.91 Safari/537.36",// "meta": {// "browser": { "name": "chrome", "version": "124.0.6367.91" },// "os": { "name": "macos", "version": "14.4" },// "device": "desktop"// }// }
🧰 API Parameters
Parameter
Type
Required
Default
Description
browser
'chrome' | 'safari' | 'firefox'
No
Random
Specify browser type
device
'mac' | 'windows' | 'iphone' | 'ipad'
No
Random
Specify device type
count
number
No
1
Number of UAs to generate
withMeta
boolean
No
false
Whether to return version numbers and meta info
🔄 Return Types
Scenario
Return Type
Description
Single UA, no meta
string
Returns UA string directly
Single UA, with meta
UserAgentWithMeta
Returns object with ua and meta fields
Multiple UAs, no meta
string[]
Returns array of UA strings
Multiple UAs, with meta
UserAgentWithMeta[]
Returns array of objects with ua and meta
count=0
[]
Returns empty array
UserAgentWithMeta Structure
interfaceUserAgentWithMeta{ua: string;// User Agent stringmeta: {browser: {name: BrowserType;// 'chrome' | 'safari' | 'firefox'version: string;// Browser version number};os: {name: OSType;// 'macos' | 'windows' | 'ios' | 'ipados'version: string;// Operating system version number};device: 'desktop'|'mobile'|'tablet';// Device type};}