Please upgrade to a more up-to-date browser to explore the datasets on this website.

Close

User menu

Cambridgeshire Insight OpenData

Welcome to Cambridgeshire Insight Open Data
Funded by the LGA Open data Breakthrough Fund

Developer resources

Welcome to the Developer Resources Page! The majority of data resources on Cambridgeshire Insight Open Data have an API. We will be updating these pages with any relevant content as the site develops.

DKAN documentation

DKAN documentation http://opendata.cambridgeshireinsight.org.uk/community/events

Examples of the DKAN API

DKAN Datastore API

Access resource data via a web API with powerful query support.

Resource ID

For example the Resource ID for the Local Housing Allowance changes 2013 resource is c94df6eb-d220-4c26-83aa-5528a241543e

Example Query

http://opendata.cambridgeshireinsight.org.uk/api/action/datastore/search...

Query this datastore and return first five results

Documentation

DKAN offers a Datastore API as a custom endpoint for the Drupal Services module.

This API is designed to be as compatible as possible with the CKAN Datastore API: http://docs.ckan.org/en/latest/datastore.html

The only documented difference is that the CKAN Datastore API supports POST requests while the DKAN Datastore API only supports GET requests. The DKAN Dataset APIs will support POST but the DKAN Datastore API.

Requests can be sent over HTTP. Data can be returned as JSON, XML, or JSONP.

Datastore API URL

Datastores can be queried at: http://opendata.cambridgeshireinsight.org.uk/api/action/datastore/search

The default return format is XML. JSON can be retrieved with '.json' at the end: http://opendata.cambridgeshireinsight.org.uk/api/action/datastore/search...

Request Parameters

Parameters: * resource_id (mixed) – id (string) or ids (array) of the resource to be searched against.

  • filters (mixed) – array or string of matching conditions to select

  • q (string) – full text query*

  • offset (int) – offset this number of rows

  • limit (int) – maximum number of rows to return (default: 100)

  • fields (array or comma separated string) – fields to return (default: all fields in original order)

  • sort (string) – comma separated field names with ordering

  • join (array) – array of fields to join from multiple tables

Return Values

Return is in XML, JSON or JSONP.

Return type:

A dictionary with the following keys

Parameters:

  • fields (list of fields) – fields/columns and metadata
  • offset (int) – query offset value
  • limit (int) – query limit value
  • count (int) – number of total matching records
  • records (list of dictionaries) – list of matching results

Examples

The following is a simple example with two resources that contain 4 records each. Please note that the resource_id would be a UUID not single digit number in real scenario. Resource: 1 +---------+-------------+----+------------+

| country | population | id | timestamp |

+---------+-------------+----+------------+

| US | 315,209,000 | 1 | 1359062329 |

| CA | 35,002,447 | 2 | 1359062329 |

| AR | 40,117,096 | 3 | 1359062329 |

| JP | 127,520,000 | 4 | 1359062329 |

+---------+-------------+----+------------+

Resource 2 +---------+-----------+----+------------+

| country | squarekm | id | timestamp |

+---------+-----------+----+------------+

| US | 9,629,091 | 1 | 1359062713 |

| CA | 9,984,670 | 2 | 1359062713 |

| AR | 2,780,400 | 3 | 1359062713 |

| JP | 377,930 | 4 | 1359062713 |

+---------+-----------+----+------------+

Simple query example:

http://opendata.cambridgeshireinsight.org.uk/api/dataset/search?resource...

Returns the country, population, and timestamp fields for US and AR from dataset 1 sorting by the country in ascending order.

Text Search

Paths with the 'query' argument will search the listed fields within the dataset.

http://opendata.cambridgeshireinsight.org.uk/api/dataset/search?resource...

Will return the country and population from US

Joining

If you wish to query multiple tables, indicate the table as an array key in the following fields:

http://opendata.cambridgeshireinsight.org.uk/api/dataset/search?resource_id[pop]=1&resource_id[size]=2&filters[pop][country]=US,AR&join[pop]=country&join[size]=country

Returns the country, population, squarekm and id for US and AR from datasets 11 and 13.

Submit a Story/App http://opendata.cambridgeshireinsight.org.uk/submit-data-storyapp