mediatype
Media Type parsing and creation
What it is and what it does
mediatype is a lightweight library for parsing and constructing MIME types (also called media types or content types). It breaks down a media type string like 'application/manifest+json' into its structural components—type, subtype, suffix, and optional parameters—and can reconstruct the string from those components. The library follows RFC-6838 specifications and is useful anywhere HTTP content negotiation, file type handling, or protocol parsing requires reliable media type manipulation.
The package depends only on enumb and installs as a pure Python wheel, making it quick to add to any project. It supports Python 3.8 through 3.10. Because the last release was in April 2022 and the repository shows no recent activity, the package is stable but not actively developed; it is suitable for projects that need straightforward media type handling without expecting ongoing feature additions.
Use it for:
- Parse Content-Type headers in HTTP request/response handlers to extract and validate media types.
- Build or validate MIME type strings programmatically when constructing HTTP responses or file metadata.
- Decompose media types in content negotiation logic to match client Accept headers against server capabilities.
- Normalize or canonicalize media type strings in APIs or data pipelines that consume untrusted input.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and creates MIME types (media types) according to RFC-6838, decomposing them into type, subtype, suffix, and parameters or reconstructing them from components.
Yes, if you need reliable MIME type parsing and don't require active maintenance. The package is stable, has no known vulnerabilities, and solves a narrow, well-defined problem with minimal dependencies. The dormant maintenance status is acceptable for a utility library with a stable specification (RFC-6838), but unsuitable if you need ongoing bug fixes or Python version support beyond 3.10.
Install
mediatype on PyPI
pip
pip install mediatypeuv
uv add mediatypepoetry
poetry add mediatypeInstalling mediatype
Before you install
Low install friction; pure Python wheel with a single lightweight dependency (enumb). Maintenance is dormant—last release was 2022-04-12 and no commits since 2024-08-14, but the repository is not archived and the package remains functional for current Python versions.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install mediatype
import mediatype
media_type = mediatype.parse('application/manifest+json')
print(media_type.type, media_type.subtype, media_type.suffix)
Verify before relying
- Whether the package handles all RFC-6838 edge cases (e.g., quoted parameters, charset encoding) or only common cases.
- Performance characteristics when parsing large numbers of media types or complex parameter strings.
- Whether enumb dependency is actively maintained and compatible with future Python releases.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — enumb |
| Maintenance | dormant — 1,585 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 96,908/month — #13,185 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mediatype-0.1.6-py3-none-any.whl
Keywords: python, mimetype, mediatype, contenttype, mime
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
python-mimeparseParses and matches MIME types against…
permissive · top 5,000 on PyPI
zope.contenttypeGuesses MIME types from filenames and body…
unclear · top 15,000 on PyPI
typecodeDetects file types and MIME types using…
permissive · top 15,000 on PyPI
filetypeInfers file type and MIME type by examining…
permissive · top 1,000 on PyPI
knowitExtracts detailed metadata from media files…
permissive · top 15,000 on PyPI
c2pa-pythonRead, validate, create, and sign C2PA manifest…
permissive · top 15,000 on PyPI
tinytagReads metadata (artist, title, duration,…
permissive · top 5,000 on PyPI
cigamDetects and reports file types, MIME types, and…
permissive · top 15,000 on PyPI
tikaTika-python provides Python access to Apache…
permissive · top 15,000 on PyPI
libmagicProvides Python bindings to the libmagic…
copyleft · top 15,000 on PyPI