skillfed

SPARQLWrapper

SPARQL Endpoint interface to Python

sparqlwrapper v2.0.0 1.4M downloads/30d#3,919 on PyPI565
License unclear W3C SOFTWARE NOTICE AND LICENSE Active released

What it is and what it does

SPARQLWrapper is a Python client library that abstracts the complexity of communicating with remote SPARQL endpoints over HTTP. It lets you write SPARQL queries (SELECT, ASK, CONSTRUCT, DESCRIBE, UPDATE) in Python code, handles the HTTP protocol details, and automatically converts responses into Python-friendly formats—JSON objects, XML trees, or rdflib Graph objects—depending on the query type and your chosen return format.

The package is built on rdflib and supports multiple authentication methods, HTTP verbs, and result serializations. It includes both a Python API for programmatic use and a command-line tool (rqw) for ad-hoc queries. It's stable (Production/Stable status), supports Python 3.7, 3.8, 3.9, and 3.10, and has been in active maintenance.

Use it for:

  • Query DBpedia or other public linked-data endpoints to retrieve structured facts about entities (people, places, concepts).
  • Build a semantic search or knowledge-graph application that needs to fetch RDF data from a remote triple store.
  • Integrate SPARQL queries into data pipelines that combine linked data with other Python data processing libraries.
  • Prototype or test SPARQL queries against a development endpoint before deploying them to production systems.
  • Retrieve and transform RDF graphs from remote endpoints into formats suitable for analysis or visualization.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

SPARQLWrapper provides a Python interface to query remote SPARQL endpoints, handling query construction and result conversion into manageable formats like JSON, XML, and RDF graphs.

Yes. SPARQLWrapper is a mature, actively maintained library with low install friction and no known vulnerabilities. It's the standard Python tool for SPARQL endpoint access. Install it if you need to query remote RDF data sources; the only caveat is to review the W3C license terms for your use case.

Install

sparqlwrapper on PyPI

pip

pip install sparqlwrapper

uv

uv add sparqlwrapper

poetry

poetry add sparqlwrapper

Installing SPARQLWrapper

Before you install

Low install friction with a single runtime dependency (rdflib). Actively maintained with recent commits and ongoing repository activity.

License in practice

Licensed under W3C SOFTWARE NOTICE AND LICENSE with unclear SPDX mapping. Review the license text before use in proprietary or commercial contexts to confirm compatibility with your project's requirements.

Quickstart

from SPARQLWrapper import SPARQLWrapper, JSON

sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setReturnFormat(JSON)
sparql.setQuery("SELECT * WHERE { ?s ?p ?o } LIMIT 1")
results = sparql.queryAndConvert()
print(results["results"]["bindings"])

Requires a live SPARQL endpoint URL; queries will fail if the endpoint is unreachable or does not support the requested query type.

Verify before relying

  • Whether the W3C SOFTWARE NOTICE AND LICENSE is compatible with common open-source or proprietary licensing frameworks.
  • Current status of the package relative to SPARQL 1.1 specification compliance.

Package facts

License W3C SOFTWARE NOTICE AND LICENSE (unclear)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 1 — rdflib
Maintenance actively maintained — 1,615 days since the last release
Last repo commit
First released
Downloads 1,424,048/month — #3,919 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: SPARQLWrapper-2.0.0-py3-none-any.whl

Keywords: python, sparql, rdf, rdflib

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: W3C LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Libraries :: Python Modules

Tags

sparql endpoint clientrdf query pythonsemantic web querieslinked data accesssparql wrapperrdf graph queriesw3c sparql protocol
semantic-weblinked-datardf

More Python Modules packages