pymantic
Semantic Web and RDF library for Python
What it is and what it does
Pymantic is a Python library for working with RDF (Resource Description Framework) and semantic web data. It provides parsers for Turtle, N-Triples, and N3 formats, allowing you to load RDF graphs from files or HTTP sources and query them using a Python API. It also includes a SPARQL client for querying remote RDF endpoints.
The library is built on top of rdflib and uses lark for parsing, requests for HTTP access, and pyld for linked-data operations. It's intended for developers working with linked data, knowledge graphs, or semantic web applications who need to parse, manipulate, and query RDF data programmatically in Python.
Use it for:
- Parse Turtle or N-Triples files and query the resulting RDF graph using Python objects and methods.
- Fetch and process RDF data from remote HTTP sources or SPARQL endpoints.
- Build knowledge graph applications that need to work with linked data and semantic relationships.
- Extract scalar values and relationships from RDF resources using prefix-qualified property names.
- Integrate RDF data processing into Python applications without writing raw SPARQL queries.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pymantic parses and queries RDF and semantic web data formats (Turtle, N-Triples, N3) and provides a Python API to work with RDF graphs and SPARQL endpoints.
Yes, if you need RDF parsing and querying in Python. The library has low install friction, permissive licensing, and no known vulnerabilities. However, maintenance is aging (316 days since last release), so evaluate whether the project's pace suits your stability requirements. For active semantic web projects, verify that its SPARQL support and format coverage meet your specific needs.
Install
pymantic on PyPI
pip
pip install pymanticuv
uv add pymanticpoetry
poetry add pymanticInstalling pymantic
Before you install
Low install friction; pure Python wheel with six runtime dependencies (requests, lxml, rdflib, lark, pytz, pyld). Maintenance status is aging—last release was 316 days ago and the repository shows 19 stars, though it remains unarchived and the last commit is recent.
License in practice
BSD permissive license allows commercial and private use with minimal restrictions, making it suitable for most projects that can accommodate attribution.
Quickstart
from pymantic.rdf import Resource, Prefix
from pymantic.parsers import turtle_parser
import requests
Resource.prefixes['foaf'] = Prefix('http://xmlns.com/foaf/0.1/')
graph = turtle_parser.parse(requests.get('https://example.org/data.ttl').text)
resource = Resource(graph, 'http://example.org/item')
name = resource.get_scalar('foaf:name')
Requires Python 3.9 or higher.
Verify before relying
- Whether the aging maintenance status (316 days since last release) affects stability or security for production use.
- Performance characteristics when working with large RDF graphs or high-volume SPARQL queries.
- Completeness of SPARQL 1.1 support and any known limitations in query dialect coverage.
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — requests, lxml, pytz, rdflib, lark, pyld |
| Maintenance | aging — 316 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 130,882/month — #11,621 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pymantic-1.0.1-py3-none-any.whl
Keywords: RDF, N3, Turtle, Semantics
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
pystardogPython client library for querying and managing…
permissive · top 15,000 on PyPI
rdflibRDFLib is a Python library for parsing,…
permissive · top 1,000 on PyPI
pyoxigraphPyoxigraph is a Python library that provides…
permissive · top 15,000 on PyPI
SPARQLWrapperSPARQLWrapper provides a Python interface to…
unclear · top 5,000 on PyPI
sparqlslurperTranslates rdflib Graph.triples() calls into…
permissive · top 15,000 on PyPI
PyShExPyShEx parses and validates RDF data against…
permissive · top 15,000 on PyPI
pyshaclValidates RDF graphs against SHACL shape…
permissive · top 5,000 on PyPI
CFGraphCFGraph extends rdflib's Graph to read RDF…
permissive · top 15,000 on PyPI
owlready2Owlready2 is a Python module for…
copyleft · top 15,000 on PyPI
semanticscholarProvides a typed Python client for querying…
permissive · top 15,000 on PyPI