API Reference#

Exceptions#

HostParseError

Exception that raised when host parsing fails.

IDNAError(message, error_code)

Exception that raised when IDNA processing fails.

IPv4AddressParseError

Exception that raised when IPv4 address parsing fails.

IPv6AddressParseError

Exception that raised when IPv6 address parsing fails.

URLParseError

Exception that raised when URL parsing fails.

URL and URLSearchParams#

URL(url[, base])

Parses a string url against a base URL base.

URLSearchParams()

Parses and manipulates URL’s query.

Low-level APIs#

Classes#

BasicURLParser()

An implementation of the basic URL parser in Python.

Host()

Utility class for hosts (domains and IP addresses).

HostValidator()

Validates a host string.

IDNA()

Utility class for IDNA processing.

Origin(scheme, host, port, domain)

A named tuple that represents the origin of the URL.

URLParserState(value[, names, module, ...])

State machine enums for the basic URL parser.

URLRecord(scheme, username, password, host, ...)

A data class that represents a universal identifier.

URLValidator()

Validates a URL string.

ValidityState(valid, error_types, ...)

A validation status.

Functions#

parse_qsl(query)

An alternative to urllib.parse.parse_qsl().

parse_url(urlstring[, base, encoding])

Parses a string urlstring against a base URL base using the basic URL parser, and returns URLRecord.

string_percent_decode(s)

Returns a percent-decoded byte sequence after encoding with utf-8.

string_percent_encode(s, safe[, encoding, ...])

Returns a percent-encoded string after encoding with encoding.

urlencode(query[, encoding])

An alternative to urllib.parse.urlencode().

urlparse(urlstring[, base, encoding, ...])

An alternative to urllib.parse.urlparse().

utf8_decode(b)

Decodes a byte sequence with utf-8 and returns its string.

utf8_encode(s)

Encodes a string with utf-8 and returns its byte sequence.

utf8_percent_encode(s, safe[, space_as_plus])

Returns a percent-encoded string after encoding with utf-8.