x402AgentTools

๐Ÿ”—URL Parser

Parse a URL into all its components: protocol, hostname, port, path segments, query parameters (as a clean object), hash and credentials. Exact โ€” no guessing by eye.

Worked examples

API URL with params

GET /api/v1/dev/url-parser?url=https%3A%2F%2Fuser%3Apw%40api.example.com%3A8443%2Fv1%2Fusers%3Fpage%3D2%26sort%3Dname%26tag%3Da%26tag%3Db%23results

Result: https://api.example.com:8443/v1/users?page=2&sort=name&tag=a&tag=b#results

Simple URL

GET /api/v1/dev/url-parser?url=https%3A%2F%2Fexample.com%2Fabout

Result: https://example.com/about

URL with encoded params

GET /api/v1/dev/url-parser?url=https%3A%2F%2Fsearch.example.com%2Ffind%3Fq%3Dhello%2520world%26lang%3Den

Result: https://search.example.com/find?q=hello%20world&lang=en

Machine API (x402)

$0.001 / call

This tool is also a JSON API for AI agents. Requests without payment receive 402 Payment Required plus instructions; agents pay USDC on Base via the x402 protocol โ€” no accounts, no API keys.

GET /api/v1/dev/url-parser?url=https%3A%2F%2Fuser%3Apw%40api.example.com%3A8443%2Fv1%2Fusers%3Fpage%3D2%26sort%3Dname%26tag%3Da%26tag%3Db%23results HTTP/1.1
Host: agenttools-hub.vercel.app

โ†’ 402 (payment required, instructions in headers)
โ†’ 200 (after X-PAYMENT header; JSON body below)

{
  "tool": "dev/url-parser",
  "input": {"url":"https://user:pw@api.example.com:8443/v1/users?page=2&sort=name&tag=a&tag=b#results"},
  "result": { "value": null, "answer": "https://api.example.com:8443/v1/users?page=2&sort=name&tag=a&tag=b#results" }
}

Agent docs: /llms.txt ยท OpenAPI spec ยท integration guide

About this tool

Exact URL decomposition via the standard URL parser: protocol, host, port, decoded path segments, query parameters as a JSON object (repeated keys become arrays), credentials, hash and origin. In `result.artifacts` the params object and path segments arrive as JSON for direct machine use.

Frequently asked questions

Do query values arrive decoded?

Yes โ€” URLSearchParams decodes percent-encoding, so `q=hello%20world` becomes `hello world`. Repeated keys (e.g. `tag=a&tag=b`) are grouped into arrays.

Does it work with relative URLs?

No โ€” an absolute URL with protocol is required; relative references have no host to anchor components to.

Related tools