User agents
Parse HTTP User-Agent strings into browser, OS and device fields, and detect bots
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/useragent/index.md to help me query User agents with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
See what you can query
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT useragent.main.ua_browser(ua) AS browser, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'), ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36'), ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'), ('Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)')) AS hits(ua)
WHERE NOT useragent.main.ua_is_bot(ua)
GROUP BY browser
ORDER BY requests DESC, browser
| browser | requests |
|---|---|
| Chrome | 2 |
| Mobile Safari | 1 |
Quick start
Choose where to run User agents, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach the release directly
Downloads the latest release for your platform and caches it locally.
ATTACH 'useragent' AS useragent (
TYPE vgi,
LOCATION 'github-auto://Query-farm/vgi-useragent'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'useragent' AS useragent (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-useragent:0.5.0'
);
3. Run a query
SELECT useragent.main.ua_browser(ua) AS browser, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'), ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36'), ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'), ('Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)')) AS hits(ua)
WHERE NOT useragent.main.ua_is_bot(ua)
GROUP BY browser
ORDER BY requests DESC, browser
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'useragent' AS useragent
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT useragent.main.ua_browser(ua) AS browser, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'), ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36'), ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'), ('Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)')) AS hits(ua)
WHERE NOT useragent.main.ua_is_bot(ua)
GROUP BY browser
ORDER BY requests DESC, browser
Query Farm operates User agents for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use useragent as the catalog alias for the query below.
4. Run a query
SELECT useragent.main.ua_browser(ua) AS browser, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'), ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36'), ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'), ('Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)')) AS hits(ua)
WHERE NOT useragent.main.ua_is_bot(ua)
GROUP BY browser
ORDER BY requests DESC, browser
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach the release directly
Uses the verified release each time you attach the connector.
ATTACH 'useragent' AS useragent (
TYPE vgi,
LOCATION 'github-auto://Query-farm/[email protected]'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'useragent' AS useragent (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-useragent:0.5.0'
);
Overview
HTTP User-Agent parsing: browser / OS / device + bot detection.
Turn raw HTTP User-Agent header strings into structured browser, operating-system, and device facts — and flag bots, crawlers, and spiders — directly in DuckDB SQL over Apache Arrow.
The useragent extension brings production-grade User-Agent parsing to your SQL workflow. It is built for web-analytics teams, log-pipeline engineers, and anyone who needs to segment HTTP traffic by client, platform, or device without leaving the database. Point it at a column of raw User-Agent headers and get clean, normalized browser / OS / device attributes plus a reliable bot signal — no hand-written UDFs, no external services, and no row-by-row API round-trips.
Parsing is powered by the community-maintained uap-core regex database — the same ruleset behind the cross-language ua-parser project — executed through the Rust uaparser crate. The full uap-core regexes.yaml ruleset is embedded into the worker at compile time and compiled exactly once per process, so the binary is fully self-contained and matching stays fast across millions of rows. Results stream back to DuckDB over Apache Arrow. Unidentified families normalize to SQL NULL (never the literal 'Other'), and crawlers are recognized via uap-core's Spider device classification.
The function surface is small and composable: single-field accessors pull one attribute (browser, operating system, or device) at a time, a boolean predicate flags automated traffic, and a one-shot parser returns every field together as a STRUCT when you need several at once. Every accessor takes a single ua VARCHAR argument and returns NULL for empty or unrecognizable input, so it drops straight into web-analytics enrichment, traffic segmentation by platform/device, and bot filtering. Reach for this worker whenever you have a column of raw User-Agent headers to enrich, segment, or filter in SQL.
Learn more
- Source code: ua-parser/uap-core
- Specification: uap-core spec
- Rust parser docs: uaparser on docs.rs
Catalog
Everything useragent exposes once attached — read straight from the worker's
released build.
main 8 functions
User-Agent parsing and bot-detection functions.
Schema examples (8)
Extract the browser family from a desktop Chrome User-Agent.
SELECT useragent.main.ua_browser('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
Extract the operating system from an iPhone Safari User-Agent.
SELECT useragent.main.ua_os('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1');
Detect that the Googlebot crawler User-Agent is a bot.
SELECT useragent.main.ua_is_bot('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
Parse every field of a Chrome-on-Windows User-Agent at once as a STRUCT.
SELECT useragent.main.ua_parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36') AS parsed;
4 more examples
Web-analytics browser breakdown: filter crawlers out of a request log with ua_is_bot, then count the remaining human requests per ua_browser family (Googlebot and Bingbot are dropped; Chrome 2, Mobile Safari 1).
SELECT useragent.main.ua_browser(ua) AS browser, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'), ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36'), ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'), ('Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)')) AS hits(ua)
WHERE NOT useragent.main.ua_is_bot(ua)
GROUP BY browser
ORDER BY requests DESC, browser;
| browser | requests |
|---|---|
| Chrome | 2 |
| Mobile Safari | 1 |
Find visitors on an outdated Chrome: keep rows whose ua_browser is 'Chrome' and whose ua_browser_version major number is below 110 (returns the Chrome 96 request with version '96.0.4664'; Chrome 120 and Firefox are excluded).
SELECT ua, useragent.main.ua_browser_version(ua) AS chrome_version
FROM (VALUES ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'), ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36'), ('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0')) AS hits(ua)
WHERE useragent.main.ua_browser(ua) = 'Chrome' AND TRY_CAST(split_part(useragent.main.ua_browser_version(ua), '.', 1) AS INTEGER) < 110
ORDER BY ua;
iOS version adoption: keep requests whose ua_os is 'iOS' (iPhone and iPad alike, Android dropped) and count them per ua_os_version (16.6 → 1, 17.0 → 2).
SELECT useragent.main.ua_os_version(ua) AS ios_version, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36')) AS hits(ua)
WHERE useragent.main.ua_os(ua) = 'iOS'
GROUP BY ios_version
ORDER BY ios_version;
Hardware breakdown: count requests per ua_device_brand and ua_device model, skipping traffic with no identifiable brand such as a generic Windows desktop (Apple iPhone, Google Pixel 7, Samsung SM-S911B; 1 request each).
SELECT useragent.main.ua_device_brand(ua) AS brand,
useragent.main.ua_device(ua) AS device, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36'), ('Mozilla/5.0 (Linux; Android 13; SM-S911B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36'), ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36')) AS hits(ua)
WHERE useragent.main.ua_device_brand(ua) IS NOT NULL
GROUP BY brand, device
ORDER BY brand, device;
ua_browser (ua ANY)
Browser/client family from a User-Agent (e.g. 'Chrome'), or NULL
Extract the browser family ('Chrome') from a User-Agent.
SELECT useragent.main.ua_browser('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
ua_browser_version (ua ANY)
Browser version from a User-Agent (e.g. '120.0.0'), or NULL
Extract the browser version ('120.0.0') from a User-Agent.
SELECT useragent.main.ua_browser_version('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
Find visitors on an outdated Chrome: keep rows whose ua_browser is 'Chrome' and whose ua_browser_version major number is below 110 (returns the Chrome 96 request with version '96.0.4664'; Chrome 120 and Firefox are excluded).
SELECT ua, useragent.main.ua_browser_version(ua) AS chrome_version
FROM (VALUES ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'), ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36'), ('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0')) AS hits(ua)
WHERE useragent.main.ua_browser(ua) = 'Chrome' AND TRY_CAST(split_part(useragent.main.ua_browser_version(ua), '.', 1) AS INTEGER) < 110
ORDER BY ua;
ua_device (ua ANY)
Device family/model from a User-Agent (e.g. 'iPhone'), or NULL
Extract the device family from a User-Agent (NULL for a generic desktop).
SELECT useragent.main.ua_device('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
ua_device_brand (ua ANY)
Device brand from a User-Agent (e.g. 'Apple'), or NULL
Extract the device brand from a User-Agent (NULL for a generic desktop).
SELECT useragent.main.ua_device_brand('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
Hardware breakdown: count requests per ua_device_brand and ua_device model, skipping traffic with no identifiable brand such as a generic Windows desktop (Apple iPhone, Google Pixel 7, Samsung SM-S911B; 1 request each).
SELECT useragent.main.ua_device_brand(ua) AS brand,
useragent.main.ua_device(ua) AS device, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36'), ('Mozilla/5.0 (Linux; Android 13; SM-S911B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36'), ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36')) AS hits(ua)
WHERE useragent.main.ua_device_brand(ua) IS NOT NULL
GROUP BY brand, device
ORDER BY brand, device;
ua_is_bot (ua ANY)
True if the User-Agent is a spider/crawler (e.g. Googlebot), else false; NULL in → NULL out
Detect that the Googlebot crawler User-Agent is a bot (returns true).
SELECT useragent.main.ua_is_bot('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
Web-analytics browser breakdown: filter crawlers out of a request log with ua_is_bot, then count the remaining human requests per ua_browser family (Googlebot and Bingbot are dropped; Chrome 2, Mobile Safari 1).
SELECT useragent.main.ua_browser(ua) AS browser, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'), ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36'), ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'), ('Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)')) AS hits(ua)
WHERE NOT useragent.main.ua_is_bot(ua)
GROUP BY browser
ORDER BY requests DESC, browser;
| browser | requests |
|---|---|
| Chrome | 2 |
| Mobile Safari | 1 |
ua_os (ua ANY)
Operating-system family from a User-Agent (e.g. 'Windows', 'iOS'), or NULL
Extract the operating-system family ('Windows') from a User-Agent.
SELECT useragent.main.ua_os('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
ua_os_version (ua ANY)
Operating-system version from a User-Agent (e.g. '17.0'), or NULL
Extract the operating-system version ('10') from a User-Agent.
SELECT useragent.main.ua_os_version('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36');
iOS version adoption: keep requests whose ua_os is 'iOS' (iPhone and iPad alike, Android dropped) and count them per ua_os_version (16.6 → 1, 17.0 → 2).
SELECT useragent.main.ua_os_version(ua) AS ios_version, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36')) AS hits(ua)
WHERE useragent.main.ua_os(ua) = 'iOS'
GROUP BY ios_version
ORDER BY ios_version;
ua_parse (ua ANY)
Parse a User-Agent into STRUCT(browser, browser_version, os, os_version, device, brand, is_bot); NULL → NULL row, unparseable → NULL fields
-
browserVARCHAR
-
browser_versionVARCHAR
-
osVARCHAR
-
os_versionVARCHAR
-
deviceVARCHAR
-
brandVARCHAR
-
is_botBOOLEAN
Parse an iPhone Safari User-Agent into all of its fields at once (browser, OS, device, brand, is_bot).
SELECT useragent.main.ua_parse('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1') AS parsed;
SELECT useragent.main.ua_browser('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36') AS browser;
SELECT useragent.main.ua_os('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1') AS os;
2 more examples
SELECT useragent.main.ua_is_bot('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)') AS is_bot;
SELECT useragent.main.ua_parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36') AS parsed;
Try these queries
Extract the browser family from a desktop Chrome User-Agent.
SELECT useragent.main.ua_browser('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36')
Uses ua_browser
Extract the operating system from an iPhone Safari User-Agent.
SELECT useragent.main.ua_os('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1')
Uses ua_os
Detect that the Googlebot crawler User-Agent is a bot.
SELECT useragent.main.ua_is_bot('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)')
Uses ua_is_bot
Parse every field of a Chrome-on-Windows User-Agent at once as a STRUCT.
SELECT useragent.main.ua_parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36') AS parsed
Uses ua_parse
Find visitors on an outdated Chrome: keep rows whose ua_browser is 'Chrome' and whose ua_browser_version major number is below 110 (returns the Chrome 96 request with version '96.0.4664'; Chrome 120 and Firefox are excluded).
SELECT ua, useragent.main.ua_browser_version(ua) AS chrome_version
FROM (VALUES ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'), ('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36'), ('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0')) AS hits(ua)
WHERE useragent.main.ua_browser(ua) = 'Chrome' AND TRY_CAST(split_part(useragent.main.ua_browser_version(ua), '.', 1) AS INTEGER) < 110
ORDER BY ua
iOS version adoption: keep requests whose ua_os is 'iOS' (iPhone and iPad alike, Android dropped) and count them per ua_os_version (16.6 → 1, 17.0 → 2).
SELECT useragent.main.ua_os_version(ua) AS ios_version, count(*) AS requests
FROM (VALUES ('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1'), ('Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36')) AS hits(ua)
WHERE useragent.main.ua_os(ua) = 'iOS'
GROUP BY ios_version
ORDER BY ios_version
Uses ua_os_versionua_os
10 more examples in the Catalog, each listed under the table or function it uses.
User agents is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Calendar
Dates, units & validation
Public holidays and business days for hundreds of countries, plus Easter, ISO weeks, and RRULE recurrences
Color
Dates, units & validation
Convert colors between hex, RGB, HSL and CIELAB, measure CIEDE2000 difference, and check WCAG contrast for accessibility
Conform
Dates, units & validation
Check and standardize phone numbers, emails, IBANs, EU VAT numbers, card numbers, URLs and postal codes offline, with no external service