Skip to content
RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
Python Ruby Other
Branch: master
Clone or download
joernhees Merge pull request #941 from joernhees/fixupSparqlConnector
make SPARQLConnector work with DBpedia
Latest commit e004802 Oct 31, 2019


Build Status Coveralls branch GitHub stars PyPI PyPI

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information as graphs.

RDFLib may be installed with pip (use sudo as required):

$ pip install rdflib

Alternatively manually download the package from the Python Package Index (PyPI) at

The current version of RDFLib is 4.2.2, see the file for what's new.

Getting Started

RDFLib aims to be a pythonic RDF API, a Graph is a python collection of RDF Subject,Predicate,Object Triples:

import rdflib

for s,p,o in g:
    print s,p,o

The components of the triples are URIs (resources) or Literals (values), URIs are grouped together by namespace, common namespaces are included in RDFLib:

type=g.value(semweb, rdflib.RDFS.label)

Where rdflib.RDFS is the RDFS Namespace, graph.value returns an object of the triple-pattern given (or an arbitrary one if more exist). New Namespaces can also be defined:


abstracts=list(x for x in g.objects(semweb, dbpedia['abstract']) if x.language=='en')

See also ./examples


The library contains parsers and serializers for RDF/XML, N3, NTriples, N-Quads, Turtle, TriX, RDFa and Microdata.

The library presents a Graph interface which can be backed by any one of a number of Store implementations.

This core RDFLib package includes store implementations for in memory storage and persistent storage on top of the Berkeley DB.

A SPARQL 1.1 implementation is included - supporting SPARQL 1.1 Queries and Update statements.

RDFLib is open source and is maintained on GitHub. RDFLib releases, current and previous are listed on PyPI

RDFLib has a plugin-architecture for store-implementation, as well as parsers/serializers, several other projects exist which extend RDFLib features:


More information is available on the project webpage:

The documentation can be built by doing::

$ python build_sphinx

And is also available from ReadTheDocs:

Support is available through the rdflib-dev group:

and on the IRC channel #rdflib on the server

You can’t perform that action at this time.