Skip to content

REST API

Michel Dumontier edited this page May 13, 2016 · 3 revisions

Obtain a description of the SPARQL endpoint

curl -iH "Accept: text/turtle" http://cu.kegg.bio2rdf.org/sparql/

returns

 HTTP/1.1 200 OK
 Date: Sat, 22 Aug 2015 11:31:08 GMTh
 Server: Virtuoso/07.10.3207 (Linux) x86_64-unknown-linux-gnu
 Accept-Ranges: bytes
 Content-Type: text/turtle; charset=UTF-8
 Content-Length: 572

 @prefix rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
 @prefix ns1:    <http://localhost:8890/> .
 @prefix sd:     <http://www.w3.org/ns/sparql-service-description#> .
 @prefix ns3:    <http://www.w3.org/ns/formats/> .
 ns1:sparql      rdf:type        sd:Service ;
  sd:endpoint     ns1:sparql ;
  sd:feature      sd:DereferencesURIs , sd:UnionDefaultGraph .
 ns1:sparql      sd:resultFormat ns3:SPARQL_Results_CSV ,
  ns3:SPARQL_Results_JSON ,
  ns3:N3 ,
  ns3:RDF_XML ,
  ns3:SPARQL_Results_XML ,
  ns3:Turtle ,
  ns3:N-Triples ,
  ns3:RDFa ;
  sd:supportedLanguage    sd:SPARQL10Query ;
  sd:url  ns1:sparql .

To perform a CURL using a sparql query in a file: curl -H "Accept: text/plain" --data-urlencode query@query.sparql http://bio2rdf.org/sparql

for SELECT or ASK queries (the right part is the content type):

 HTML -> 'text/html'
 HTML (Faceted Browsing Links) -> 'text/x-html+tr'
 Spreadsheet -> 'application/vnd.ms-excel'
 XML -> 'application/sparql-results+xml'
 JSON -> 'application/sparql-results+json'
 Javascript -> 'application/javascript'
 Turtle -> 'text/turtle'
 RDF/XML -> 'application/rdf+xml'
 N-Triples -> 'text/plain'
 CSV -> 'text/csv'
 TSV -> 'text/tab-separated-values'

for CONSTRUCT queries:

Turtle -> 'text/turtle'
Pretty-printed Turtle (slow!) -> 'application/x-nice-turtle'
RDF/JSON -> 'application/rdf+json'
RDF/XML -> 'application/rdf+xml'
N-Triples -> 'text/plain'
XHTML+RDFa -> 'application/xhtml+xml'
ATOM+XML -> 'application/atom+xml'
ODATA/JSON -> 'application/odata+json'
JSON-LD -> 'application/x-json+ld'
HTML (list) -> 'text/x-html+ul'
HTML (table) -> 'text/x-html+tr'
HTML+Microdata (inconvenient) -> 'text/html'
HTML+Microdata (pretty-printed table) -> 'application/x-nice-microdata'
Turtle-style HTML (for browsing, not for export) -> 'text/x-html-nice-turtle'
Microdata/JSON -> 'application/microdata+json'
CSV -> 'text/csv'
TSV -> 'text/tab-separated-values'
TriG -> 'application/x-trig'
You can’t perform that action at this time.