How to use SparqlProxy

From Data-gov Wiki

Jump to: navigation, search
Infobox (How-To) edit with form
  • name: How to use SparqlProxy


Contents

Overview

RESTful API documentation

SparqlProxy is a RESTful Web Service. Check http://data-gov.tw.rpi.edu/ws/sparqlproxy.php for the most up-to-date parameter descriptions and examples.

Service URL

 http://data-gov.tw.rpi.edu/ws/sparqlproxy.php

Parameters

  • query: encoded String of SPARQL query
  • query-uri : URI of SPARQL query
  • service-uri: URI of SPARQL endpoint
  • output: output format. The following values are support
xml - SPARQL XML Bindings
exhibit - Simile Exhibit JSON
gvds - Google Visualization JSON
csv - CSV
html - HTML table

Using SparqlProxy in Javascript

A query to a specific triple store (typical usage)

        			
 var queryloc = "http://data-gov.tw.rpi.edu/demo/stable/demo-1356-1623-health-claim-vs-income.sparql";
 var service  = "http://data-gov.tw.rpi.edu/joseki/sparql/tdb-datagov";
 var queryurl = "http://data-gov.tw.rpi.edu/ws/sparqlproxy.php?"
                 + "output=gvds"
                 + "&service-uri=" + encodeURIComponent(service)
                 + "&query-uri=" + encodeURIComponent(queryloc) ;

A query with from clause can be issued to a default SPARQL query service which load dataset on the fly.

        			
 var queryloc = "http://data-gov.tw.rpi.edu/sparql/demo-34-magnitude5.sparql";
 var queryurl = "http://data-gov.tw.rpi.edu/ws/sparqlproxy.php?"
                 + "output=gvds"
                 + "&query-uri=" + encodeURIComponent(queryloc) ;

Using SparqlProxy via Web Interface

There are two alternative options to use SparqlProxy

Option1 - Run SPARQL query.

You may type a SPARQL query into the SPARQL query: text area. Clicking the query button will submit the query to the SPARQL endpoint specified in the SPARQL service (URL) field. Once the SPARQL service URL returns the SPARQL XML Bindings, SparqlProxy transforms them into the format specified by the radio buttons (Google Viz/JSON, Exhibit/JSON, SPARQL/JSON, SPARQL/XML, HTML, CSV).

Option2 - Run SPARQL query (by URI)

This option performs the same function as Option 1, but accepts a URL for a SPARQL query instead of using the text entered in an input box. This requires that you save a SPARQL query into a text file available on the web.

Personal tools
internal pages