Skip to main content

HTTP Web Services Based on the SPARQL Endpoint

Abstract

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

23901031.png

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:<http://www.w3.org/2004/02/skos/core#> SELECT ?n ?prefLabel WHERE
{ <http://reegle.info/glossary/246> skos:narrower ?n . ?n skos:prefLabel ?prefLabel . }limit 100' http://vocabulary.semantic-web.at/PoolParty/sparql/glossary

Example

Screenshot of a query performed via browser based REST Console:

23901030.png

Note

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