The Store API
A JSON API for accessing data
programmatically. Generally the result of a request is a JSON
object.
JSONP
All the requests support JSONP: Supply
a callback parameter, the JSON data will be wrapped with a
function call using the value of the callback parameter as its
name. Example (a JSONP version of a Tax Share example, below):
${c.jsonp_url}
Requests
The store responds to the following requests:
Search
Search the spending data in the store. Modulo some checks and minor modifications (e.g. to ensure json is returned), search parameters are passed directly through to solr so you can use any parameters supported by Solr. Key basic paramemters:
- q = {value}: query string. Can use free text or restrict on specific
fields using 'field:value' syntax. Look at SOLR docs for more information.
- rows= {value}: limit the number of results to value. Defaults to 10.
- start = {value}: start return results at start. Defaults to 0.
Returns data in JSON and JSONP is supported. Examples:
${url(controller='api',
action='search')}
${url(controller='api',
action='search', q='children')}
REST
A family of calls for navigating the store's data. For details, see:
${c.rest_url}
JSONP also works with the REST API.
Aggregate
Retrieves a dataset, specifying axes of interest. The data will be
aggregated over all other axes.
Example:
${c.aggregate_url}
Parameters:
- dataset={value} - the name of the data set to retrieve. In the above
example, 'cra' is the name of the Country Regional Analysis data
set.
- include-{key}={value} (optional, repeatable) - omit entries whose
{key} does not match {value}. In the above example, this is
used to examine only entries whose 'cofog1' (meaning the first level
function) is '07' (meaning 'Health').
- breakdown-{key}={value} (optional, repeatable) - Makes an axis with {key}
as its coordinate. {value} is ignored. There is no need to break down
by time; spending is always broken down by time.
- per-{statistic}={key} (optional, repeatable) - Divides the results by
a {statistic} that depends on {key}. The motivating example is
"per-population2006=region", to work out per-capita spending, but the
mechanism is general.
- per-{statistic}= (optional, repeatable) - Divides the results by
a {statistic} that depends on time. The motivating example is
"per-gdp_deflator2006=", to work out spending in real terms, but the
mechanism is general.
- exclude-{key}={value} (deprecated) - No effect.
- start_date (deprecated) - No effect.
- end_date (deprecated) - No effect.
Tax share
Estimates a household's tax contribution based on simple proxy data. The
estimate allows for both direct tax (including income tax, national insurance
and council tax) and indirect tax (including VAT, alcohol and tobacco duty,
and fuel duty).
Example:
${c.mytax_url}
Parameters:
- income - Total household income, including all pension and benefits.
This is used to estimate total tax paid, including both direct and
indirect taxation.