# sparql-http-client

> Simplified SPARQL HTTP request client

Latest version **3.1.0** (published 2025-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install sparql-http-client
pnpm add sparql-http-client
yarn add sparql-http-client
bun add sparql-http-client
```

## Health

**Score 48/100 (D)** — status: stable.

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2025-11-11 |
| First published | 2015-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/sparql-http-client) |
| Module format | ESM + CommonJS |
| Dependencies | 11 |
| Unpacked size | 186.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Thomas Bergwinkl |
| Maintainers | bergos |
| Keywords | sparql, http, rdf |

## Links

- npm: https://www.npmjs.com/package/sparql-http-client
- Repository: https://github.com/rdf-ext/sparql-http-client
- Homepage: https://rdf-ext.github.io/sparql-http-client/
- Issues: https://github.com/rdf-ext/sparql-http-client/issues
- npm.io page: https://npm.io/package/sparql-http-client

## Dependencies (11)

- [duplex-to](https://npm.io/package/duplex-to.md) ^2.0.0
- [nodeify-fetch](https://npm.io/package/nodeify-fetch.md) ^3.1.0
- [stream-chunks](https://npm.io/package/stream-chunks.md) ^1.0.0
- [@rdfjs/dataset](https://npm.io/package/@rdfjs/dataset.md) ^2.0.2
- [readable-stream](https://npm.io/package/readable-stream.md) ^4.5.2
- [@rdfjs/parser-n3](https://npm.io/package/@rdfjs/parser-n3.md) ^2.0.2
- [@bergos/jsonparse](https://npm.io/package/@bergos/jsonparse.md) ^1.4.1
- [@rdfjs/data-model](https://npm.io/package/@rdfjs/data-model.md) ^2.0.2
- [@rdfjs/environment](https://npm.io/package/@rdfjs/environment.md) ^1.0.0
- [@rdfjs/to-ntriples](https://npm.io/package/@rdfjs/to-ntriples.md) ^3.0.1
- [rdf-transform-triple-to-quad](https://npm.io/package/rdf-transform-triple-to-quad.md) ^2.0.0

## Recent versions

- 3.1.0 (latest) — 2025-11-11
- 3.0.1 — 2024-08-15
- 3.0.0 — 2024-02-18
- 2.4.2 — 2022-12-22
- 2.4.1 — 2022-06-01
- 2.4.0 — 2021-05-28
- 2.3.1 — 2021-05-10
- 2.3.0 — 2021-04-15
- 2.2.3 — 2021-01-19
- 2.2.2 — 2020-04-14
- 2.2.1 — 2020-04-13
- 2.2.0 — 2020-03-26
- 2.1.2 — 2020-03-24
- 2.1.1 — 2020-03-23
- 2.1.0 — 2020-03-12
- … 9 more at https://npm.io/package/sparql-http-client/versions

## README

# sparql-http-client

[![build status](https://img.shields.io/github/actions/workflow/status/rdf-ext/sparql-http-client/test.yaml?branch=master)](https://github.com/rdf-ext/sparql-http-client/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/sparql-http-client.svg)](https://www.npmjs.com/package/sparql-http-client)

SPARQL client for easier handling of SPARQL Queries and Graph Store requests.
The [SPARQL Protocol](https://www.w3.org/TR/sparql11-protocol/) is used for [SPARQL Queries](https://www.w3.org/TR/sparql11-query/) and [SPARQL Updates](https://www.w3.org/TR/sparql11-update/). 
The [SPARQL Graph Store Protocol](https://www.w3.org/TR/sparql11-http-rdf-update/) is used to manage Named Graphs.

It provides client implementations in different flavors.
The default client comes with an interface for [streams](https://github.com/nodejs/readable-stream), the simple client is closer to [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), and the parsing client wraps the results directly into [RDF/JS DatasetCore](https://rdf.js.org/dataset-spec/#datasetcore-interface) objects or arrays.

## Usage

The example below shows how to use the client to run a `SELECT` query against the Wikidata endpoint.
Check the [documentation](https://rdf-ext.github.io/sparql-http-client/) for more details.

```javascript
import SparqlClient from 'sparql-http-client'

const endpointUrl = 'https://query.wikidata.org/sparql'
const query = `
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>

SELECT ?value WHERE {
  wd:Q243 p:P2048 ?height.

  ?height pq:P518 wd:Q24192182;
    ps:P2048 ?value .
}`

const client = new SparqlClient({ endpointUrl })
const stream = client.query.select(query)

stream.on('data', row => {
  for (const [key, value] of Object.entries(row)) {
    console.log(`${key}: ${value.value} (${value.termType})`)
  }
})

stream.on('error', err => {
  console.error(err)
})
```

---
_Source: https://npm.io/package/sparql-http-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
