-
Notifications
You must be signed in to change notification settings - Fork 13
Web API
Some actions require authentication, particularly those that write to the system or aim to access protected data (e.g. pre-publication datasets). For this purpose, each user is provided an API key. The key is displayed in the Settings (go to the dashboard and click on Change next to the Information header). You can use it to perform authentication by adding the following into the HTTP headers (change your-api-key
to the API key you find in your settings):
Authorization: ApiKey your-api-key
All API calls that return JSON support JSON-P (JSON with padding). You can add a ?callback=foo
parameter to any query to wrap the output in a function call. This is used to include JSON data in other sites that do not support CORS:
$ curl http://mapthemoney.org/cra.json?callback=foo
foo({
"description": "Data published by HM Treasury.",
"name": "cra",
"label": "Country Regional Analysis v2009",
"currency": "GBP"
});
This can be used in remote web pages to include data as a simple script
tag:
<script>
function foo(data) {
alert(data.label);
}
</script>
<script src="http://mapthemoney.org/cra.json?callback=foo"></script>
Most analytical functions are exposed as part of the Cubes package's Slicer OLAP API. They will access the database and allow for many operations such as data filtering and aggregation.
The slicer API is exposed at /api/slicer
(no version indicated). For usage examples see: How Where Does My Money Go uses the slicer API.
This needs to be fleshed out, but working with curl
should allow you to see the format for most calls.
-
GET /api/3/reference
- static reference data (countries, currencies etc) -
GET /api/3/sessions
- information about the current user session -
GET /api/3/datasets
- dataset listing -
POST /api/3/datasets
- create a dataset -
GET /api/3/datasets/:name
- get basic metadata -
POST /api/3/datasets/:name
- write basic metadata (also: public/private) -
DELETE /api/3/datasets/:name
- delete a whole dataset -
GET /api/3/datasets/:name/model
- get dataset model (OLAP measures and dimensions) -
POST /api/3/datasets/:name/model
- write model -
GET /api/3/datasets/:name/managers
- manager accounts -
POST /api/3/datasets/:name/managers
- edit access rights -
GET /api/3/datasets/:name/structure
- source data fields and samples -
GET /api/3/datasets/:name/sources
- list existing sources -
POST /api/3/datasets/:name/sources/submit
- submit a new source from aurl
and begin loading -
POST /api/3/datasets/:name/sources/upload
- upload afile
to create a new source and begin loading -
GET /api/3/datasets/:name/sources/:source
- get source metadata by the normalised file name -
GET /api/3/datasets/:name/serve/:source
- download the source data as-is -
GET /api/3/datasets/:name/runs
- list runs for a dataset -
GET /api/3/datasets/:name/runs/:id
- get details for a run, including the log
If you are stuck with the installation or usage of SpenDB, please: search for existing bug reports or file an issue, or message the spendb mailing list.