{"id":35060939,"url":"https://github.com/openspending/os-api","last_synced_at":"2025-12-27T10:32:02.187Z","repository":{"id":52159513,"uuid":"47968159","full_name":"openspending/os-api","owner":"openspending","description":"OpenSpending API Server","archived":false,"fork":false,"pushed_at":"2021-05-06T19:19:15.000Z","size":6260,"stargazers_count":4,"open_issues_count":6,"forks_count":7,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-08T16:29:31.685Z","etag":null,"topics":["api","fdp","fiscal","opendata","openspending"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openspending.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-14T10:32:34.000Z","updated_at":"2020-07-22T17:59:38.000Z","dependencies_parsed_at":"2022-08-28T15:52:23.058Z","dependency_job_id":null,"html_url":"https://github.com/openspending/os-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/openspending/os-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openspending%2Fos-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openspending%2Fos-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openspending%2Fos-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openspending%2Fos-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openspending","download_url":"https://codeload.github.com/openspending/os-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openspending%2Fos-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28077505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-27T02:00:05.897Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","fdp","fiscal","opendata","openspending"],"created_at":"2025-12-27T10:32:00.598Z","updated_at":"2025-12-27T10:32:02.176Z","avatar_url":"https://github.com/openspending.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenSpending API\n\n[![Gitter](https://img.shields.io/gitter/room/openspending/chat.svg)](https://gitter.im/openspending/chat)\n[![Build Status](https://travis-ci.org/openspending/os-api.svg?branch=master)](https://travis-ci.org/openspending/os-api)\n[![Coverage Status](https://coveralls.io/repos/openspending/os-api/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/openspending/os-api?branch=master)\n[![Issues](https://img.shields.io/badge/issue-tracker-orange.svg)](https://github.com/openspending/openspending/issues)\n[![Docs](https://img.shields.io/badge/docs-latest-blue.svg)](http://docs.openspending.org/)\n\nAn API to explore the OpenSpending database.\n\n- An analytical API powered by [Babbage](https://github.com/openspending/babbage)\n- A search API to access package-level meta data\n- A search API to access fiscal line-level data\n\nThe API is written in Python 3 and uses [Flask](http://flask.pocoo.org/) blueprints.\n\n## Quick start\n\nClone the repo, install dependencies from pypi, and run the server.\n\nFor development, create a `.env` file and add environmental variables:\n\n```ini\n# Address for the postgres instance, e.g. postgresql://postgres@db/postgres\nOS_API_ENGINE=postgresql://postgres@db/postgres\n# Address of elasticsearch server\nOS_ELASTICSEARCH_ADDRESS=localhost:9200\n# Address of Redis instance\nOS_API_CACHE=redis\n\n# Check health of ElasticSearch before starting app (optional)\nOS_CHECK_ES_HEALTHY='True'\n```\n\nWith the backing services available, a development server can be started with:\n`python dev_server.py`\n\n## Available Endpoints\n\n- `/api/3/info/\u003cdataset\u003e/package`\n  - Returns the Fiscal Data-Pacakge for this dataset\n- `/api/3/cubes`:\n  - Returns a list of the available datasets in the store\n- `/api/3/cubes/\u003cdataset\u003e/model`:\n  - Returns the `babbage` model for the dataset. This is the model which is used  when querying the data.\n- `/api/3/cubes/\u003cdataset\u003e/facts`:\n  - Returns individual entries from the dataset in non-aggregated form.\n  - Parameters:\n    - `cut` - filters on the data (`field_name:value`, `field_name:value|field_name:value` etc.)\n    - `fields` - fields to return\n    - `order` - data ordering (e.g. `field_name:desc`)\n    - `pagesize` - number of entries in one batch of returned data\n    - `page` - page selection\n- `/api/3/cubes/\u003cdataset\u003e/members/\u003cdimension\u003e`\n  - Returns the distinct set of values for a specific dimension.\n  - Parameters: `cut`, `order`, `page` and `pagesize` as above\n- `/api/3/cubes/\u003cdataset\u003e/aggregate`\n  - Returns an aggregate of the data in the specified dataset.\n  - Parameters:\n    - `cut`, `order`, `page` and `pagesize` as above\n    - `drilldown` - group by these dimensions (e.g. `field_name_1|field_name_2`)\n    - `aggregates` - which measures to aggregate (and what function to perform (e.g. `amount.sum`, `count`)\n\n## Testing\n\nYou need a few services running, namely Elasticsearch v5.x running on localhost:9200 and PostgreSQL.\n\nThen set a few environment variables (your DB connection string might vary):\n```bash\n$ export OS_API_ENGINE=postgresql://postgres@/postgres\n$ export DPP_DB_ENGINE=postgresql://postgres@/postgres\n$ export OS_ELASTICSEARCH_ADDRESS=localhost:9200\n$ export ELASTICSEARCH_ADDRESS=localhost:9200\n```\n\nInstall a few dependencies:\n```bash\n$ npm install -g os-types\n$ sudo apt-get install libleveldb-dev libleveldb1 libpq-dev python3-dev\n$ pip3 install tox coveralls 'datapackage-pipelines[speedup]\u003e=2.0.0' 'datapackage-pipelines-fiscal\u003e=1.2.0' psycopg2-binary\n\n# or for MacOS\n$ npm install -g os-types\n$ brew install leveldb\n$ pip3 install tox coveralls 'datapackage-pipelines[speedup]\u003e=2.0.0' 'datapackage-pipelines-fiscal\u003e=1.2.0' psycopg2-binary\n```\n\nFill the local DB with a sample fiscal data:\n```\n$ cd tests/sample_data \u0026\u0026 dpp run --verbose --concurrency=8 all\n```\n\nThen run:\n```bash\n$ tox\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenspending%2Fos-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenspending%2Fos-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenspending%2Fos-api/lists"}