{"id":13813194,"url":"https://github.com/ada-url/ada-python","last_synced_at":"2025-05-03T06:31:23.256Z","repository":{"id":166169963,"uuid":"641612870","full_name":"ada-url/ada-python","owner":"ada-url","description":"Python bindings for Ada URL parser","archived":false,"fork":false,"pushed_at":"2025-04-28T16:33:08.000Z","size":1087,"stargazers_count":45,"open_issues_count":4,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-28T17:39:37.984Z","etag":null,"topics":["whatwg-url"],"latest_commit_sha":null,"homepage":"https://ada-url.com","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ada-url.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-05-16T20:57:05.000Z","updated_at":"2025-04-01T14:07:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"f78cfc37-a21b-433e-9464-a088d82d1684","html_url":"https://github.com/ada-url/ada-python","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ada-url%2Fada-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ada-url%2Fada-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ada-url%2Fada-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ada-url%2Fada-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ada-url","download_url":"https://codeload.github.com/ada-url/ada-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252154738,"owners_count":21702983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["whatwg-url"],"created_at":"2024-08-04T04:01:06.734Z","updated_at":"2025-05-03T06:31:18.854Z","avatar_url":"https://github.com/ada-url.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"ada-url\n========\n\nThe `urlib.parse` module in Python does not follow the legacy RFC 3978 standard nor\ndoes it follow the newer WHATWG URL specification. It is also relatively slow.\n\nThis is ``ada_url``, a fast standard-compliant Python library for working with URLs based on the ``Ada`` URL\nparser.\n\n* `Documentation \u003chttps://ada-url.readthedocs.io\u003e`__\n* `Development \u003chttps://github.com/ada-url/ada-python/\u003e`__\n* `Ada \u003chttps://www.ada-url.com/\u003e`__ \n\nInstallation\n------------\n\nInstall from `PyPI \u003chttps://pypi.org/project/ada-url/\u003e`__:\n\n.. code-block:: sh\n\n    pip install ada_url\n\nUsage examples\n--------------\n\nParsing URLs\n^^^^^^^^^^^^\n\nThe ``URL`` class is intended to match the one described in the\n`WHATWG URL spec \u003chttps://url.spec.whatwg.org/#url-class\u003e`_:.\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from ada_url import URL\n    \u003e\u003e\u003e urlobj = URL('https://example.org/path/../file.txt')\n    \u003e\u003e\u003e urlobj.href\n    'https://example.org/path/file.txt'\n\nThe ``parse_url`` function returns a dictionary of all URL elements:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from ada_url import parse_url\n    \u003e\u003e\u003e parse_url('https://user:pass@example.org:80/api?q=1#2')\n    {\n        'href': 'https://user:pass@example.org:80/api?q=1#2',\n        'username': 'user',\n        'password': 'pass',\n        'protocol': 'https:',\n        'port': '80',\n        'hostname': 'example.org',\n        'host': 'example.org:80',\n        'pathname': '/api',\n        'search': '?q=1',\n        'hash': '#2',\n        'origin': 'https://example.org:80',\n        'host_type': \u003cHostType.DEFAULT: 0\u003e,\n        'scheme_type': \u003cSchemeType.HTTPS: 2\u003e\n    }\n\nAltering URLs\n^^^^^^^^^^^^^\n\nReplacing URL components with the ``URL`` class:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from ada_url import URL\n    \u003e\u003e\u003e urlobj = URL('https://example.org/path/../file.txt')\n    \u003e\u003e\u003e urlobj.host = 'example.com'\n    \u003e\u003e\u003e urlobj.href\n    'https://example.com/file.txt'\n\nReplacing URL components with the ``replace_url`` function:\n\n    \u003e\u003e\u003e from ada_url import replace_url\n    \u003e\u003e\u003e replace_url('https://example.org/path/../file.txt', host='example.com')\n    'https://example.com/file.txt'\n\nSearch parameters\n^^^^^^^^^^^^^^^^^\n\nThe ``URLSearchParams`` class is intended to match the one described in the\n`WHATWG URL spec \u003chttps://url.spec.whatwg.org/#interface-urlsearchparams\u003e`__.\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from ada_url import URLSearchParams\n    \u003e\u003e\u003e obj = URLSearchParams('key1=value1\u0026key2=value2')\n    \u003e\u003e\u003e list(obj.items())\n    [('key1', 'value1'), ('key2', 'value2')]\n\nThe ``parse_search_params`` function returns a dictionary of search keys mapped to\nvalue lists:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from ada_url import parse_search_params\n    \u003e\u003e\u003e parse_search_params('key1=value1\u0026key2=value2')\n    {'key1': ['value1'], 'key2': ['value2']}\n\nInternationalized domain names\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe ``idna`` class can encode and decode IDNs:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from ada_url import idna\n    \u003e\u003e\u003e idna.encode('Bücher.example')\n    b'xn--bcher-kva.example'\n    \u003e\u003e\u003e idna.decode(b'xn--bcher-kva.example')\n    'bücher.example'\n\nWHATWG URL compliance\n---------------------\n\nThis library is compliant with the WHATWG URL spec. This means, among other things,\nthat it properly encodes IDNs and resolves paths:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from ada_url import URL\n    \u003e\u003e\u003e parsed_url = URL('https://www.GOoglé.com/./path/../path2/')\n    \u003e\u003e\u003e parsed_url.hostname\n    'www.xn--googl-fsa.com'\n    \u003e\u003e\u003e parsed_url.pathname\n    '/path2/'\n\nContrast that with the Python standard library's ``urlib.parse`` module:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from urllib.parse import urlparse\n    \u003e\u003e\u003e parsed_url = urlparse('https://www.GOoglé.com/./path/../path2/')\n    \u003e\u003e\u003e parsed_url.hostname\n    'www.googlé.com'\n    \u003e\u003e\u003e parsed_url.path\n    '/./path/../path2/'\n\nAlternative Python bindings\n---------------------------\n\nThis package uses `CFFI \u003chttps://github.com/ada-url/ada-python/\u003e`__ to call\nthe ``Ada`` library's functions, which has a performance cost.\nThe alternative `can_ada \u003chttps://github.com/tktech/can_ada\u003e`__ (Canadian Ada)\npackage uses `pybind11 \u003chttps://pybind11.readthedocs.io/en/stable/\u003e`__ to generate a\nPython extension module, which is more performant.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fada-url%2Fada-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fada-url%2Fada-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fada-url%2Fada-python/lists"}