SPARQL API Endpoint Documentation

SPARQL API Endpoint Documentation

Table of Contents

Getting Started

In order to access the API, you will need an OAuth Consumer Key. Please follow these steps to obtain your Consumer Key:

  1. Login with your NETID 
  2. Open the "OAuth Consumers" Tab
  3. Click on "Add consumer"
  4. Under "Consumer name", enter any name for your application/website (ie. MyWebsite.com)
  5. Under "Callback URL", enter 'https://YOUR_DOMAIN'.
  6. Click 'Save'
  7. Click "OAuth Consumers"
  8. Click 'Edit' in the row of your newly created 'Consumer'
  9. Under 'key' you will find your Consumer Key. Copy this key to a secure location.
    1. This key will be used on all the HTTP Requests that you make to the API. 
    2. At any given time, you can revoke a consumer (key) and generate a new one.
  10. Click 'Save'.
  11. Visit the endpoint at http://globalresearchopportunities.northwestern.edu/sparql-api or click on some example queries below.

 

A Quick Introduction to RDF

Back to Top

This documents aims to map out the data relationships for Northwestern GRO (Opportunities) though ontologies and RDF mapping. If you are completely unfamiliar with what an ontology is, or would like a better sense of how they work, please refer to additional reading at http://protege.stanford.edu/publications/ontology_development/ontology101-noy-mcguinness.html.

The benefit of mapping data out as an ontology as opposed to, for example, the relational data exactly as it is stored in the database is interoperability - while we define our own Opportunity, we also equal it to an Opportunity someone else has made. Thus, if you were to have two different data sets, made by two different organizations that are not aware of each other's existence, a good ontology mapping would allow you to use and visualize such data together with ease.

Opportunities uses several existing ontologies - including (click on each for more detail) vivo, skos, and foaf, - and defines it's own ontology, gro. A visual mapping of gro in relation to other ontologies is partially demonstrated by this chart:

 

 

Every node in the graph is a Class. A Class can have both data properties and sub-Classes. An example of how the chart could be read in plain language: An Opportunity is an Organization which has TaxonomyTerms such as Credit, Participant, and FundingAvailability, and it also has a 'Geographic Location', which means it has either a 'Geographic Region' or Campus. Equivalent Classes, sub-Classes, and data properties of a Class are referred to as predicates.

These ontologies, as mapped to the Opportunities website, can be exposed through a SPARQL endpoint, such as the one provided through Opportunities at http://globalresearchopportunities.northwestern.edu/sparql-api. This endpoint can return data in various formats including JSON and XML.

For example, we can run the following query to return all predicates, including all sub-Classes and data properties of an Opportunity:

PREFIX gro: <https://globalresearchopportunities.northwestern.edu/ontology/gro.owl#>

SELECT distinct ?predicate WHERE
{ ?x rdf:type gro:Opportunity .
?x ?predicate ?object }


Sample SPARQL Queries

Back to Top

Here is a selection of sample SPARQL queries that can be modified and extended to draw various types of data.

PREFIX gro: <https://globalresearchopportunities.northwestern.edu/ontology/gro.owl#>

SELECT distinct ?x ?predicate ?object WHERE
{ ?x rdf:type gro:Opportunity .
?x ?predicate ?object }


This will return every field of every Opportunity, up to however much the API supports. Note that the "gro" prefix was defined prior to the query. Each prefix must be defined with the proper IRI or you may not get any results.

PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?x ?name WHERE
{ ?x rdf:type foaf:Person .
?x foaf:name ?name }


This query will return the names of all Users (who are of type foaf:Person). In this example, the ?predicate was replaced with foaf:name to indicate we only want the data field foaf:name, not all predicates.

PREFIX vivo: <http://vivoweb.org/ontology/core#>

SELECT ?x ?object WHERE
{?x rdf:type vivo:School .
?x rdfs:label ?object }

This will return all Schools (Taxonomy term) you can find Opportunities in. In this example, we used an external ontology not defined by GRO.

PREFIX gro: <https://globalresearchopportunities.northwestern.edu/ontology/gro.owl#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT distinct ?subject ?object WHERE
{ ?subject rdf:type gro:Language .
?subject rdfs:label ?object }

This will return all languages you can find Opportunities in. In this example, we used the GRO ontology.

PREFIX gro: <https://globalresearchopportunities.northwestern.edu/ontology/gro.owl#>
PREFIX content: <http://purl.org/rss/1.0/modules/content/>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT distinct ?subject ?object ?title ?lan WHERE
{ ?subject rdf:type gro:Opportunity .
?subject gro:Language ?lan .
?subject content:encoded ?object .
?subject dc:title ?title }


This query will return all Opportunities and certain fields, such as the language (reference to a Taxonomy Term), their title, and their description.

Or, you can return all Opportunities in the UK - countries are determined by the ISO 3166-1 alpha-2 code of that country (for a full list, http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2):

PREFIX gro: <https://globalresearchopportunities.northwestern.edu/ontology/gro.owl#>
PREFIX content: <http://purl.org/rss/1.0/modules/content/>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT distinct ?subject ?object ?title ?hp WHERE
{ ?subject rdf:type gro:Opportunity .
?subject gro:countrycode "UK" .
?subject content:encoded ?object .
?subject dc:title ?title .
?subject foaf:workInfoHomepage ?hp }


Useful links:
- Syntax tutorial
- Statistic queries

RDF Mapping in Opportunities

Back to Top

User

RDF Types: foaf:Person

Fields RDF predicates Mapping type Datatype  
First Name foaf:givenName property xsd:string  
Last Name foaf:familyName property xsd:string  
Regions of Interest gro:Region, vivo:GeographicRegion rel xsd:string  
Display Name foaf:name property xsd:string  
Primary Center Affiliation foaf:Organization, gro:Center, gro:Primary rel xsd:string  
Primary School Affiliation foaf:Organization, gro:School, gro:Primary, vivo:School rel xsd:string  
Directory Link foaf:homepage property xsd:string  
Bio bio:biography property xsd:string  
Countries of Interest vivo:GeographicLocation, gro:Country rel xsd:string  
Other Center Affiliations foaf:Organization, gro:NUCenterProgramInstitute, gro:Other rel    
Other Department Affiliations foaf:Organization, gro:Department, gro:Other, vivo:Department rel    
Other School Affiliations foaf:Organization, gro:School, gro:Other, vivo:School rel    
Phone foaf:phone property xsd:string  
Languages of Proficiency gro:Language, vcard:Language rel    
Primary Department Affiliation foaf:Organization, gro:Department, gro:Primary, vivo:Department rel    
Related Opportunities gro:Opportunity rel    
name foaf:name property    
homepage foaf:page rel    

International Affiliate / External Partner

RDF Types: sioc:Item, foaf:Document, gro:Partner ()

Fields RDF predicates Mapping type Datatype  
Body content:encoded property    
Child Institution(s) foaf:Organization, gro:Child rel    
Parent Institution foaf:Organization, gro:Parent rel    
Affiliation Types gro:AffiliateType rel    
Website foaf:workInfoHomepage property xsd:string  
title dc:title property    
created dc:date, dc:created property xsd:dateTime  
changed dc:modified property xsd:dateTime  
uid sioc:has_creator rel    
name foaf:name property    
uuid rdf:nodeID property xsd:string  
last_activity sioc:last_activity_date property xsd:dateTime  

Opportunity

RDF Types: sioc:Item, foaf:Document, obo:ERO_0000595, gro:Opportunity ()

Fields RDF predicates Mapping type Datatype  
Opportunity Description content:encoded property xsd:string  
Course Credit Availability gro:Credit rel xsd:string  
NU Sponsor gro:Sponsor rel xsd:string  
Funding Availability gro:FundingAvailability rel xsd:string  
Keyword Descriptors vivo:freetextKeyword property xsd:string  
Compensation vivo:totalAwardAmount property xsd:string  
Language of Instruction vcard:Language, gro:Language, gro:Parent rel xsd:string  
Language Requirement vcard:Language, gro:Language, gro:Primary rel xsd:string  
Languages Taught vcard:Language, gro:Language, gro:Child rel xsd:string  
Northwestern Campus vivo:Campus, gro:Campus rel    
Opportunity Regions vivo:GeographicRegion, gro:Region rel    
Opportunity Timeline vivo:EventSeries, gro:Primary rel    
Opportunity Type gro:OpportunityType rel    
Opportunity Type (Other) vivo:termType property xsd:string  
International and/or External Opportunity Partners gro:Partner rel    
Opportunity Start Year vivo:dateTimeInterval property xsd:string  
Other Limits on Participation obo:ERO_0000774 property xsd:string  
Other Required Skills gro:Eligibility, gro:Other rel xsd:string  
Participants gro:Participant rel    
Type of Payment Available gro:PaymentType rel    
Similar Opportunities gro:Opportunity, gro:Other rel    
Participants (Other) gro:Participant, gro:Other rel    
Opportunity Website foaf:workInfoHomepage property xsd:string  
Schools gro:School rel    
Subject Area gro:SubjectArea rel    
Country Code
gro:countrycode property xsd:string  
title dc:title property xsd:string  
created dc:date, dc:created property xsd:dateTime  
changed dc:modified property xsd:dateTime  
uid sioc:has_creator rel    
name foaf:name property    
uuid rdf:nodeID property xsd:string  
last_activity sioc:last_activity_date property xsd:dateTime  

Taxonomy Terms

All Taxonomy terms share the same predicates, but have unique classes.

Tags

RDF Types: skos:Concept, gro:Tags

Fields RDF predicates Mapping type Datatype  
name rdfs:label, skos:prefLabel property    
description skos:definition property    
vid skos:inScheme rel    
parent skos:broader rel    

Affiliate Type

RDF Types: skos:Concept, gro:AffiliateType

Campus

RDF Types: skos:Concept, vivo:Campus, gro:Campus

Course Credit Availability

RDF Types: skos:Concept, gro:Credit

Funding Availability

RDF Types: skos:Concept, gro:FundingAvailability

Keywords

RDF Types: skos:Concept, gro:Keywords

Languages

RDF Types: skos:Concept, vcard:Language, gro:Language

NU Center Program Institute

RDF Types: skos:Concept, gro:NUCenterProgramInstitute

NU Department

RDF Types: skos:Concept, vivo:Department, gro:Department

NU Partner

RDF Types: skos:Concept, gro:NUPartner

NU School

RDF Types: skos:Concept, vivo:School, gro:School

Opportunity Country

RDF Types: skos:Concept, vivo:GeographicLocation, gro:Country

Opportunity Direction and Mapping Options

RDF Types: skos:Concept, gro:Direction

Opportunity Type

RDF Types: skos:Concept, gro:OpportunityType

Participants

RDF Types: skos:Concept, gro:Participant

Primary Subject Area

RDF Types: skos:Concept, gro:SubjectArea

Regions

RDF Types: skos:Concept, vivo:GeographicRegion, gro:Region

Subject Discipline

RDF Types: skos:Concept, gro:SubjectDiscipline

Timeframes

RDF Types: skos:Concept, gro:Timeframe

Topics

RDF Types: skos:Concept, gro:Topic

Type of Payment

RDF Types: skos:Concept, gro:Payment

Action

RDF Types: skos:Concept, gro:Action

Namespaces

Namespaces are the full length name of the various prefixes.

Prefix Namespace
bio http://purl.org/vocab/bio/0.1/
ero http://www.berkeleybop.org/ontologies/ero.owl#
gro https://globalresearchopportunities.northwestern.edu/ontology/gro.owl#
obo http://purl.obolibrary.org/obo/
vcard http://www.w3.org/2006/vcard/
vivo http://vivoweb.org/ontology/core#
content http://purl.org/rss/1.0/modules/content/
dc http://purl.org/dc/terms/
foaf http://xmlns.com/foaf/0.1/
og http://ogp.me/ns#
rdfs http://www.w3.org/2000/01/rdf-schema#
sioc http://rdfs.org/sioc/ns#
sioct http://rdfs.org/sioc/types#
skos http://www.w3.org/2004/02/skos/core#
xsd http://www.w3.org/2001/XMLSchema#
owl http://www.w3.org/2002/07/owl#
rdf http://www.w3.org/1999/02/22-rdf-syntax-ns#
rss http://purl.org/rss/1.0/
site http://globalresearchopportunities.northwestern.edu/ns#
v http://rdf.data-vocabulary.org/#