SPARQL Endpoint
Use the SPARQL 1.1 query language to perform structured queries against a dataset. Useful for performing precise queries against a dataset whose structure you understand.
Table of contents
Endpoint URL
Login to test this query using our experimental API explorer
Authentication
You will need your API key (on your dashboard) in order to authenticate to this API. You have two options for authentication:
- By URL Parameter -- add the
apikeyparameter to your request URL, with your key as the value - By Request Header -- add a custom HTTP header called
X_KASABI_APIKEYto your HTTP request, with your key as the value
For more information on Kasabi authentication options read the authentication documentation. Your API key will need to be authorized to use this service.
Parameters
This API supports the following request parameters:
| Parameter Name | Parameter Value(s) | Required? | Notes |
|---|---|---|---|
query | URL encoded SPARQL query | Yes | This is the query to execute against the dataset |
output | Short name for desired response format | No | Supports selecting response format using url parameter rather than HTTP Accept header. |
HTTP Response Codes
Clients should be prepared to receive any valid HTTP response code. The following table lists the most frequently used codes
| Code | Meaning |
|---|---|
200 OK | Successful Request |
400 Bad Request | Missing or malformed SPARQL query |
401 Not Authorized | API key is not authorized to access the data |
Please also review our additional notes on response codes.
Response Formats
| Query Type | Response Format | Accept Header | output parameter | Notes |
|---|---|---|---|---|
| SELECT or ASK | application/sparql-results+json | application/sparql-results+json | json | Return results in SPARQL JSON results format |
| SELECT or ASK | application/sparql-results+xml | application/sparql-results+json | xml | Return results in SPARQL XML results format |
| CONSTRUCT or DESCRIBE | application/rdf | application/rdf | rdf (or xml) | Return results as RDF/XML |
| CONSTRUCT or DESCRIBE | application/rdf | application/rdf | rdf (or xml) | Return results as RDF/XML |
| CONSTRUCT or DESCRIBE | application/json | application/json | json | Return results as RDF/JSON |
| CONSTRUCT or DESCRIBE | text/turtle | text/turtle | turtle | Return results as Turtle |
| CONSTRUCT or DESCRIBE | text/plain | text/plain | ntriples | Return results as NTriples |
Sample Queries
This query looks up the identifier (URI) of an ingredient in the Foodista dataset. The names of the foods are associated with the RDF Schema label property. Simply alter the value of the property to look-up a different food name. Names will need to be exactly matched. For fuzzier lookups, use the search API.
This is a basic query that allows a list of recipes to be extracted from the dataset. The query will return at most ten results. Add an OFFSET clause to page into the dataset. Additional recipe properties can be added to filter the list.
This query illustrates how to find recipes that use specific ingredients. The ingredient property relates recipes to their ingredients. This query references the ingredients (in this case Carrots and Cashews) by their unique identifiers, however labels could be used instead.
The query will return the identifier, title and recipe homepage on the Foodista site for each matched recipe. This could be used to build links to Foodista to allow a user to read the recipe in detail.
This query finds the URIs and labels of all of the foods used as ingredients.
Rather than query for all things of a particular type it queries instead for all things that are used as an ingredient in a recipe.
This query returns what are the most used techniques or preparation methods (according to the Foodista community).
If you want to learn how to cook, it's better you know this stuff!
Stuff you could get away with it.