skillfed

pymantic

Semantic Web and RDF library for Python

pymantic v1.0.1 130.9K downloads/30d#11,621 on PyPI19
Permissive license BSD AGING released

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 pymantic

uv

uv add pymantic

poetry

poetry add pymantic

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTPTopic :: Scientific/Engineering :: Information AnalysisTopic :: Text Processing :: Markup

Tags

RDF parsing and queryingsemantic web libraryturtle parser pythonSPARQL clientRDF graph manipulationlinked data processingN-Triples parser
rdf-semantic-weblinked-datasparql

More WWW/HTTP packages