API Submodule

rfc3986.api.urlparse(uri, encoding='utf-8')

Parse a given URI and return a ParseResult.

This is a partial replacement of the standard library’s urlparse function.

Parameters
  • uri (str) – The URI to be parsed.

  • encoding (str) – The encoding of the string provided.

Returns

A parsed URI

Return type

ParseResult

rfc3986.api.uri_reference(uri, encoding='utf-8')

Parse a URI string into a URIReference.

This is a convenience function. You could achieve the same end by using URIReference.from_string(uri).

Parameters
  • uri (str) – The URI which needs to be parsed into a reference.

  • encoding (str) – The encoding of the string provided

Returns

A parsed URI

Return type

URIReference

rfc3986.api.normalize_uri(uri, encoding='utf-8')

Normalize the given URI.

This is a convenience function. You could use either uri_reference(uri).normalize().unsplit() or URIReference.from_string(uri).normalize().unsplit() instead.

Parameters
  • uri (str) – The URI to be normalized.

  • encoding (str) – The encoding of the string provided

Returns

The normalized URI.

Return type

str