Package Exports
- sparql-http-client
- sparql-http-client/ParsingClient
- sparql-http-client/ResultParser
- sparql-http-client/SimpleClient
- sparql-http-client/StreamClient
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sparql-http-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sparql-http-client
SPARQL client for easier handling of SPARQL Queries and Graph Store requests. The SPARQL Protocol is used for SPARQL Queries and SPARQL Updates. The SPARQL Graph Store Protocol is used to manage Named Graphs.
Getting started example
TL;DR; the package exports a StreamClient
class which run SPARQL queries on an endpoint.
const SparqlClient = require('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 = await client.query.select(query)
stream.on('data', row => {
Object.entries(row).forEach(([key, value]) => {
console.log(`${key}: ${value.value} (${value.termType})`)
})
})
stream.on('error', err => {
console.error(err)
})
Find more details on https://zazuko.github.io/sparql-http-client