RDFLib is a Python package for parsing, storing, and querying RDF. It includes serializers, in-memory and persistent stores, and SPARQL 1.1 support.
Overview
RDFLib helps Python developers work with Resource Description Framework data for semantic web and linked-data projects. The central Graph type holds subject–predicate–object triples and can be populated by parsers or programmatic triple insertion using namespace-aware URIs and typed literals.
Built-in parsers and serializers cover RDF/XML, Turtle, N-Triples, N-Quads, N3, TriG, TriX, JSON-LD, HexTuples, RDFa, and Microdata. Namespace helpers shorten common vocabularies, and binding prefixes affects serialized output across major syntaxes.
Storage backends include in-memory graphs, Berkeley DB persistence, and remote SPARQL endpoints, with additional stores available through plugins. A SPARQL 1.1 engine supports query and update operations plus extension hooks for custom functions.
Installable from PyPI via pip, with optional extras for BerkeleyDB, NetworkX, HTML, lxml, or orjson integrations. Documentation warns that processing untrusted RDF may trigger file or network access, so callers should apply appropriate restrictions. Related packages in the RDFLib organization extend specific integrations such as GraphDB or RDF4J clients.
Key features
- RDF parse and serialize formats
- Graph and dataset interfaces
- SPARQL 1.1 queries and updates
- In-memory and Berkeley DB stores
- Remote SPARQL endpoint stores
- Namespace and prefix binding
- Plugin-extensible store layer
- Optional PyPI feature extras
Use cases
- Loading linked-data vocabularies
- Running SPARQL over RDF files
- Building semantic web pipelines
- Persisting RDF graphs on disk