Skip to content

Instantly share code, notes, and snippets.

@timhodson
Created February 21, 2012 16:49
Show Gist options
  • Select an option

  • Save timhodson/1877329 to your computer and use it in GitHub Desktop.

Select an option

Save timhodson/1877329 to your computer and use it in GitHub Desktop.
Kasabi: Quick example of using the lookup api
########################################
## Quick curl commands
########################################
# get the response as RDF
curl -v -X GET "http://api.kasabi.com/dataset/airlines/apis/lookup?about=http://data.kasabi.com/dataset/airlines/MYL&output=rdf&apikey=$KASABI_API_KEY"
# get the response as JSON
curl -v -X GET "http://api.kasabi.com/dataset/airlines/apis/lookup?about=http://data.kasabi.com/dataset/airlines/MYL&output=json&apikey=$KASABI_API_KEY"
########################################
## Javascript and jQuery based example
########################################
// lookup up an item in a dataset to get detail. Uses the JSON output and parses the results
$('document').ready(function() {
var apibase, apikey, thingUri;
apikey = "&apikey=MYSECRETKEY";
apibase = "http://api.kasabi.com";
thingUri = encodeURI("http://data.kasabi.com/dataset/airlines/MYL");
return $.ajax({
url: "" + apibase + "/dataset/airlines/apis/lookup?about=" + thingUri + "&output=json" + apikey,
success: function(data) {
return $('div.foo').html("<h1>" + data[thingUri]['http://xmlns.com/foaf/0.1/name'][0]['value'] + "</h1>\n<p>" + data[thingUri]['http://purl.org/dc/terms/description'][0]['value'] + "</p>");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment