Skip to main content

URL parser and manipulator based on the WHAT WG URL standard

Project description

The urlib.parse module in Python does not follow the legacy RFC 3978 standard nor does it follow the newer WHATWG URL specification. It is also relatively slow.

This is ada_url, a fast standard-compliant Python library for working with URLs based on the Ada URL parser.

Installation

Install from PyPI:

pip install ada_url

Usage examples

Parsing URLs

The URL class is intended to match the one described in the WHATWG URL spec:.

>>> from ada_url import URL
>>> urlobj = URL('https://example.org/path/../file.txt')
>>> urlobj.href
'https://example.org/path/file.txt'

The parse_url function returns a dictionary of all URL elements:

>>> from ada_url import parse_url
>>> parse_url('https://user:pass@example.org:80/api?q=1#2')
{
    'href': 'https://user:pass@example.org:80/api?q=1#2',
    'username': 'user',
    'password': 'pass',
    'protocol': 'https:',
    'port': '80',
    'hostname': 'example.org',
    'host': 'example.org:80',
    'pathname': '/api',
    'search': '?q=1',
    'hash': '#2',
    'origin': 'https://example.org:80',
    'host_type': <HostType.DEFAULT: 0>,
    'scheme_type': <SchemeType.HTTPS: 2>
}

Altering URLs

Replacing URL components with the URL class:

>>> from ada_url import URL
>>> urlobj = URL('https://example.org/path/../file.txt')
>>> urlobj.host = 'example.com'
>>> urlobj.href
'https://example.com/file.txt'

Replacing URL components with the replace_url function:

>>> from ada_url import replace_url
>>> replace_url('https://example.org/path/../file.txt', host='example.com')
'https://example.com/file.txt'

Search parameters

The URLSearchParams class is intended to match the one described in the WHATWG URL spec.

>>> from ada_url import URLSearchParams
>>> obj = URLSearchParams('key1=value1&key2=value2')
>>> list(obj.items())
[('key1', 'value1'), ('key2', 'value2')]

The parse_search_params function returns a dictionary of search keys mapped to value lists:

>>> from ada_url import parse_search_params
>>> parse_search_params('key1=value1&key2=value2')
{'key1': ['value1'], 'key2': ['value2']}

Internationalized domain names

The idna class can encode and decode IDNs:

>>> from ada_url import idna
>>> idna.encode('Bücher.example')
b'xn--bcher-kva.example'
>>> idna.decode(b'xn--bcher-kva.example')
'bücher.example'

WHATWG URL compliance

This library is compliant with the WHATWG URL spec. This means, among other things, that it properly encodes IDNs and resolves paths:

>>> from ada_url import URL
>>> parsed_url = URL('https://www.GOoglé.com/./path/../path2/')
>>> parsed_url.hostname
'www.xn--googl-fsa.com'
>>> parsed_url.pathname
'/path2/'

Contrast that with the Python standard library’s urlib.parse module:

>>> from urllib.parse import urlparse
>>> parsed_url = urlparse('https://www.GOoglé.com/./path/../path2/')
>>> parsed_url.hostname
'www.googlé.com'
>>> parsed_url.path
'/./path/../path2/'

Alternative Python bindings

This package uses CFFI to call the Ada library’s functions, which has a performance cost. The alternative can_ada (Canadian Ada) package uses pybind11 to generate a Python extension module, which is more performant.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

ada_url-1.15.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (481.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

ada_url-1.15.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (485.0 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

ada_url-1.15.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (481.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

ada_url-1.15.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (485.0 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

ada_url-1.15.0-cp312-cp312-musllinux_1_1_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

ada_url-1.15.0-cp312-cp312-musllinux_1_1_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ ARM64

ada_url-1.15.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (556.7 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

ada_url-1.15.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (556.9 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

ada_url-1.15.0-cp311-cp311-musllinux_1_1_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

ada_url-1.15.0-cp311-cp311-musllinux_1_1_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ ARM64

ada_url-1.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (555.7 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

ada_url-1.15.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (556.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

ada_url-1.15.0-cp310-cp310-musllinux_1_1_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

ada_url-1.15.0-cp310-cp310-musllinux_1_1_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

ada_url-1.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (555.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

ada_url-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (556.0 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

ada_url-1.15.0-cp39-cp39-musllinux_1_1_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

ada_url-1.15.0-cp39-cp39-musllinux_1_1_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

ada_url-1.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (555.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

ada_url-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (556.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

ada_url-1.15.0-cp38-cp38-musllinux_1_1_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

ada_url-1.15.0-cp38-cp38-musllinux_1_1_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

ada_url-1.15.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (555.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

ada_url-1.15.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (556.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

File details

Details for the file ada_url-1.15.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1f204247e5325a6a6f7d5307a3ddf7167938b25a6fe427368eb575af7ea27fa3
MD5 e45828b0cf14138d5df937eb45745a5a
BLAKE2b-256 2060756aee63386e08287e25e881ddf821371e498a68dcd1b878c9087921b733

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 740a5d15339255bd7a29e62c554dafd43733de20b1d70823afff069335c175ce
MD5 f5781ac1fbfa5911feb00b77dfb74bca
BLAKE2b-256 da6126d1265e3de6c10345330d32f664ffb23bb19d1249432a68232471f97606

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c09d86a758fb62dbde2338fdf134883cbbd5acb350ee770601ee453ce4df4ea
MD5 a950016fd4723cac190614c4949dfd7b
BLAKE2b-256 98f627d4d808365e934306a7716600722979206d5977459270c7010c780bc8ba

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4089de679370e3ca602b0bf96983db458760c61ef37633f2773ac636e6dcda98
MD5 554f9afdbefc59b1a7ee2617f927db98
BLAKE2b-256 a4d258ec06984243ed759e11817dabd32bcc98651f1e72deb32e134307b53d75

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp312-cp312-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 508f2d45eef6fb3451bbf5566648fb1225469e32782a7d11201bec8610dcc38d
MD5 00aa6722a227fda2af8bf208a1ef8dd2
BLAKE2b-256 6defce43c8022ded1bff2a4fc4cdb48bb55708ac91904aeb200035d02c8c6d01

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp312-cp312-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp312-cp312-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 aceda1bd161831a4623483638d8f2d4262503c078f7115c52c0a5d4f7342eadc
MD5 373673bb4697fb4b673899b6cfb7f253
BLAKE2b-256 d1568e4a2d22b0483262df61a8d2c0cf2dbf2559e84a409179648e94021e7d69

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b6f881f4588f06e8baa25a0ce2f06f90b494b2eb5e3890d073c3edfca6f7eee
MD5 60e9327de0e1f66a3de355d6e2cb1da8
BLAKE2b-256 ca0d27b52d26befaf2a21896fcf0932022618d587af91393481b826ab7645c30

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5f2801896db49a799eb14bc459cb77bddc4d2b45f10f759d3ec6d4691d594d4e
MD5 db5e918e11ac043451978f771edd4acc
BLAKE2b-256 78c5837ae6699d67496100f63b6a965d56bb577d47363cd00de9e8620c66fa56

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 8ad724cc3419acd10c231ca2281f935f0193a2abd706a0763780f64f582ed9f0
MD5 773a5f30be0cab387c8a87e100174b04
BLAKE2b-256 5f704a9f15ba41b3f30112a8c66e724a7fc7095b7a74106d9c19f9bd2b7f10f3

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp311-cp311-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp311-cp311-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 8c7a8ea1aaf23cd43f7208c961e4b17c7d1f7afd0ec9482c96db4ebd218414fd
MD5 9cfb72f10c92e4a421def528cbbf245a
BLAKE2b-256 656dc19fde733648ca5603b10a007a1c14cf8df4f9a2ca909c10881381ad9072

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 575029b231e614531d014d1c5b713b31cd23e5a28b92f894f0ed09a34fb6b9ac
MD5 b145e6987a9d211f8a5bc8bb15b76e52
BLAKE2b-256 b695e18f65c4cc41ec0fdd56780759250fdc81d9df2f394cb907f6aff8eb67ca

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5e4187481b4e7b728314d7d6790839169075eff5b4b2e3e74a2ee1b3040bd998
MD5 8cdfcfec9de2a3b0a0653b316f27c305
BLAKE2b-256 c761bdf7fca309f937a2c90397beabb7ae8ea6e1e7edc4cb201324ccd2fd5327

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 08117a733ef5b9450a36013e82a5812701ab557886b9b8f5d4dde675bf64c13a
MD5 4232829949df149b62ac4d992206a9e3
BLAKE2b-256 dfca66ece7fcf6e44e04f71b9b221462d71b3e6e7de2fe1006fdb972f003bee9

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp310-cp310-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp310-cp310-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 3029652f6b982bd64678a89f5195ddabf2a35a591a6b517e9b0ca7ad28b032fe
MD5 9843fdccf9ebbf2ffd06681e6a43e9a7
BLAKE2b-256 39ec0690c6081d81ebfcce36b73e9698c5dfda840baa8b00e3451945ed37cb6f

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af2c4314f5cc9fbad77bdc8878c2c7ed6b06ec6f036d7c0c16e062cdf2b48bfb
MD5 abf481258a510331eff44af35cdfe73e
BLAKE2b-256 0b08d0cad3119d1102beeff0ae5ea8912bb2aef868d01b50a03b796b1e3d6d89

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0f07ba5d5adcbda095b8efce170bc45e0b81b9df2dd8beac461f99fd61544f6b
MD5 4b19c33056371707a5900bd397efae63
BLAKE2b-256 ef7225c671f065396b70645f55782ef39d612f66da073644344c6febcdae7882

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 d88af037b5e870051ab35ed85b618aca99e1b96c385d3b12fc8e8b644c0d8313
MD5 ca2f29dc9694c78e603b722b12258e37
BLAKE2b-256 f14d6fb114f2a9ba74618d172cd2636277e330ed1d4271218293a0106625bd39

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp39-cp39-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp39-cp39-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 b41499d8c1571ffeae309c62eee392a08d858d424492dbc4c76b2a3e293e4789
MD5 14fed9c954a82b1515ee3ad1f688a4a8
BLAKE2b-256 32c00f154f1ecfdb8d163a91c285f6a324549797d6f570f6d74f0e95060c4046

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea2aa36ec5e1bc4d3bccfdcb281913291c784224405abc013336ba449d626ddf
MD5 37936ba1b877d54e042bd5cdd5cea676
BLAKE2b-256 76b2e37f51bd5265d3c501dfa8016807f654eea10877e97cd1e6ffa2f27d1dab

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fe01e835c36af193bed504bbdc6cd7faae65e034355aea74cc524d78704f3d42
MD5 281a16f73ca3a2d55f338c9ddcf8f674
BLAKE2b-256 190ba534a31246ccb12d7515f4cd677bf563ee64fd72b53dcc897653dfd0f051

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 4facfcb2f79f4aef6159be562ebc6f012dd6a112abfbd3eec398d8c7e641a453
MD5 f498c200b2897e7ae8aea3ba5efe3469
BLAKE2b-256 12b348be96e300ab6c7085c479e1d7ac827249f7f5656012cf829ff45b6b49fc

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp38-cp38-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp38-cp38-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 91e0b363a727eede0fa2f98a3049596388af0ab5d53a721725dffaa9512356df
MD5 c1b03eabb0859786b41a46e319316736
BLAKE2b-256 d66a9988a0c0c4491010220ca5a836dc78564f86fb1a8ed41aaa4c449cf43867

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 175d6232fa13899a4e4156083c7cfe82f9a9542eb70d5d361c1608714dc68add
MD5 b39a1a91c23c1c1cd615564a8fa1a118
BLAKE2b-256 b4eea989a1d8d576e6d87a85e1e63808a1601ac9a73bf4e55f7b91345eec7dc2

See more details on using hashes here.

File details

Details for the file ada_url-1.15.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ada_url-1.15.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3eb620ea7bcb7d085295048e2e61d462b57c72cf4a06ee3e0b02fb3694b31d97
MD5 43bf089619edc1bd4a7cb231c27ff3f6
BLAKE2b-256 9dda9c2d6ad5d020e6a4bb5864afd453cfa9bac7784fb68140ebf70f7bcad397

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page