Nobelprize.org
Lists of Nobel Prizes and Laureates

Linked Data Examples

Sparql

Our sparql endpoint can be used to query our dataset. You can easily test different queries. Below are some examples of queries that can be done.

The first query will list all Nobel Laureates born in Iceland:

SELECT DISTINCT ?label 
WHERE { 
  ?laur rdf:type nobel:Laureate . 
  ?laur rdfs:label ?label . 
  ?laur dbpedia-owl:birthPlace <http://data.nobelprize.org/resource/country/Iceland> . 
}

Result:

label
"Halldór Kiljan Laxness"

 

The query below will list all female Nobel Laureates in Physics:

SELECT DISTINCT ?label 
WHERE { 
  ?laur rdf:type nobel:Laureate . 
  ?laur rdfs:label ?label . 
  ?laur foaf:gender "female" . 
  ?laur nobel:laureateAward ?award . 
  ?award nobel:category <http://data.nobelprize.org/resource/category/Physics> . 
}  

Result:

label
"Marie Curie, née Sklodowska"
"Maria Goeppert Mayer"

 

Since our dataset is linked to other datasets, it's possible to query several datasets at the same time. Below is an example that combines the Nobelprize dataset with DBPedia. It will list the all Nobel Prize Laureates in the Nobelprize dataset that are born in countries smaller than a certain area according to DBPedia.

PREFIX dbpo: <http://dbpedia.org/ontology/> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX nobel: <http://data.nobelprize.org/terms/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX owl: <http://www.w3.org/2002/07/owl#> 
SELECT DISTINCT ?label ?country 
WHERE { 
  ?laur rdf:type nobel:Laureate . 
  ?laur rdfs:label ?label . 
  ?laur dbpo:birthPlace ?country . 
  ?country rdf:type dbpo:Country . 
  ?country owl:sameAs ?dbp . 
  SERVICE <http://dbpedia.org/sparql> { 
    ?dbp dbpo:areaTotal ?area . 
    FILTER (?area < 10000000000) 
  } 
}

The result:

label country
"Derek Walcott" <http://data.nobelprize.org/resource/country/Saint_Lucia> [http]
"Jules A. Hoffmann" <http://data.nobelprize.org/resource/country/Luxembourg> [http]
"Sir Vidiadhar Surajprasad Naipaul" <http://data.nobelprize.org/resource/country/Trinidad> [http]
"Christopher A. Pissarides" <http://data.nobelprize.org/resource/country/Cyprus> [http]
"Gabriel Lippmann" <http://data.nobelprize.org/resource/country/Luxembourg> [http]

Note that in order for this to work, the dbpedia spaql endpoint has to be responsive, else an error message will be displayed.

 

Performing a sparql query from php

<?php
$query = "
PREFIX nobel: <http://data.nobelprize.org/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?label
     WHERE {
     ?laur rdf:type nobel:Laureate .
     ?laur rdfs:label ?label .
     ?laur foaf:gender 'female' .
     ?laur nobel:laureateAward ?award .
     ?award nobel:category <http://data.nobelprize.org/resource/category/Physics> .
 }";
$url = 'http://data.nobelprize.org/sparql?query='.urlencode($query).'&format=json';
     
# Fetch the data
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
$string = curl_exec($ch);
curl_close($ch);
$result = json_decode($string, true);
var_dump($result);
?>
   

 

 

Fetching an RDF file

 
<?php
# URL of the RDF file I want to fetch
$rdfurl = 'http://data.nobelprize.org/resource/laureate/1';
# Base URL of the linked data cache
# See http://entrystore.org/ldcache/ for more information
$url = 'http://data.nobelprize.org/ldc/';
# Add the url of the RDF file
$url = $url.'?url='.$rdfurl;
# Ask for json format from the linked data cache
$url = $url.'&format=application/rdf+json';
# Fetch the data
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
$string = curl_exec($ch);
curl_close($ch);
$result = json_decode($string, true);
var_dump($result);

?>   

 

The open data project at Nobelprize.org was supported in 2012 and 2014 by Vinnova.

 

Share this:
To cite this page
MLA style: "API Examples". Nobelprize.org. Nobel Media AB 2014. Web. 24 Jun 2017. <http://www.nobelprize.org/nobel_organizations/nobelmedia/nobelprize_org/developer/linkeddata-example.html>

Recommended: