urlpath
Object-oriented URL from urllib.parse and pathlib
What it is and what it does
URLPath is a Python library that wraps URL strings in an object-oriented interface modeled after pathlib.PurePath, treating URLs as hierarchical paths. It lets you decompose URLs into components (scheme, netloc, username, password, hostname, port, path, query, fragment), navigate and manipulate them using familiar path operators (/ for joining, .parent for going up), and rebuild URLs with modified parts using methods like with_scheme(), with_query(), and with_fragment().
Beyond path operations, URLPath integrates requests to let you call HTTP verbs (get, post, put, patch, delete) directly on URL objects, and provides a "jailed" mode to restrict path traversal outside a root URL. It handles query strings as both raw strings and as form field tuples, and preserves trailing slashes. The package targets developers who want to work with URLs programmatically without manually parsing and reconstructing URL strings.
Use it for:
- Build URLs dynamically by composing path segments and query parameters using pathlib-like operators instead of string concatenation.
- Extract and modify individual URL components (hostname, port, credentials, query fields) without regex or manual parsing.
- Make HTTP requests directly from URL objects using get(), post(), put(), patch(), delete() methods.
- Restrict URL navigation to a root domain using jailed mode to prevent accidental traversal to external hosts.
- Normalize and compare URLs by treating them as structured objects with predictable component access.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
URLPath extends pathlib.PurePath to treat URLs as filesystem-like objects, letting you manipulate URL components (scheme, netloc, path, query, fragment) using familiar path operations and make HTTP requests directly from URL objects.
Yes, if you work with URLs programmatically and prefer object-oriented manipulation over string parsing. The low install friction, permissive MIT license, and stable API make it a safe dependency. The aging maintenance status (last release 305 days ago) is not a blocker for a mature library with no known vulnerabilities, but monitor the repository for critical fixes. Not necessary if you only build URLs occasionally or are already comfortable with urllib.parse.
Install
urlpath on PyPI
pip
pip install urlpathuv
uv add urlpathpoetry
poetry add urlpathInstalling urlpath
Before you install
Low install friction: pure Python wheel with only two runtime dependencies (requests and charset-normalizer). Maintenance signal is aging—last release was 305 days ago, though the repository remains active and the package has been stable since its 2015 initial release.
License in practice
MIT license is permissive; you can use, modify, and distribute URLPath freely in commercial and private projects with minimal restrictions.
Quickstart
pip install urlpath
from urlpath import URL
url = URL('https://example.com/path?field=value#fragment')
print(url.scheme) # 'https'
print(url.hostname) # 'example.com'
print(url.path) # '/path'
response = url.get() # Make HTTP GET request
Requires Python 3.9 or later.
Verify before relying
- Whether optional dependencies (JMESPath, WebOb) are actually used by the package or are legacy references.
- Performance characteristics when manipulating very large or complex URLs.
- Whether the jailed mode fully prevents directory traversal attacks or is a convenience feature only.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — charset-normalizer, requests |
| Maintenance | aging — 305 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 133,666/month — #11,499 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: urlpath-2.0.0-py3-none-any.whl
Keywords: http, pathlib, requests, uri, url, urllib
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
furlfurl parses and manipulates URLs by providing a…
permissive · top 5,000 on PyPI
pyuriPyURI parses, constructs, and manipulates URIs…
permissive · top 15,000 on PyPI
dsnparseParses DSN (Data Source Name) connection URL…
permissive · top 15,000 on PyPI
urlpyurlpy parses, normalizes, and compares URLs…
permissive · top 15,000 on PyPI
pathlib2Backport of Python's standard pathlib module…
permissive · top 5,000 on PyPI
purlProvides an immutable, chainable URL class for…
permissive · top 15,000 on PyPI
pathlibProvides object-oriented filesystem path…
permissive · top 5,000 on PyPI
hyperlinkHyperlink provides an immutable, RFC…
permissive · top 1,000 on PyPI
url-normalizeStandardizes URLs to a canonical form by…
permissive · top 1,000 on PyPI
s3pathlibs3pathlib provides a pathlib-like…
permissive · top 5,000 on PyPI