web-user-agent-parse Edge Function — Web Search
Web SearchParse a User-Agent string to detect browser name/version, OS, device type (desktop/mobile/tablet/bot), and bot status.
Edge function web-user-agent-parse Parse a User-Agent string to detect browser name/version, OS, device type (desktop/mobile/tablet/bot), and bot status.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.
npx aerostack add navin/web-user-agent-parse Use with AI Assistants
MCPConnect Claude, Cursor, or any MCP-compatible client — then call this function by slug
① Add MCP Server
Add this once — access all Aerostack functions from your AI tool.
{
"mcpServers": {
"aerostack": {
"url": "https://mcp.aerostack.dev",
"type": "http"
}
}
} ② Call this function
Ask your AI to use the call_function tool with this slug:
call_function({
slug: "web-user-agent-parse",
args: {
"userAgent": "example_userAgent"
}
}) web-user-agent-parse — Parse User-Agent strings
Detect browser, OS, device type, and bot status from a User-Agent header string using pure regex matching — no external libraries.
API
POST /api/web-user-agent-parse
Request body
| Field | Type | Required | Description |
|---|---|---|---|
userAgent |
string | Yes | User-Agent header value |
Success response (200)
{
"success": true,
"data": {
"browser": { "name": "Chrome", "version": "120.0.0.0" },
"os": { "name": "Windows", "version": "10.0" },
"device": { "type": "desktop" },
"bot": false,
"raw": "Mozilla/5.0 ..."
}
}
Error responses
| Code | HTTP | When |
|---|---|---|
INVALID_INPUT |
400 | Missing userAgent field |
INTERNAL_ERROR |
500 | Unexpected error |
Usage
Direct import
import { webUserAgentParse } from '@aerostack/functions/web-user-agent-parse';
const result = webUserAgentParse({ userAgent: req.headers['user-agent'] });
if (result.bot) { /* block or flag */ }
if (result.device.type === 'mobile') { /* redirect to mobile site */ }
Use Cases
- Filtering out bot traffic from analytics pipelines
- Serving device-appropriate content (mobile vs desktop redirects)
- Segmenting analytics by browser and OS for compatibility reports
Metadata
Tags
Publisher
@navin verified
Build and publish your own functions
Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.
More Web Search Functions
Browse Web Search Functions →web-query-stringify
by @navin
Serialize a parameters object to a URL query string with support for arrays, encoding, and null skipping.
web-content-type-parse
by @navin
Parse a Content-Type header value into MIME type, subtype, charset, boundary, and convenience boolean flags.
web-headers-parse
by @navin
Parse a raw HTTP header block string or object into a structured lowercase-keyed object with content-type and authorization extraction.
web-ip-extract
by @navin
Extract the real client IP address from HTTP request headers, with proxy trust control and private IP detection.
web-query-parse
by @navin
Parse a URL query string into a typed object with support for arrays, number/boolean coercion, and bracket notation.
web-url-build
by @navin
Build a URL from a base and optional path, query parameters, and hash fragment.
Frequently asked questions
What does the web-user-agent-parse function do? +
web-user-agent-parse is a serverless edge function for web-search automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.
How do I deploy the web-user-agent-parse function? +
Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/web-user-agent-parse ``` It will be live on Cloudflare Workers in seconds.
What runtime does web-user-agent-parse use? +
web-user-agent-parse runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.
Can I customise the web-user-agent-parse function? +
Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.