Knowledge Graphs

Skip to end of metadata
Go to start of metadata
Table of Contents

Introduction

The Knowledge Graph server is based on FactForge by Ontotext. FactForge integrates a subset of the Linked Open Data cloud (LOD) and provides inference and SPARQL querying on top of it. The underlying RDF engine of FactForge is GraphDB by Ontotext.

Datasets

The following Linked Datasets are available for querying via the Knowledge Graph Server (FactForge):

See http://www.ontotext.com/factforge for more info

Ontologies and Vocabularies

The following ontologies and vocabularies are used:

Data Size

At present, the integrated datasets provide more than 5 billion RDF triples.

Service Endpoint

service
endpoint
methods
Knowledge Graph SPARQL endpoint
https://lod.s4.ontotext.com/v1/FactForge/sparql GET, POST

HTTP Headers

Header name Required Description Valid values Default value
Content-Type
  • no (for GET)
  • yes (for POST)
Must be equal to "application/x-www-form-urlencoded" for POST
application/x-www-form-urlencoded n/a
Accept yes
Relevant values depend on the SPARQL query type
  • for graph queries (RDF): application/rdf+xml, text/plain, text/turtle, text/rdf+n3, text/x-nquads, application/rdf+json, application/trix, application/x-trig, application/x-binary-rdf;
  • for tuple queries (variable bindings): application/sparql-results+xml, application/sparql-results+json;
  • for boolean queries: application/sparql-results+xml, application/sparql-results+json, text/boolean
n/a
Accept-Encoding no
Set if the client supports transparent compression.
  • gzip
if omitted, response is not compressed

Request Parameters

Both GET and POST methods are supported. The GET method is preferred as it adheres to the REST architectural style. The POST method should be used in cases where the length of the (URL-encoded) query exceeds practicable limits of proxies, servers, etc. In case a POST request is used, the query parameters should be sent to the server as www-form-urlencoded data.

Parameter name
Required
Description
query
yes
The query to evaluate
infer no
Specifies whether inferred statements should be included in the query evaluation. Inferred statements are included by default

SPARQL GET Request

GET /v1/FactForge/sparql?query=select%20*%20where%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D%20limit%202 HTTP/1.1
Host: lod.s4.ontotext.com
Accept: application/sparql-results+xml

SPARQL POST Request

POST /v1/FactForge/sparql HTTP/1.1
Host: lod.s4.ontotext.com
Content-Type: application/x-www-form-urlencoded
Accept: application/sparql-results+xml

query=select%20*%20where%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D%20limit%202

Response format

The response format depends on the query type and the selected Accept format parameter.
The following is an example response of a SPARQL Select query, serialized as application/sparql-results+xml:

Example

Let's execute the following simple SPARQL query, listing the names of all European countries (from DBpedia):

# Countries in Europe
PREFIX dbp-ont: <http://dbpedia.org/ontology/>
PREFIX geo-ont: <http://www.geonames.org/ontology#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dbpedia: <http://dbpedia.org/resource/>

SELECT DISTINCT ?name
WHERE {
    ?country rdf:type dbp-ont:Country ;
             skos:prefLabel ?name ;
             geo-ont:parentFeature dbpedia:Europe .
} ORDER BY ?name

We can use a simple online tool like curl to execute the request to the RESTful service for the Knowledge Graph server:

Lets go step-by-step through the sample code above:

  1. we specify the API Key and secret - as already explained all S4 requests need a valid API key and secret pair
  2. we specify the S4 RESTful service to be used - in this case the SPARQL endpoint of the Knowledge Graph server. As part of the service endpoint URL we also provide the API key pair
  3. we have chosen to execute a simple SPARQL query listing the names of all European countries
  4. we make a RESTful request to the S4 service via the command line tool curl, providing the query (from step 3), the S4 service endpoint (from step 2) and we specify in the HTTP header that 1) this HTTP request type is "application/x-www-form-urlencoded" and 2) that the response format should be JSON ("application/sparql-results+json")

The result of the service invocation is a JSON file which looks like:

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.