{"id":15035171,"url":"https://github.com/rdflib/rdflib","last_synced_at":"2026-02-13T12:21:32.766Z","repository":{"id":2377038,"uuid":"3342046","full_name":"RDFLib/rdflib","owner":"RDFLib","description":"RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.","archived":false,"fork":false,"pushed_at":"2025-05-05T05:49:57.000Z","size":23152,"stargazers_count":2254,"open_issues_count":334,"forks_count":572,"subscribers_count":82,"default_branch":"main","last_synced_at":"2025-05-06T19:52:02.884Z","etag":null,"topics":["graph","json-ld","linked-data","n3","namespace","nquads","ntriples","parser","pypi","python","python-library","rdf","rdf-xml","rdflib","semantic-web","serializer","sparql","turtle","turtle-rdf","uri"],"latest_commit_sha":null,"homepage":"https://rdflib.readthedocs.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RDFLib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":"CODEOWNERS","security":"docs/security_considerations.rst","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-02-03T05:49:13.000Z","updated_at":"2025-04-30T21:55:19.000Z","dependencies_parsed_at":"2023-01-16T18:31:12.523Z","dependency_job_id":"e6953048-fad9-4995-8ac0-dbd56066f41e","html_url":"https://github.com/RDFLib/rdflib","commit_stats":{"total_commits":4206,"total_committers":192,"mean_commits":21.90625,"dds":0.7998097955301949,"last_synced_commit":"0ecc40009ae397c2798c0c08a2d751a1a9d2f8a7"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RDFLib%2Frdflib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RDFLib%2Frdflib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RDFLib%2Frdflib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RDFLib%2Frdflib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RDFLib","download_url":"https://codeload.github.com/RDFLib/rdflib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020475,"owners_count":22000750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graph","json-ld","linked-data","n3","namespace","nquads","ntriples","parser","pypi","python","python-library","rdf","rdf-xml","rdflib","semantic-web","serializer","sparql","turtle","turtle-rdf","uri"],"created_at":"2024-09-24T20:27:43.762Z","updated_at":"2026-02-13T12:21:32.750Z","avatar_url":"https://github.com/RDFLib.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](docs/_static/RDFlib.png)\n\n# RDFLib\n\n[![Build Status](https://github.com/RDFLib/rdflib/actions/workflows/validate.yaml/badge.svg?branch=main)](https://github.com/RDFLib/rdflib/actions?query=branch%3Amain)\n[![Documentation Status](https://readthedocs.org/projects/rdflib/badge/?version=latest)](https://rdflib.readthedocs.io/en/latest/?badge=latest)\n[![Coveralls branch](https://img.shields.io/coveralls/RDFLib/rdflib/main.svg)](https://coveralls.io/r/RDFLib/rdflib?branch=main)\n\n[![GitHub stars](https://img.shields.io/github/stars/RDFLib/rdflib.svg)](https://github.com/RDFLib/rdflib/stargazers)\n[![Downloads](https://pepy.tech/badge/rdflib/week)](https://pepy.tech/project/rdflib)\n[![PyPI](https://img.shields.io/pypi/v/rdflib.svg)](https://pypi.python.org/pypi/rdflib)\n[![PyPI](https://img.shields.io/pypi/pyversions/rdflib.svg)](https://pypi.python.org/pypi/rdflib)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6845245.svg)](https://doi.org/10.5281/zenodo.6845245)\n\n[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/RDFLib/rdflib)\n[![Gitter](https://badges.gitter.im/RDFLib/rdflib.svg)](https://gitter.im/RDFLib/rdflib?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n[![Matrix](https://img.shields.io/matrix/rdflib:matrix.org?label=matrix.org%20chat)](https://matrix.to/#/#RDFLib_rdflib:gitter.im)\n\nRDFLib is a pure Python package for working with [RDF](http://www.w3.org/RDF/). RDFLib contains most things you need to work with RDF, including:\n\n* parsers and serializers for RDF/XML, N3, NTriples, N-Quads, Turtle, TriX, Trig, JSON-LD and even HexTuples\n* a Graph interface which can be backed by any one of a number of Store implementations\n* Store implementations for in-memory, persistent on disk (Berkeley DB) and remote SPARQL endpoints\n    * additional Stores can be supplied via plugins \n* a SPARQL 1.1 implementation - supporting SPARQL 1.1 Queries and Update statements\n* SPARQL function extension mechanisms\n\n## RDFlib Family of packages\nThe RDFlib community maintains many RDF-related Python code repositories with different purposes. For example:\n\n* [rdflib](https://github.com/RDFLib/rdflib) - the RDFLib core\n* [sparqlwrapper](https://github.com/RDFLib/sparqlwrapper) - a simple Python wrapper around a SPARQL service to remotely execute your queries\n* [pyLODE](https://github.com/RDFLib/pyLODE) - An OWL ontology documentation tool using Python and templating, based on LODE.\n* [pyrdfa3](https://github.com/RDFLib/pyrdfa3) - RDFa 1.1 distiller/parser library: can extract RDFa 1.1/1.0 from (X)HTML, SVG, or XML in general.\n* [pymicrodata](https://github.com/RDFLib/pymicrodata) - A module to extract RDF from an HTML5 page annotated with microdata.\n* [pySHACL](https://github.com/RDFLib/pySHACL) - A pure Python module which allows for the validation of RDF graphs against SHACL graphs.\n* [OWL-RL](https://github.com/RDFLib/OWL-RL) - A simple implementation of the OWL2 RL Profile which expands the graph with all possible triples that OWL RL defines.\n\nPlease see the list for all packages/repositories here:\n\n* \u003chttps://github.com/RDFLib\u003e\n\nHelp with maintenance of all of the RDFLib family of packages is always welcome and appreciated.\n\n## Versions \u0026 Releases\n\n* `main` branch in this repository is the current unstable release - version 8 alpha\n* `7.4.0` a few small fixes, add test matrix for active python versions, and move v7 documentation to MkDocs\n* `7.3.0` many fixes and usability improvements, particularly for the Dataset class. See changelog for details\n* `7.2.1` tiny clean up release, relaxes Python version requirement\n* `7.2.0` general fixes and usability improvements, see changelog for details\n* `7.1.4` tidy-up release, possibly last 7.x release\n* `7.1.3` current stable release, small improvements to 7.1.1\n* `7.1.2` previously deleted release\n* `7.1.1` previous stable release\n    * see \u003chttps://github.com/RDFLib/rdflib/releases/tag/7.1.1\u003e\n* `7.0.0` previous stable release, supports Python 3.8.1+ only.\n    * see [Releases](https://github.com/RDFLib/rdflib/releases)\n* `6.x.y` supports Python 3.7+ only. Many improvements over 5.0.0\n    * see \u003chttps://github.com/RDFLib/rdflib/releases/tag/6.3.2\u003e\n* `5.x.y` supports Python 2.7 and 3.4+ and is [mostly backwards compatible with 4.2.2](https://rdflib.readthedocs.io/en/stable/upgrade4to5.html).\n  * * see \u003chttps://github.com/RDFLib/rdflib/releases/tag/5.0.0\u003e\n\nSee \u003chttps://github.com/RDFLib/rdflib/releases/\u003e for the release details.\n\n## Documentation\nSee \u003chttps://rdflib.readthedocs.io\u003e for our documentation built from the code. Note that there are `latest`, `stable` and versioned builds, such as `5.0.0`, matching releases.\n\n## Installation\nThe stable release of RDFLib may be installed with Python's package management tool *pip*:\n\n    $ pip install rdflib\n\nSome features of RDFLib require optional dependencies which may be installed using *pip* extras:\n\n    $ pip install rdflib[berkeleydb,networkx,html,lxml,orjson]\n\nAlternatively manually download the package from the Python Package\nIndex (PyPI) at https://pypi.python.org/pypi/rdflib\n\n### Installation of the current main branch (for developers)\n\nWith *pip* you can also install rdflib from the git repository with one of the following options:\n\n    $ pip install git+https://github.com/rdflib/rdflib@main\n\nor\n\n    $ pip install -e git+https://github.com/rdflib/rdflib@main#egg=rdflib\n\nor from your locally cloned repository you can install it with one of the following options:\n\n    $ poetry install  # installs into a poetry-managed venv\n\nor\n\n    $ pip install -e .\n\n## Getting Started\nRDFLib aims to be a pythonic RDF API. RDFLib's main data object is a `Graph` which is a Python collection\nof RDF *Subject, Predicate, Object* Triples:\n\nTo create graph and load it with RDF data from DBPedia then print the results:\n\n```python\nfrom rdflib import Graph\ng = Graph()\ng.parse('http://dbpedia.org/resource/Semantic_Web')\n\nfor s, p, o in g:\n    print(s, p, o)\n```\nThe components of the triples are URIs (resources) or Literals\n(values).\n\nURIs are grouped together by *namespace*, common namespaces are included in RDFLib:\n\n```python\nfrom rdflib.namespace import DC, DCTERMS, DOAP, FOAF, SKOS, OWL, RDF, RDFS, VOID, XMLNS, XSD\n```\n\nYou can use them like this:\n\n```python\nfrom rdflib import Graph, URIRef, Literal\nfrom rdflib.namespace import RDFS, XSD\n\ng = Graph()\nsemweb = URIRef('http://dbpedia.org/resource/Semantic_Web')\ntype = g.value(semweb, RDFS.label)\n```\nWhere `RDFS` is the RDFS namespace, `XSD` the XML Schema Datatypes namespace and `g.value` returns an object of the triple-pattern given (or an arbitrary one if multiple exist).\n\nOr like this, adding a triple to a graph `g`:\n\n```python\ng.add((\n    URIRef(\"http://example.com/person/nick\"),\n    FOAF.givenName,\n    Literal(\"Nick\", datatype=XSD.string)\n))\n```\n\nThe triple (in n-triples notation) `\u003chttp://example.com/person/nick\u003e \u003chttp://xmlns.com/foaf/0.1/givenName\u003e \"Nick\"^^\u003chttp://www.w3.org/2001/XMLSchema#string\u003e .`\nis created where the property `FOAF.givenName` is the URI `\u003chttp://xmlns.com/foaf/0.1/givenName\u003e` and `XSD.string` is the\nURI `\u003chttp://www.w3.org/2001/XMLSchema#string\u003e`.\n\nYou can bind namespaces to prefixes to shorten the URIs for RDF/XML, Turtle, N3, TriG, TriX \u0026 JSON-LD serializations:\n\n```python\ng.bind(\"foaf\", FOAF)\ng.bind(\"xsd\", XSD)\n```\n\nThis will allow the n-triples triple above to be serialised like this:\n\n```python\nprint(g.serialize(format=\"turtle\"))\n```\n\nWith these results:\n```turtle\nPREFIX foaf: \u003chttp://xmlns.com/foaf/0.1/\u003e\nPREFIX xsd: \u003chttp://www.w3.org/2001/XMLSchema#\u003e\n\n\u003chttp://example.com/person/nick\u003e foaf:givenName \"Nick\"^^xsd:string .\n```\n\nNew Namespaces can also be defined:\n\n```python\ndbpedia = Namespace('http://dbpedia.org/ontology/')\n\nabstracts = list(x for x in g.objects(semweb, dbpedia['abstract']) if x.language=='en')\n```\n\nSee also [./examples](./examples)\n\n## Features\nThe library contains parsers and serializers for RDF/XML, N3,\nNTriples, N-Quads, Turtle, TriX, JSON-LD, RDFa and Microdata.\n\nThe library presents a Graph interface which can be backed by\nany one of a number of Store implementations.\n\nThis core RDFLib package includes store implementations for\nin-memory storage and persistent storage on top of the Berkeley DB.\n\nA SPARQL 1.1 implementation is included - supporting SPARQL 1.1 Queries and Update statements.\n\nRDFLib is open source and is maintained on [GitHub](https://github.com/RDFLib/rdflib/). RDFLib releases, current and previous\nare listed on [PyPI](https://pypi.python.org/pypi/rdflib/)\n\nMultiple other projects are contained within the RDFlib \"family\", see \u003chttps://github.com/RDFLib/\u003e.\n\n## Running tests\n\n### Running the tests on the host\n\nRun the test suite with `pytest`.\n```shell\npoetry install\npoetry run pytest\n```\n\n### Running test coverage on the host with coverage report\n\nRun the test suite and generate a HTML coverage report with `pytest` and `pytest-cov`.\n```shell\npoetry run pytest --cov\n```\n\n### Viewing test coverage\n\nOnce tests have produced HTML output of the coverage report, view it by running:\n```shell\npoetry run pytest --cov --cov-report term --cov-report html\npython -m http.server --directory=htmlcov\n```\n\n## Contributing\n\nRDFLib survives and grows via user contributions!\nPlease read our [contributing guide](https://rdflib.readthedocs.io/en/latest/CONTRIBUTING/) and [developers guide](https://rdflib.readthedocs.io/en/latest/developers/) to get started.\nPlease consider lodging Pull Requests here:\n\n* \u003chttps://github.com/RDFLib/rdflib/pulls\u003e\n\nTo get a development environment consider using Gitpod or Google Cloud Shell.\n\n[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/RDFLib/rdflib)\n[![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://shell.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2FRDFLib%2Frdflib\u0026cloudshell_git_branch=main\u0026cloudshell_open_in_editor=README.md)\n\nYou can also raise issues here:\n\n* \u003chttps://github.com/RDFLib/rdflib/issues\u003e\n\n## Support \u0026 Contacts\nFor general \"how do I...\" queries, please use https://stackoverflow.com and tag your question with `rdflib`.\nExisting questions:\n\n* \u003chttps://stackoverflow.com/questions/tagged/rdflib\u003e\n\nIf you want to contact the rdflib maintainers, please do so via:\n\n* the rdflib-dev mailing list: \u003chttps://groups.google.com/group/rdflib-dev\u003e\n* the chat, which is available at [gitter](https://gitter.im/RDFLib/rdflib) or via matrix [#RDFLib_rdflib:gitter.im](https://matrix.to/#/#RDFLib_rdflib:gitter.im)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdflib%2Frdflib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frdflib%2Frdflib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdflib%2Frdflib/lists"}