-
Notifications
You must be signed in to change notification settings - Fork 4
Home
In the following the SPARQLBin deployment and API are described.
## Architecture ![SPARQLBin.com architecture diagram](https://raw.github.com/mhausenblas/sparqlbin.com/master/doc/architecture.png)The main components are:
- A user-facing Web application for browser user agents
- Apache Web server serving static content [1] and redirecting API requests [2]
- SPARQLBin server handling API requests [2]
- A backend using Apache CouchDB for storing and retrieving SPARQL queries [3]
- Any non-browser user agent that may use the API [4] directly
- Executing SPARQL queries with
/execute
- Storing SPARQL queries with
/share
- Retrieving SPARQL queries with
/q
Note that each entry is time-stamped at time of storing. The default response content type of the API is JSON, other media types might be supported in the future.
### Executing SPARQL queries - /execute In order to execute a SPARQL query you `POST` to `/execute` as follows:POST /execute HTTP/1.1
Host: sparqlbin.com
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
endpoint:http%253A%2F%2Fdbpedia.org%2Fsparql
query:PREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0APREFIX+rdfs%3A+%3Chttp...
The two required parameters are:
-
endpoint
... the URL of the SPARQL endpoint to execute the query against -
query
... the SPARQL query string
If the execution is successful you should see something like the following:
HTTP/1.1 200 OK
Date: Sun, 05 Aug 2012 10:33:19 GMT
Server: BaseHTTP/0.3 Python/2.6.5
Content-type: application/json
Via: 1.1 sparqlbin.com
{"head": {"link": [], "vars": ["s", "p", "o"]}, "results": {"distinct":...
POST /share HTTP/1.1
Host: sparqlbin.com
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
endpoint:http%253A%2F%2Fdbpedia.org%2Fsparql
query:PREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0APREFIX+rdfs%3A+%3Chttp...
The two required parameters are the same as above for /execute
and if the storing is successful you should see something like the following:
HTTP/1.1 200 OK
Date: Sun, 05 Aug 2012 10:33:19 GMT
Server: BaseHTTP/0.3 Python/2.6.5
Content-type: application/json
Via: 1.1 sparqlbin.com
{"entryid": "0f880d0a723f62393033a47ee955585c"}
Note that entryid
is a UUID for the query entry (endpoint URL and query string) that has been stored in the CouchDB backend. And, yes, it should be 201
- will be fixed ;)
GET /q/0f880d0a723f62393033a47ee955585c HTTP/1.1
Host: sparqlbin.com
The required path component after the /q
is the query entry ID you get from storing an entry (see above).
HTTP/1.1 200 OK
Date: Sun, 05 Aug 2012 11:01:19 GMT
Server: BaseHTTP/0.3 Python/2.6.5
Content-type: application/json
Via: 1.1 sparqlbin.com
{"endpoint": "http://dbpedia.org/sparql", "timestamp": "2012-08-05T10:51:17Z", "querystr": "PREFIX rdf: <http:...
Note that this means every query (endpoint URL and query string) has a URL where the raw data in JSON is served from, for example, the URL for the query with the entry ID 0f880d0a723f62393033a47ee955585c
is http://sparqlbin.com/q/0f880d0a723f62393033a47ee955585c - also note the timestamp
which represents the date and time the query has been stored.