### Example User Agent String for Minimo Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/minimo.md This is an example of a user agent string that would be parsed to identify the Minimo browser. No specific setup is required to use this example. ```sh Mozilla/5.0 (X11; U; Linux armv6l; rv 1.8.1.5pre) Gecko/20070619 Minimo/0.020 ``` -------------------------------- ### GoBrowser Example Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/go.md Example of a user agent string for NokiaE66 with GoBrowser. ```APIDOC ## GoBrowser User Agent Example ### Description This example shows a user agent string identifying the NokiaE66 device running the GoBrowser. ### Request Example ```sh NokiaE66/GoBrowser/2.0.297 ``` ``` -------------------------------- ### Server-side Example: Parsing Client Hints Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/idata/with-client-hints.md Example of how to parse both the User-Agent string and Client Hints headers in a Node.js server environment. ```javascript const request = { headers : { 'user-agent' : 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36', 'sec-ch-ua-mobile' : '?1', 'sec-ch-ua-model' : 'Galaxy S3 Marketing', 'sec-ch-ua-platform' : 'Android' } }; // Parse only 'user-agent' header const result1 = UAParser(request.headers); console.log(result1.os.name); // "Linux" console.log(result1.device.type); // undefined console.log(result1.device.model); // undefined // Parse 'user-agent' and Client Hints headers const result2 = UAParser(request.headers).withClientHints(); console.log(result2.os.name); // "Android" console.log(result2.device.type); // "mobile" console.log(result2.device.model); // "Galaxy S3 Marketing" // Chaining with getBrowser() new UAParser(request.headers) .getBrowser() .withClientHints() .then((browser) => { console.log(browser.toString()); // Chrome 110.0.0.0 }); // Example using Node.js http server const http = require('http'); const uap = require('ua-parser-js'); http.createServer(function (req, res) { const getHighEntropyValues = 'Sec-CH-UA-Full-Version-List, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Form-Factors'; res.setHeader('Accept-CH', getHighEntropyValues); res.setHeader('Critical-CH', getHighEntropyValues); const result = uap(req.headers).withClientHints(); res.end(JSON.stringify(result, null, ' ')); }) .listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); ``` -------------------------------- ### Install UAParser.js Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/intro/quick-start/using-es-modules-typescript.md Install the UAParser.js library using npm. TypeScript definitions are included. ```sh npm install ua-parser-js ``` -------------------------------- ### Solaris User Agent Example Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/mosaic.md Example of a user agent string from Solaris, used for browser identification. ```sh NCSA_Mosaic/2.6 (X11; SunOS 4.1.3 sun4m) ``` -------------------------------- ### UAParser Code Examples Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/overview.md Practical examples demonstrating the usage of UAParser for version checking, custom browser parsing, and custom device parsing. ```APIDOC ### Code Example ```js [example-version.js] const UAParser = require('ua-parser-js'); console.log(`Current library version: ${UAParser.VERSION}`); ``` ```js [example-browser.js] const myOwnListOfBrowsers = [ [/(mybrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION] ]; const myUA = 'Mozilla/5.0 MyBrowser/1.3'; const myParser = new UAParser({ browser: myOwnListOfBrowsers }); console.log(myParser.setUA(myUA).getBrowser()); // {name: "MyBrowser", version: "1.3", major: "1"} ``` ```js [example-custom-device.js] const myOwnList = [ [/(mytab) ([\w ]+)/i], [UAParser.DEVICE.VENDOR, UAParser.DEVICE.MODEL, [UAParser.DEVICE.TYPE, UAParser.DEVICE.TABLET]] ]; const myUA = 'Mozilla/5.0 MyTab 14 Pro Max'; const myParser = new UAParser({ device: myOwnList }); console.log(myParser.setUA(myUA).getDevice()); // {vendor: "MyTab", model: "14 Pro Max", type: "tablet"} ``` ``` -------------------------------- ### Windows User Agent String Example Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/dragon.md Example of a user agent string for the Dragon browser on Windows. ```sh Mozilla/5.0 (Windows NT 6.2) AppleWebKit/535.7 (KHTML, like Gecko) Comodo_Dragon/16.1.1.0 Chrome/16.0.912.63 Safari/535.7 ``` -------------------------------- ### Rekonq Browser User Agent Example (Linux) Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/rekonq.md This snippet shows an example of a Rekonq user agent string found on Linux systems. ```APIDOC ## Rekonq Browser User Agent Example (Linux) ### Description This example demonstrates a typical user agent string for the Rekonq browser when running on a Linux operating system. ### Method N/A (This is an example string, not an API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example ``` Mozilla/5.0 (X11; U; Linux x86_64; cs-CZ) AppleWebKit/533.3 (KHTML, like Gecko) rekonq Safari/533.3 ``` ### Response N/A (This is an example string, not an API response) ``` -------------------------------- ### Get Browser Name - Chromium on Linux Example Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/chromium.md This snippet demonstrates a user agent string for Chromium running on Linux and how it relates to the IBrowser.name property. ```APIDOC ## IBrowser.name - Chromium on Linux ### Description This section shows an example user agent string for Chromium on Linux and its corresponding browser name. ### Method N/A (This is an example of a user agent string) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **name** (string) - The name of the browser, e.g., "Chromium" #### Response Example ```json { "name": "Chromium" } ``` ### User Agent String Example ```sh Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, like Gecko) Ubuntu/11.10 Chromium/16.0.912.21 Chrome/16.0.912.21 Safari/535.7 ``` ``` -------------------------------- ### IE Mobile User Agent Example Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/iemobile.md Example of an IE Mobile user agent string and how it might be parsed. ```APIDOC ## IE Mobile User Agent Parsing ### Description This section demonstrates parsing a typical user agent string for IE Mobile. ### Method GET (or relevant method for parsing) ### Endpoint /parse ### Parameters #### Query Parameters - **userAgent** (string) - Required - The user agent string to parse. ### Request Example ```json { "userAgent": "Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 7.11) 320x240; VZW; Motorola-Q9c; Windows Mobile 6.1 Standard" } ``` ### Response #### Success Response (200) - **browser** (object) - Information about the browser. - **name** (string) - The name of the browser (e.g., "IE Mobile"). - **os** (object) - Information about the operating system. - **device** (object) - Information about the device. #### Response Example ```json { "browser": { "name": "IE Mobile", "version": "7.11" }, "os": { "name": "Windows CE", "version": "6.1 Standard" }, "device": { "name": "Motorola-Q9c", "vendor": "Motorola", "model": "Q9c" } } ``` ``` -------------------------------- ### Example User Agent String for Klar Browser Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/klar.md This is an example of a user agent string that would be identified as the Klar browser, specifically for versions prior to 4.1. ```text # Klar < 4.1 Mozilla/5.0 (Linux; Android 7.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Klar/1.0 Chrome/58.0.3029.83 Mobile Safari/537.36 ``` -------------------------------- ### Example User Agent String for Bolt on Linux Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/bolt.md This is an example of a user agent string from the Bolt browser on a Linux operating system. It can be used for testing or demonstration purposes. ```text Mozilla/5.0 (X11; 78; CentOS; US-en) AppleWebKit/527+ (KHTML, like Gecko) Bolt/0.862 Version/3.0 Safari/523.15 ``` -------------------------------- ### Client-side Example: Asynchronous Client Hints Parsing Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/idata/with-client-hints.md Demonstrates how to fetch and parse Client Hints data asynchronously in a browser environment using `withClientHints()`. ```javascript // Using async/await (async function () { const ua = new UAParser(); // Get browser data from user-agent only let browser = ua.getBrowser(); console.log('Using User-Agent: ', browser); // Get browser data from client-hints (with user-agent as fallback) browser = await ua.getBrowser().withClientHints(); console.log('Using Client-Hints: ', browser); })(); // Using Promises (.then) const ua = new UAParser(); ua.getBrowser().withClientHints().then(function (browser) { console.log('Using Client-Hints: ', browser); }); ``` -------------------------------- ### NetSurf User Agent Strings Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/netsurf.md Example user agent strings for NetSurf on Linux and Plan9 platforms. ```sh NetSurf/3.10 (Linux; Arch Linux) ``` ```sh Mozilla/5.0 (Plan9) NetSurf/3.12 ``` -------------------------------- ### Retrieve OS information with UAParser Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/get-os.md Example usage of getOS() to parse a user-agent string and log the resulting OS object. ```js const galaxytabs8 = 'Mozilla/5.0 (Linux; Android 12; SM-X706B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36' const parser = new UAParser(galaxytabs8); console.log(parser.getOS()); // { name : "Android", version : "12" } ``` -------------------------------- ### Fennec Browser User Agent Examples Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/fennec.md These are example user agent strings for the Fennec browser. They can be used to test parsing logic. ```text Mozilla/5.0 (X11; U; Linux armv61; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1 ``` ```text Mozilla/5.0 (Maemo; Linux armv7l; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 Fennec/10.0.1 ``` -------------------------------- ### Example User Agent String Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/flow.md This is an example of a user agent string that can be parsed by the ua-parser-js library. It contains information about the browser, operating system, and rendering engine. ```sh Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) EkiohFlow/5.7.4.30559 Flow/5.7.4 (like Gecko Firefox/53.0 rv:53.0) ``` -------------------------------- ### GSA User Agent String Example Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/gsa.md Example of a user agent string identifying the Google Search App on an iPhone. ```sh Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) GSA/30.1.161623614 Mobile/14F89 Safari/602.1 ``` -------------------------------- ### Sleipnir User Agent Strings Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/sleipnir.md Example user agent strings for various versions of the Sleipnir browser. ```sh Mozilla/5.0 (Linux; Android 10; SOV37 Build/52.1.C.0.220; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/123.0.6312.120 Mobile Safari/537.36 Sleipnir/3.7.5 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Sleipnir 2.8.4) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022) Sleipnir/2.8.4 ``` -------------------------------- ### Pico Browser User Agent Examples Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/picobrowser.md These strings represent various versions of the Pico Browser identified on different Pico hardware platforms. ```sh Mozilla/5.0 (X11; Linux x86_64; Pico Neo3 Link OS5.8.4.0 like Quest) AppleWebKit/537.36 (KHTML, like Gecko) PicoBrowser/3.3.22 Chrome/105.0.5195.68 VR Safari/537.36 Mozilla/5.0 (X11; Linux x86_64; PICO 4 OS5.8.2 like Quest) AppleWebKit/537.36 (KHTML, like Gecko) PicoBrowser/3.3.38 Chrome/105.0.5195.68 VR Safari/537.36 Mozilla/5.0 (X11; Linux x86_64; PICO 4 OS5.4.0 like Quest) AppleWebKit/537.36 (KHTML, like Gecko) PicoBrowser/3.3.22 Chrome/105.0.5195.68 VR Safari/537.36 OculusBrowser/7.0 ``` -------------------------------- ### Chrome Headless User Agent Examples Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/chrome-headless.md These are example user agent strings for Chrome Headless. They are useful for identifying headless browser instances in logs or for testing purposes. ```sh Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36 ``` ```sh Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/60.0.3112.113 Safari/537.36 ``` -------------------------------- ### Whale Browser User Agent Example Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/whale.md This snippet shows an example of a user agent string that identifies the Whale Browser. This can be used with ua-parser-js to extract browser details. ```APIDOC ## Whale Browser User Agent Example ### Description This section provides an example of a user agent string that corresponds to the Whale Browser. This string can be processed by the ua-parser-js library to identify the browser and its version. ### Request Example ```sh Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.146 Whale/2.6.90.14 Safari/537.36 ``` ### Response Example When this user agent string is parsed by ua-parser-js, the library would identify the browser as 'Whale' with a specific version. ```json { "browser": { "name": "Whale", "version": "2.6.90.14" }, "os": { "name": "Mac OS X", "version": "10.15.2" }, "engine": { "name": "WebKit", "version": "537.36" }, "cpu": { "architecture": null, "family": null }, "device": { "model": null, "type": null, "vendor": null }, "ua": { "browser": "Whale", "os": "Mac OS X 10.15.2" } } ``` ``` -------------------------------- ### Retrieve browser information Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/get-browser.md Example usage of getBrowser() to parse a specific user-agent string. ```js const operamini = 'Opera/9.80 (J2ME/MIDP; Opera Mini/5.1.21214/19.916; U; en) Presto/2.5.25' const parser = new UAParser(operamini); console.log(parser.getBrowser()); // { name: "Opera Mini", version: "5.1.21214", major: "5", type: undefined } ``` -------------------------------- ### ICEBrowser User Agent String Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/ice.md Example of a user agent string for ICEBrowser running on Windows XP. ```sh Mozilla/5.0 (Java 1.6.0_01; Windows XP 5.1 x86; en) ICEbrowser/v6_1_2 ``` -------------------------------- ### GET getCPU() Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/get-cpu.md Retrieves the CPU architecture information from the parsed user agent string. ```APIDOC ## getCPU() ### Description Returns the CPU architecture name detected from the user agent string. ### Response - **architecture** (string) - The detected CPU architecture (e.g., arm, amd64, ppc, x86). ### Response Example { "architecture": "ppc" } ### Code Example ```js const powerpc = 'Mozilla/4.0 (compatible; MSIE 5.17; Mac_PowerPC Mac OS; en)' const parser = new UAParser(powerpc); console.log(parser.getCPU()); // { architecture : "ppc" } ``` ``` -------------------------------- ### Retrieve Engine Information Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/get-engine.md Example usage of getEngine to parse a user-agent string and output the detected rendering engine. ```js const operamini = 'Opera/9.80 (J2ME/MIDP; Opera Mini/5.1.21214/19.916; U; en) Presto/2.5.25' const parser = new UAParser(operamini); console.log(parser.getEngine()); // { name : "Presto", version : "2.5.25" } ``` -------------------------------- ### Quark Browser User Agent String Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/quark.md Example of a Quark browser user agent string on Android. ```sh Mozilla/5.0 (Linux; U; Android 12; zh-Hans-CN; JLH-AN00 Build/HONORJLH-AN00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 Quark/5.8.2.221 Mobile Safari/537.36 ``` -------------------------------- ### IceCat Linux User Agent String Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/icecat.md Example user agent string for IceCat running on a Linux environment. ```sh Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092921 IceCat/3.0.3-g1 ``` -------------------------------- ### Define a complex user-agent string Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/intro/why-ua-parser-js.md Example of a real-world, highly complex user-agent string from a mobile application. ```javascript const ua = `Mozilla/5.0 (Linux; Android 10; STK-LX1 Build/HONORSTK-LX1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/110.0.5481.153 Mobile Safari/537.36 musical_ly_2022803040 JsSdk/1.0 NetType/WIFI Channel/huaweiadsglobal_int AppName/musical_ly app_version/28.3.4 ByteLocale/en ByteFullLocale/en Region/IQ Spark/1.2.7-alpha.8 AppVersion/28.3.4 PIA/1.5.11 BytedanceWebview/d8a21c6`; ``` -------------------------------- ### PaleMoon Linux User Agent String Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/palemoon.md Example of a user agent string for PaleMoon version 27.6.1 on a Linux x86_64 system. ```sh Mozilla/5.0 (X11; Linux x86_64; rv:52.9) Gecko/20100101 Goanna/3.4 Firefox/52.9 PaleMoon/27.6.1 ``` -------------------------------- ### Detecting Bots with ua-parser-js Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/submodules/bot-detection/overview.md This example demonstrates how to use the isBot, isAICrawler, and isAIAssistant functions to classify a user-agent string. It requires importing the necessary functions from 'ua-parser-js/bot-detection' and potentially extensions. ```javascript import { UAParser } from 'ua-parser-js'; import { Bots } from 'ua-parser-js/extensions'; import { isAIAssistant, isAICrawler, isBot } from 'ua-parser-js/bot-detection'; const result = UAParser(Bots, req.headers); if (isBot(result)) { if (isAICrawler(result)) { console.log('You are an AI Crawler Bot!'); } else if (isAIAssistant(result)) { console.log('You are an AI Assistant Bot!'); } else { console.log('You are a Bot!'); } } else { console.log('You might be a human or an unknown Bot!'); } ``` -------------------------------- ### Parse User-Agent in Node.js Server Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/intro/quick-start/using-node-js.md This example demonstrates a basic HTTP server that parses the User-Agent header from incoming requests. ```js const http = require('http'); const uap = require('ua-parser-js'); http.createServer(function (req, res) { // get user-agent header let ua = uap(req.headers['user-agent']); // write the result as response res.end(JSON.stringify(ua, null, ' ')); }) .listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); ``` -------------------------------- ### LG Browser User Agent String Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/lg-browser.md Example of a user agent string for LG Browser version 7.00.00 on a webOS smart TV. ```sh Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.41 (KHTML, like Gecko) Large Screen Safari/537.41 LG Browser/7.00.00(LGE; 47LB680V-ZD; 05.05.90; 1); webOS.TV-2014; LG NetCast.TV-2013 Compatible (LGE, 47LB680V-ZD, wired) ``` -------------------------------- ### Detect ChatGPT user agent Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/submodules/enums/extension.md Example demonstrating how to use UAParser with extensions to identify a specific bot user agent. ```js import { UAParser } from 'ua-parser-js'; import { Fetchers } from 'ua-parser-js/extensions'; import { Extension } from 'ua-parser-js/enums'; const userAgent = "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot"; const { BrowserName: { Fetcher }} = Extension; const { browser } = UAParser(userAgent, Fetchers); if (browser.is(Fetcher.OPENAI_CHATGPT_USER)) { console.log('Hello, ChatGPT!'); } ``` -------------------------------- ### getOS() - Get Operating System Information Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/get-os.md The getOS() method returns an object containing the name and version of the operating system detected from the user-agent string. ```APIDOC ## GET /api/main/overview#methods ### Description Returns the operating system name and version. ### Method GET ### Endpoint /api/main/overview#methods ### Parameters #### Query Parameters - **userAgent** (string) - Required - The user-agent string to parse. ### Response #### Success Response (200) - **name** (string) - The name of the detected operating system. - **version** (string) - The detected OS version. ### Request Example ```js const userAgentString = 'Mozilla/5.0 (Linux; Android 12; SM-X706B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36'; const parser = new UAParser(userAgentString); const osInfo = parser.getOS(); console.log(osInfo); // Expected Output: { name: "Android", version: "12" } ``` ### Response Example ```json { "name": "Android", "version": "12" } ``` ``` -------------------------------- ### Netscape User Agent Strings on Windows Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/netscape.md Examples of user agent strings for Netscape 6, 9, and 8 on various Windows versions. ```sh # Netscape 6 Mozilla/5.0 (Windows; U; Win95; de-DE; rv:0.9.2) Gecko/20010726 Netscape6/6.1 # Netscape on Windows ME Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.8.1.8pre) Gecko/20071015 Firefox/2.0.0.7 Navigator/9.0 # Netscape on Windows 2000 Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20050519 Netscape/8.0.1 ``` -------------------------------- ### Get Browser Name - Coc Coc Example Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/coc-coc.md This snippet demonstrates how to get the browser name, specifically for the Coc Coc browser on macOS, using the UA Parser JS library. ```APIDOC ## Get Browser Name - Coc Coc Example ### Description This section shows how to extract the browser name from a user agent string, focusing on the Coc Coc browser on macOS. ### Method N/A (This is a documentation example, not an API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (Example Output) - **browser.name** (string) - The name of the browser. #### Response Example ```json { "browser": { "name": "Coc Coc" } } ``` ### User Agent String Example ```sh Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/78.0.129 Chrome/72.0.3626.129 Safari/537.36 ``` ``` -------------------------------- ### Create HTTP Server with Client Hints Support Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/idata/with-client-hints.md Configures an HTTP server to request Client Hints from the browser using Accept-CH and Critical-CH headers. ```javascript const http = require('http'); const uap = require('ua-parser-js'); http.createServer(function (req, res) { // you can also pass Client Hints data to UAParser // note: only works in a secure context (localhost or https://) // from any browsers that are based on Chrome 85+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-UA const getHighEntropyValues = 'Sec-CH-UA-Full-Version-List, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Form-Factors'; res.setHeader('Accept-CH', getHighEntropyValues); res.setHeader('Critical-CH', getHighEntropyValues); const result = uap(req.headers).withClientHints(); // write the result as response res.end(JSON.stringify(result, null, ' ')); }) .listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); ``` -------------------------------- ### Parse Client Hints in Node.js Server Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/intro/quick-start/using-node-js.md This example shows how to parse Sec-CH-UA headers in a secure context. It requires Chrome 85+ and must be served over localhost or HTTPS. ```js const http = require('http'); const uap = require('ua-parser-js'); http.createServer(function (req, res) { // Since `v2.0.0` you can also pass Client Hints data to UAParser. // Note that this only works in a secure context (localhost or https://) // from any browsers that are based on Chrome 85+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-CH-UA const getHighEntropyValues = 'Sec-CH-UA-Full-Version-List, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Arch, Sec-CH-UA-Bitness'; res.setHeader('Accept-CH', getHighEntropyValues); res.setHeader('Critical-CH', getHighEntropyValues); ua = uap(req.headers).withClientHints(); // write the result as response res.end(JSON.stringify(ua, null, ' ')); }) .listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); ``` -------------------------------- ### Detect Helio Browser on Lumin OS Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/helio.md This example shows a user agent string that identifies the Helio browser version 0.98.20 running on Lumin OS. ```sh Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36 Helio/0.98.20 ``` -------------------------------- ### Opera Mini User Agent Strings Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/opera-mini.md These are example User-Agent strings for Opera Mini. The first is for J2ME/MIDP devices, and the second is for Opera Mini 8+ on iPhone. ```text Opera/9.80 (J2ME/MIDP; Opera Mini/5.1.21214/19.916; U; en) Presto/2.5.25 ``` ```text Mozilla/5.0 (iPhone; CPU iPhone OS 9_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) OPiOS/12.1.1.98980 Mobile/13C75 Safari/9537.53 ``` -------------------------------- ### Parse User-Agent Strings Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/intro/quick-start/using-html.md Demonstrates initializing the parser, retrieving results for the current environment, and parsing custom user-agent strings. ```html ``` -------------------------------- ### Parse a Single User-Agent String Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/intro/quick-start/using-cli.md Use npx to execute the parser directly without global installation. The output can be displayed in the console or redirected to a file. ```sh $ npx ua-parser-js "" ``` ```sh # example command input: npx ua-parser-js "Flock/2.16 (Zenwalk 7.3; es_PR;)" # console output: [ { "ua": "Flock/2.16 (Zenwalk 7.3; es_PR;)", "browser": { "name": "Flock", "version": "2.16", "major": "2" }, "cpu": {}, "device": {}, "engine": {}, "os": { "name": "Zenwalk", "version": "7.3" } } ] # let's save the result into a log file: npx ua-parser-js "Flock/2.16 (Zenwalk 7.3; es_PR;)" >> log.txt ``` -------------------------------- ### Retrieve CPU architecture with UAParser Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/get-cpu.md Demonstrates initializing the parser with a user agent string and calling getCPU to identify the architecture. ```js const powerpc = 'Mozilla/4.0 (compatible; MSIE 5.17; Mac_PowerPC Mac OS; en)' const parser = new UAParser(powerpc); console.log(parser.getCPU()); // { architecture : "ppc" } ``` -------------------------------- ### Initialize UAParser with ExtraDevices Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/submodules/extensions/extra-devices.md Import the ExtraDevices extension and pass it as an array to the UAParser constructor to enable extended device detection. ```javascript import { ExtraDevices } from 'ua-parser-js/extensions'; const parserWithExtraDevices = new UAParser([ExtraDevices]); ``` -------------------------------- ### Initialize Email Parser Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/submodules/extensions/emails.md Import the Emails extension and pass it to the UAParser constructor to enable email client detection. ```javascript import { Emails } from 'ua-parser-js/extensions'; const emailParser = new UAParser(Emails); ``` -------------------------------- ### Parse Client Hints on Server-side Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/idata/with-client-hints.md Demonstrates how to pass request headers to UAParser and use withClientHints() to extract extended device information. ```javascript // Suppose we got a request having these HTTP headers: const request = { headers : { 'user-agent' : 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36', 'sec-ch-ua-mobile' : '?1', 'sec-ch-ua-model' : 'Galaxy S3 Marketing', 'sec-ch-ua-platform' : 'Android' } }; // parse only "user-agent" header const result1 = UAParser(request.headers); // also use "sec-ch-ua" headers, in addition to "user-agent" const result2 = UAParser(request.headers).withClientHints(); console.log(result1.os.name); // "Linux" console.log(result1.device.type); // undefined console.log(result1.device.model); // undefined console.log(result2.os.name); // "Android" console.log(result2.device.type); // "mobile" console.log(result2.device.model); // "Galaxy S3 Marketing" new UAParser(request.headers) .getBrowser() .withClientHints() .then((browser) => { console.log(browser.toString()); // Chrome 110.0.0.0 }); ``` -------------------------------- ### Retrieve and Format OS Information Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/idata/to-string.md Demonstrates how to access the operating system name and version from the parsed result. The toString() method on the OS object provides a combined string of the OS name and version. ```javascript // OS uap.getResult().os.name; // "Windows Phone" uap.getResult().os.version; // "8.1" uap.getResult().os.toString(); // "Windows Phone 8.1" ``` -------------------------------- ### Initialize Library Detection Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/submodules/extensions/libraries.md Import the Libraries extension and pass it to the UAParser constructor to enable detection of non-browser tools. ```javascript import { Libraries } from 'ua-parser-js/extensions'; const libParser = new UAParser(Libraries); ``` -------------------------------- ### Android Browser User Agent Examples Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/android.md These are example user agent strings for Android browsers on different devices and OS versions. They can be used to test or simulate browser identification. ```sh # Android Browser on Galaxy Nexus Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 ``` ```sh # Android Browser on Galaxy S3 Mozilla/5.0 (Linux; Android 4.4.4; en-us; SAMSUNG GT-I9300I Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36 ``` ```sh # Android Browser on HTC Flyer (P510E) Mozilla/5.0 (Linux; U; Android 3.2.1; ru-ru; HTC Flyer P510e Build/HTK75C) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13 ``` ```sh # Android Browser on Huawei Honor Glory II (U9508) Mozilla/5.0 (Linux; U; Android 4.0.4; ru-by; HUAWEI U9508 Build/HuaweiU9508) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 ACHEETAHI/2100050044 ``` ```sh #Android Browser on Huawei P8 (H891L) Mozilla/5.0 (Linux; Android 4.4.4; HUAWEI H891L Build/HuaweiH891L) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 ``` ```sh # Android Browser on Samsung S6 (SM-G925F) Mozilla/5.0 (Linux; Android 5.0.2; SAMSUNG SM-G925F Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.0 Chrome/38.0.2125.102 Mobile Safari/537.36 ``` -------------------------------- ### Get Browser Information Source: https://context7.com/faisalman/ua-parser-js-docs/llms.txt Retrieves browser name, version, major version, and type. Use the `is()` method to check for specific browser names and `toString()` to get a formatted string. ```javascript import { UAParser } from 'ua-parser-js'; const operamini = 'Opera/9.80 (J2ME/MIDP; Opera Mini/5.1.21214/19.916; U; en) Presto/2.5.25'; const parser = new UAParser(operamini); console.log(parser.getBrowser()); // { name: "Opera Mini", version: "5.1.21214", major: "5", type: undefined } // Check browser type with is() method const browser = parser.getBrowser(); console.log(browser.is('Opera Mini')); // true console.log(browser.toString()); // "Opera Mini 5.1.21214" ``` -------------------------------- ### Initialize MediaPlayers Parser Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/submodules/extensions/media-players.md Import the MediaPlayers extension and pass it to the UAParser constructor to enable media player detection. ```javascript import { MediaPlayers } from 'ua-parser-js/extensions'; const mediaPlayerParser = new UAParser(MediaPlayers); ``` -------------------------------- ### Get Device Model Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/device/model.md Retrieves the model and series of a device. ```APIDOC ## GET /api/main/get-device ### Description Retrieves the model and series of a device, determined dynamically from user-agent data. ### Method GET ### Endpoint /api/main/get-device ### Parameters #### Query Parameters - **model** (string) - Optional - Name and series of the device. ``` -------------------------------- ### Check for Apple Silicon with Client Hints Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/submodules/helpers/is-apple-silicon.md Use this snippet when you have the full result object, including client hints, to check for Apple Silicon. Ensure UAParser is initialized and getResult() is called. ```javascript import { isAppleSilicon } from 'ua-parser-js/helpers'; const uap = new UAParser(); const result = await uap.getResult().withClientHints(); if (isAppleSilicon(result)) { console.log('Hi Apple Silicon!'); } ``` -------------------------------- ### GET getResult() Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/get-result.md Retrieves the full breakdown of the detected user-agent string. ```APIDOC ## getResult() ### Description Returns a full breakdown of the detected user-agent, including browser, CPU, device, engine, and OS information. ### Response #### Success Response (200) - **ua** (string) - The user-agent string of the current instance. - **browser** (object) - Browser name, version, major, and type. - **cpu** (object) - CPU architecture. - **device** (object) - Device type, vendor, and model. - **engine** (object) - Browser engine name and version. - **os** (object) - Operating system name and version. #### Response Example { "ua": "Mozilla/5.0 (Linux; Android 12; SM-X706B)...", "browser": { "name": "Chrome", "version": "103.0.5060.53", "major": "103", "type": null }, "cpu": { "architecture": null }, "device": { "type": "mobile", "vendor": "Huawei", "model": "SM-X706B" }, "engine": { "name": "Blink", "version": "103.0.5060.53" }, "os": { "name": "Android", "version": "12" } } ``` -------------------------------- ### Set custom user-agent with UAParser Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/set-ua.md Demonstrates initializing the parser, retrieving the default user-agent, and overriding it with a custom string. ```javascript const parser = new UAParser(); // Prints the current browser's user-agent console.log(parser.getUA()); // Replace it with a custom user-agent string parser.setUA('Mozilla/5.0 MyBrowser/1.0'); // Now it uses the new value we set before parser.getUA(); // "Mozilla/5.0 MyBrowser/1.0" ``` -------------------------------- ### DuckDuckGo Android User Agent Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/duckduckgo.md Example user agent string for DuckDuckGo running on Android. ```sh Mozilla/5.0 (Linux; Android 8.1.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/92.0.4515.131 Mobile DuckDuckGo/5 Safari/537.36 ``` -------------------------------- ### UAParser Constructor Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/api/main/overview.md Demonstrates how to instantiate the UAParser class with and without the 'new' keyword. ```APIDOC ## Constructor ### new UAParser() When called *with* the `new` keyword, it returns a new `UAParser` instance. ```js const parser = new UAParser("your user-agent here"); console.log(parser); /* UAParser instance */ const result = parser.getResult(); console.log(result); /* { ua : "your user-agent here", browser : {}, engine : {}, os : {}, device : {}, cpu : {} } */ ``` ### UAParser() When called *without* the `new` keyword, it directly returns the result of `getResult()`. ::: tip `UAParser()` equals with `new UAParser().getResult()` ::: ```js const result = UAParser("your user-agent here"); console.log(result); /* { ua : "your user-agent here", browser : {}, engine : {}, os : {}, device : {}, cpu : {} } */ ``` ::: tip - In browser environment, if the User-Agent string is not set, it will be automatically taken from `window.navigator.userAgent`. - In Node.js environment, you'll need to pass the User-Agent string manually, usually from `request.headers["user-agent"]`. ::: ::: warning To ensure stable parsing performance and mitigate ReDoS risks, any User-Agent string longer than **500** characters will be automatically trimmed. ::: ``` -------------------------------- ### DuckDuckGo macOS User Agent Source: https://github.com/faisalman/ua-parser-js-docs/blob/main/docs/info/browser/name/duckduckgo.md Example user agent string for DuckDuckGo running on macOS. ```sh Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.1517.4.1 Ddg/17.4.1 ```