HTTP Web Services Based on the SPARQL Endpoint

In this section we show how to use PoolParty's 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:

  1. Formulate a SPARQL query

  2. Execute an HTTP GET request with request parameters:

    1. query: your SPARQL query (UTF-8) URL-encoded

    2. format: your desired return format, for example: application/xml, application/json

  3. Use the header to describe the format of the mime type of the request body:

    • content-type: application/x-www-form-urlencoded

  4. Provide authentication information when needed.

  5. Parse the SPARQL results in your application code using one of the Available SPARQL Clients


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.