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.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (482.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

ada_url-1.15.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (485.4 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

ada_url-1.15.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (482.8 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

ada_url-1.15.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (485.4 kB view details)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

ada_url-1.15.1-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.1-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.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (558.0 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

ada_url-1.15.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (557.3 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

ada_url-1.15.1-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.1-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.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (556.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

ada_url-1.15.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (556.4 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

ada_url-1.15.1-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.1-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.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (556.8 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

ada_url-1.15.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (556.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

ada_url-1.15.1-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.1-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.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (556.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

ada_url-1.15.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (556.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

ada_url-1.15.1-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.1-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.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (556.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

ada_url-1.15.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (556.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1199429e9eb8625e0e0d5713a420335abf1461ac6d582362c5489980bc18844d
MD5 3511e329536b9771984b1c74fb19e3bb
BLAKE2b-256 1b8c582691ba6a0da5af22c5bec878fcd720f213b326c8879a23adf5e9cd2a44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3729612820da9d43d940dbb47b2e85f236f3c984c2ae0069f369def95872046d
MD5 b24f2f0d69be187c68fbde945e22f575
BLAKE2b-256 e6a17797cf0a0b3c694c47d968af834e3a3b75b929c64c2ce7b61cd03e2ed745

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 09ead0e79d3b9af6772cb373e8016f2c290d1a98d675fd61e9879afaac94bce2
MD5 a2692c3a85b10e53908f6529e246d7c4
BLAKE2b-256 0bbbcf37e343c20c967df2dd287fa81df0ce6af1c4cf9b3bf601d94bb7fc29bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e98c6828e2ecbb3380c91d14d07256ab896718dae0b08dd9b527c6a5d3c9f7ed
MD5 8dad44831d0f02c138488b8d6a47b5be
BLAKE2b-256 2a591015a7a7db119bda07dea6ad6e13360f4d81afffc276e3c4278146d517a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 872a95317526939627852d04b778997f976a4149bd99ec7d23a48b003ab7459f
MD5 449ef06ad29ec59a5affe0bbe6b2b428
BLAKE2b-256 b2804a24fac0ae14115d09ba6e708258be8eab7656d9437f37e5d5cbdeefa465

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp312-cp312-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 7573e45d19936a971fc570cb792d28438880b21bcc178776fabf643988938e9d
MD5 d1ff69f676ab2f74777c21d538fc32fc
BLAKE2b-256 5fd55d43d6eadf22fc1ae80a32621435a6ff17ad6bf9a84c9df77cb295a03fb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7d0a145d58ffd318cb67ecfbefed873eead1d84c9e5dfd232bb9d7e74891786
MD5 b7156b3cc986f8de7d0bd3f5dbe4c0ab
BLAKE2b-256 13b82b95235e64c8b79da826ab1c615b7e5cfa087b26c5d98edfbe2b1a01bb19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1fbbb85527f6a4914312d3f70743d9fd1412b8a7d9c6579a297d9a5161fb7c44
MD5 1590cb73525eaf494af5dbac1d303044
BLAKE2b-256 0a62510bb1a8451ce64b59142cdc282fa3310c2ce049d1eed4010fe9ec25a4da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 aa10c72d26975bbed1313ef63ac7275d7530a07d590a537df819dd0aa190d58b
MD5 3afd3fb651de73ef2a3861ef8cbadcbb
BLAKE2b-256 b7689515365982835c969f3ae01a8674bf78b2711f0970b31ee02806bd446a20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp311-cp311-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 7a7075804b963e9c88c2fea3ddb2dad772f38d668b08e5d79983b6586a94b814
MD5 0b099701d986e15ee2404210a350165a
BLAKE2b-256 3236b1e941f9a864025e67714171ceb2737c2ef1a39422518cdd8f213eb7e22a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a6d29b191cf9c0a937c59590c38b9902c062a8410df95ed70c57a31b475b2df2
MD5 db7fcb312895e3476faf40a2c199e4c7
BLAKE2b-256 13e94014e25a00d1f7ef5a97ea34001cc18fcafeaff649f5bac5cdc3d889ae9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 08968012864728a49ba3f81478147010a9eb4841bec411d276fec923db5d6774
MD5 ccac42c1c2d40bf139799737bb0e2e4b
BLAKE2b-256 8d3d7a386a03f962a73ec9c0a598c3bf1a8506b5008f8fa8544a3b5042de15f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 cbd18f93734e099c265b405eba241bfc38494444a2ff1cce98bba63164e92e82
MD5 5b9f087515a151f292321ccb4d4c25a1
BLAKE2b-256 26865b36f4a7b00dbf5c5bedf6e73728df051aedf53ca4453fd6fd0353d21b7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp310-cp310-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 731dd9bdc596a92a9ffde82907b08bd8dda256e1269f03d83f14c0b90286039d
MD5 73f3206b03aa6e64f61810d261935b07
BLAKE2b-256 130c58235b20b8ca067643f2a89cf8cdc7f4d54ec955082417ad25cbee6b22ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1aaede818a8553249ccb41dc534bfbcc159466d9327ab054a905086afd1d743
MD5 fdb144fc0df8bb59d31d8046b4e47d4d
BLAKE2b-256 f3d0fec5a4790672efade5f7a51fec0a33887a417b7c04fd5b86f131696d6056

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8f3cb74d5ed5a2bb1b3c4754a1d2f4a861056de3943c7230f4ba8529542ebaf3
MD5 ea5b550ac32882e8c7b854a2ce93edd7
BLAKE2b-256 b1518bf686b380130f13a24bf8fc62581231ea981f7901c75fa5498ea0b105a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 4712f2ae3883fdc953eb2fe818b950528b005d118d14ac480966d53f8842a35f
MD5 a03ddee7a4564db152bbd8296c9ded5b
BLAKE2b-256 aac31a710c58215e9f82bd87abb30f7af2c22ef4b24069b1561592bb6d1b823d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp39-cp39-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 34d7c92713d06e2b102d511434969b4b866d9bae3ef3e3f093ce289ca8af141f
MD5 353369fefd0d05e5b966a6c801962bcc
BLAKE2b-256 49502cad0213e5db01d52c38c3a7fcc6e93500b102aacd7fb9da2515e209a6b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e28d6476fd252481eefa4503df3265f2fd78fb40fd778c03b96199489814182
MD5 47f60c14a7fb771ab1b61cbfc14842c8
BLAKE2b-256 aa6e80973e7c0ca7a4c068b2177e045b4552261dba944ba3af4676b28ac41248

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dbaa50f73f7964a4b474877898d13c3463ac4eb49d93d41ea376de0b4b86a903
MD5 7984c2c420b00030d5709ee0ce65b678
BLAKE2b-256 eeea58bbd0461e0f9404db8d9d6f9f17dca2af62253a1963fea124d4bcf30afb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f2dca2c4d480177861239db903a0c29c8c6a2e7f9047d0ccdfa816f8bf4638f0
MD5 10ed498be3d5a83b2f1762a6ef809d35
BLAKE2b-256 cf613125d558d569f64bae755807a4a385908f259fbe030841886d83166a3ef6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp38-cp38-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 fed3c0b0e4d99ff380a3049f8fbd02b5e9fab913b96ea64813b1dbd1e7e61ece
MD5 6bd314bf7b9077c0c133ccb13a69e988
BLAKE2b-256 ce07c9af089fe5e95df4d5a5900b0cc287901a1f287c4bd80cec2e32ab5c3bc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ca8f290eab7d3dfd59770e2cfab6d0d09a4c786f86125c381f4ee8ab0a7d37b
MD5 e88bb09b0f8cb78b4db01f6112f58b1c
BLAKE2b-256 0895a0c1cc47911c30b6f433fb1ba0a5cca101fd9d3830257746122a3587d4ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ada_url-1.15.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0e3ddf95b644704dc9b52ceb81c5f3bd55b18e066c33f6cad9b262628ff62c37
MD5 5dd603cdef2fd05334c2bf97f7acb232
BLAKE2b-256 ecbdbedb5171d5299d23a2badf55f51c71bdb5bce477895e96e2302f98b086b3

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