data_url.py
data_url is a Python 3 library which provides easy methods for creating and working with data URL's. The full API documentation is available here.
Examples
Creating a data URL
If all you need is to create a URL and nothing else there is a shortcut method included so you don't need to directly instantiate the DataURL class.
import data_url
with open('image.jpeg', 'rb') as image:
data = image.read()
url = data_url.construct_data_url(mime_type='image/jpeg', base64_encoded=True, data=data)
If you need the information to persist it is recommended to instantiate a class through one of the factory methods on DataURL
import data_url
with open('image.jpeg', 'rb') as image:
data = image.read()
url = data_url.DataURL.from_data('image/jpeg', True, data)
print(str(url))
You can access the full data URL by either converting the DataURL object to a string as above or by accessing the url attribute.
Retrieving data from a URL
Given you already have a data URL you can instantiate a DataURL object and retrieve each individual attribute.
import data_url
raw_url = "data:application/json;base64,ewogICJ0ZXN0IjogMTIzCn0K"
url = data_url.DataURL.from_url(raw_url)
print(url.mime_type, url.is_base64_encoded, url.data)
Metadata
Release files for data-url 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| data_url-1.4.0.tar.gz | 6.5 kB | With provenance | Details for data_url-1.4.0.tar.gz |
Release files / data_url-1.4.0.tar.gz
| Download URL | data_url-1.4.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21a13f65fa3b3c75b1d7beb56bbb47b46110e8ae21bdcfe20c3da05a7fc59521
|
|
BLAKE2b-256 checksum How to use checksums |
5466f5778a96f6853819c7555cda4d821031403d626865369bd0d9706565bd08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency logSecurity for data-url 1.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 1 file in this release has been uploaded with provenance metadata.
Attestation for data_url-1.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.