SPARQLWrapper
SPARQL Endpoint interface to Python
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 sparqlwrapperuv
uv add sparqlwrapperpoetry
poetry add sparqlwrapperInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
sparqlslurperTranslates rdflib Graph.triples() calls into…
permissive · top 15,000 on PyPI
rdflibRDFLib is a Python library for parsing,…
permissive · top 1,000 on PyPI
pymanticPymantic parses and queries RDF and semantic…
permissive · top 15,000 on PyPI
owlrlImplements OWL2 RL Profile and RDFS inference…
unclear · top 5,000 on PyPI
CFGraphCFGraph extends rdflib's Graph to read RDF…
permissive · top 15,000 on PyPI
rdflib-jsonldProvides JSON-LD parsing and serialization for…
permissive · top 15,000 on PyPI
pyoxigraphPyoxigraph is a Python library that provides…
permissive · top 15,000 on PyPI
pystardogPython client library for querying and managing…
permissive · top 15,000 on PyPI
owlready2Owlready2 is a Python module for…
copyleft · top 15,000 on PyPI
prefixmapsRetrieves and manages semantic prefix maps that…
permissive · top 15,000 on PyPI