HTTP Web Services based on the SPARQL Endpoint

In this section we show how to use PoolPartys SPARQL endpoint as http web service. You should read the section about the SPARQL endpoint before you read this chapter.

Getting Started

Thesaurus data can be accessed via the SPARQL endpoint by simply posting queries to the endpoint URL via a HTTP POST or HTTP GET.
These are the steps necessary to retrieve the data:

  • Formulate a SPARQL query
  • Execute an HTTP GET request with request parameters:
    1. query: your SPARQL query (UTF-8) URL-encoded
    2. format: your desired return format e.g.: application/xml, application/json
  • Describe the format of the mime type of the body of the request: content-type: application/x-www-form-urlencoded
  • Provide Authentication information when needed.
  • Parse the SPARQL results in your application code using one of the Available SPARQL Clients

SPARQL request using Postman
Example request using curl
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: text/html" -d 'format=application/json&query=PREFIX skos:<> SELECT ?n ?prefLabel WHERE
{ <> skos:narrower ?n . ?n skos:prefLabel ?prefLabel . }limit 100'

Screenshot of a query performed via browser based REST Console:

In the chapter Examples for Thesaurus Services you can find several query templates which can be used and adapted to fit your needs.