Go Back Developer area

A close-up of some nuts.

The DataShare API

The DataShare API provides access to all the datasets stored in DataShare. The API implements RESTful interfaces to allow developers to perform simple queries on the available data. XML and JSON representations of the data are available.

Getting started

The DataShare API lets you programmatically access tens of thousands of records and query the data in several ways, using the url and additional parameters to specify the data you would like returned.


Some simple API requests

Details of all categories

Search for all available data categories, their descriptions and the URL stubs needed to access them.

https://data.lichfielddc.gov.uk/api/The DataShare domain followed by /api/

Example: https://data.lichfielddc.gov.uk/api returns a list of all available data categories.

Schema details

Search for all available datasets within a category, their descriptions and the URL stubs needed to access them.

https://data.lichfielddc.gov.uk/api/The DataShare domain followed by /api/Category/The category to be queried.

Example: https://data.lichfielddc.gov.uk/api/spending returns a list of all datasets in the Spending category.

Uploaded data files

Details of the data files uploaded to a dataset.

https://data.lichfielddc.gov.uk/api/The DataShare domain followed by /api/Category/The category that the dataset is in.SchemaName/The dataset to be queried.

Example: https://data.lichfielddc.gov.uk/api/spending/payments-to-suppliers would return a list of all uploaded datasets for Payments to suppliers in the Spending category.

Full inventory

A full list of all schemas, associated meta data and the data files uploaded to them.

https://data.lichfielddc.gov.uk/api/The DataShare domain followed by /api/esdInventoryThe esdInventory request.

Example: https://data.lichfielddc.gov.uk/api/esdInventory returns a list of all available data schemas, their associated data files and meta data.

Dataset definition

The definition of a dataset, including column names, types, etc.

https://data.lichfielddc.gov.uk/api/The DataShare domain followed by /api/Category/The category that the dataset is in.SchemaName/The dataset to be queried followed by the definition request.definition

Example: https://data.lichfielddc.gov.uk/api/spending/payments-to-suppliers/definition would return a list of all the columns in the Payments to suppliers dataset in the Spending category.


Search types

SearchByTextEquals

Search for entries in the field <fieldToSearch> that exactly match the word (or words) <searchText>.

Parameters:

  • fieldToSearch
  • searchText
  • format

Example: ../SearchByTextEquals?fieldToSearch=ExpenseArea&searchText=Cashiering&format=xml


SearchByNumberEquals

Search for entries in field <fieldToSearch> that are exactly equal to <searchText>.

Parameters:

  • fieldToSearch
  • searchText
  • format

Example: ../SearchByNumberEquals?fieldToSearch=Amount&searchText=120&format=xml


SearchByNumberGreaterThan

Search for entries in field <fieldToSearch> that are greater than <searchText>.

Parameters:

  • fieldToSearch
  • searchText
  • format

Example: ../SearchByNumberGreaterThan?fieldToSearch=Amount&searchText=10000&format=xml


SearchByNumberGreaterThanEqualTo

Search for entries in field <fieldToSearch> that are greater than or equal to <searchText>.

Parameters:

  • fieldToSearch
  • searchText
  • format

Example: ../SearchByNumberGreaterThanEqualTo?fieldToSearch=Amount&searchText=10000&format=xml


SearchByNumberLessThan

Search for entries in field <fieldToSearch> that are less than <searchText>.

Parameters:

  • fieldToSearch
  • searchText
  • format

Example: ../SearchByNumberLessThan?fieldToSearch=Amount&searchText=100&format=xml


SearchByNumberLessThanEqualTo

Search for entries in field <fieldToSearch> that are less than or equal to <searchText>.

Parameters:

  • fieldToSearch
  • searchText
  • format

Example: ../SearchByNumberLessThanEqualTo?fieldToSearch=Amount&searchText=100&format=xml


SearchSchemaDate

Search for entries in field <fieldToSearch> that are between <from> and <to>.

Parameters:

  • fieldToSearch
  • from (DD-MM-YYYY)
  • to (DD-MM-YYYY)
  • format

Example: ../SearchSchemaDate?fieldToSearch=Date&from=01-04-2010&to=08-04-2010&format=xml


API request for a particular dataset file that was uploaded

A list of all the files that have been uploaded for a dataset can be returned as follows:

https://data.lichfielddc.gov.uk/api/The DataShare domain followed by /api/Category/The category that the dataset is in.SchemaName/The dataset to be queried.Dataset/The dataset file to show.?format=ReturnFormatThe format to return the data in (options are XML or JSON).

Example: https://data.lichfielddc.gov.uk/api/spending/payments-to-suppliers/january-2011 would return all data for January 2011 file uploaded to Payments to suppliers in the Spending category.

Restrictions

There is a currently a limit on requests of 10,000 returned results. If you need to return more results than this please get in touch with us.


URL search

The following are examples of how to open a dataset's view page with a pre-defined search:

Example search by text field:
?filter[0].ColumnToSearch=ExpenseArea&filter[0].SearchOperator=contains&filter[0].SearchText=Arts

Example search by number field:
?filter[0].ColumnToSearch=Amount&filter[0].SearchOperatorNumber=greaterthan&filter[0].SearchNumber=100000

Example search by date:
?filter[0].ColumnToSearch=Date&filter[0].SearchOperatorDate=greaterthan&filter[0].From=01-01-2011&filter[0].To=31-01-2011

Bugs and feature requests

We're always trying to make DataShare better. So, if you spot any bugs or have any feedback, stories of how you're using DataShare, or feature requests please let us know via our contact page.