# URL parser

Split a URL into scheme, login, host, port, path, query parameters and fragment.

- Endpoint: `POST https://setget.net/v1/tools/url-parse` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `url-parse`
- Page: https://setget.net/tools/url-parse

## Inputs

- `url` (required, string): The URL to take apart.

## Example 1

```json
{"input":{"url":"https://user:pw@Example.com:8443/a/b%20c?x=1&x=2&y=#top"}}
```

Result:

```json
{"scheme":"https","username":"user","password":"pw","host":"example.com","host_type":"domain","is_idn":false,"ascii_host":"example.com","unicode_host":"example.com","port":8443,"default_port":443,"path":"/a/b%20c","segments":["a","b c"],"query":"x=1&x=2&y=","params":{"x":["1","2"],"y":""},"fragment":"top","origin":"https://example.com:8443"}
```

## Example 2: An internationalised domain name

```json
{"input":{"url":"http://bücher.example/"}}
```

Result:

```json
{"scheme":"http","username":null,"password":null,"host":"bücher.example","host_type":"domain","is_idn":true,"ascii_host":"xn--bcher-kva.example","unicode_host":"bücher.example","port":null,"default_port":80,"path":"/","segments":[],"query":null,"params":{},"fragment":null,"origin":"http://xn--bcher-kva.example"}
```

**Is the URL fetched?** No. The text is only split into its parts. Nothing is requested or looked up.

**Why is a parameter sometimes a list?** A name that appears more than once in the query becomes a list of its values, in order.

**What is the origin?** Scheme, host and port together. Browsers use it to decide which pages may share data.
