URL Parser API

Description

Parse a url into its individual components. This endpoint will try its best to parse things as reliably as possible in line with the accepted RFCs and standards. If a severely malformed URL is provided, the execution may fail to parse out a result.

Endpoint

> GET https://api.jsonrepo.com/v1/compute/parser/url

Headers

Field Description
api_key Required Your API Key

Parameters

Field Type Description
url String Required The URL to parse
Maximum: 1000 characters

URL Formats:

If an invalid url is provided, the endpoint will mark it as invalid but it will still attempt to parse it in the bet way possible. Please keep in mind that parsing a url is actually incredibly difficult as there are a lot of URLs out there that do not respect established RFCs. We do our best to mitigate for these cases but it is not an exact process.

Response

A successful request will result in a populated payload field with the expected output.

A failed request will result in an error output as detailed in Error Rules. If the endpoint validation fails due to missing, badly formatted or invalid parameters, the endpoint will return HTTP code 400 along with a message detailing the error.

See the examples section for more information.

Requst

  • Curl
// Parse a complex `url`

curl -G \
https://api.jsonrepo.com/v1/compute/parser/url \
-H "api_key: {YOUR_API_KEY_HERE}" \
--data-urlencode "url=https://myuser:1234@sub.example.com:8080/path/to/page?x=1&y=2#fragment" 

Success Response

{
    "http_code": 200,
    "http_message": "Ok",
    "message": "Successful execution",
    "payload": {
        "url": {
            "scheme": "https",
            "host": "sub.example.com",
            "port": "8080",
            "user": "myuser",
            "pass": "1234",
            "path": "/path/to/page",
            "query": {
                "x": "1",
                "y": "2"
            },
            "fragment": "fragment"
        }
    }
}

Error Response Examples

// Request with too large `url` parameter

{
    "http_code": 400,
    "http_message": "Bad Request",
    "message": "Malformed request: `url` parameter must be provided and consist of 1000 characters or less.",
    "payload": []
}

// Request with invalid `url=ftp://user:pass@`

{
    "http_code": 400,
    "http_message": "Bad Request",
    "message": "Malformed request: `url` could not be parsed. Formatting error encountered.",
    "payload": []
}