Developers API Guide

This section documents Data.Gov.sa APIs, for developers who want to write code that interacts with Data.gov.sa and their data.

For example, using the Data.Gov.sa API your app can:

Quering

Query example (first 5 results)

https://data.gov.sa/api/3/action/datastore_search?resource_id=d5c349f5-f588-43aa-b81b-8fe5d9a2e113&limit=5

Query example (results containing jones)

https://data.gov.sa/api/3/action/datastore_search?resource_id=d5c349f5-f588-43aa-b81b-8fe5d9a2e113&q=jones

Query example (via SQL statement)

https://data.gov.sa/api/3/action/datastore_search_sql?sql=SELECT * from "d5c349f5-f588-43aa-b81b-8fe5d9a2e113" WHERE title LIKE jones

Javascript

A simple ajax (JSONP) request to the data API using jQuery.

var data = {

resource_id: "d5c349f5-f588-43aa-b81b-8fe5d9a2e113", // the resource id

limit: 5, // get 5 results

q: "jones" // query for "jones"

};

$.ajax({

url: "https://data.gov.sa/api/3/action/datastore_search",

data: data,

dataType: "jsonp",

success: function(data) {

alert("Total results found: " + data.result.total)

}

});

Python

import urllib

url = "https://data.gov.sa/api/3/action/datastore_search?resource_id=d5c349f5-f588-43aa-b81b-8fe5d9a2e113&limit=5&q=title:jones"

fileobj = urllib.urlopen(url)

print fileobj.read()

vote: 
Average: 3 (2 votes)

Comments