Skip to content
moxon home

URL Parsing

The /url endpoint parses a URL into its structural components: scheme, host, port, path, query parameters, and fragment. Duplicate query parameters are grouped into an array.

gethttps://api.moxon.dev/v5/url
Try itget/v5/url

Parameters

  • urlstringrequired

    Absolute URL to parse, including its scheme (e.g. https://example.com/path?a=1)

Default Ports

When the URL omits the port, the scheme's default port is returned:

SchemePort
ftp21
http80
https443
ws80
wss443

Any other scheme returns null.

Response Fields

  • urlstring

    The original input URL

  • schemestring

    URL scheme without the trailing colon (e.g. https)

  • hoststring

    Hostname

  • portnumber|null

    Port number — the scheme's default port when the URL omits it, null if the scheme has no known default

  • pathstring

    Path component

  • paramsobject

    Query parameters — duplicate keys are grouped into an array

  • fragmentstring

    Fragment identifier without the leading #

  • validboolean

    Always true for a successfully parsed URL

Code Examples

Error Handling

If parameters are missing or invalid, the API will return an error:

  • 400Please provide a URL (?url={URL})The url parameter is missing
  • 400URL cannot exceed 2048 charactersThe url exceeds the maximum length
  • 400Invalid URLThe url value cannot be parsed as a URL