npm

Don't miss out on this year's npm Pride t-shirt designs!Order your favorites here »

sparql-http-client

1.1.0 • Public • Published

sparql-http-client

Build Status NPM Version

Simplified SPARQL HTTP request client

Usage

var fetch = require('isomorphic-fetch')
var SparqlHttp = require('sparql-http-client')

SparqlHttp.fetch = fetch

// which endpoint to query
var endpoint = new SparqlHttp({endpointUrl: 'https://query.wikidata.org/sparql'})

// the SPARQL query itself
var query = 'SELECT ?height WHERE { wd:Q243 wdt:P2048 ?height . }'

// run query with promises
endpoint.selectQuery(query).then(function (res) {

  return res.text()

// result body of the query
}).then(function (body) {
  // parse the body for pretty print
  console.log(body)
  var result = JSON.parse(body)

  // output the complete result object
  console.log(JSON.stringify(result, null, ' '))

// necessary catch the error
}).catch(function (err) {

  console.error(err)

})

See the examples folder for more complex examples.

Licence

MIT

install

npm i sparql-http-client

Downloadsweekly downloads

23

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
Report a vulnerability