Sign inSign up

openspending/os-api

By openspending

•Updated almost 7 years ago

OpenSpending API server (based on babbage)

Image
0

9.0K

openspending/os-api repository overview

⁠OpenSpending-Next API

Gitter Build Status Coverage Status Issues Docs

An API to explore the OpenSpending database.

⁠Quick start

Clone the repo, install dependencies from pypi, and run the server. See the docs⁠ for more information.

For development, create a .env file and add environmental variables:

# Address for the postgres instance, e.g. postgresql://postgres@db/postgres
OS_API_ENGINE=postgresql://postgres@db/postgres
# Address of RabbitMQ instance
OS_MQ_ADDRESS=mq
# Address of elasticsearch server
OS_ELASTICSEARCH_ADDRESS=localhost:9200
# Address of RabbitMQ
CELERY_CONFIG=amqp://guest:guest@localhost:5672//
CELERY_BACKEND_CONFIG=amqp://guest:guest@localhost:5672//
# Address of Redis instance
OS_API_CACHE=redis

# Check health of ElasticSearch before starting app (optional)
OS_CHECK_ES_HEALTHY='True'

A development server can be started with: python dev_server.py

⁠Testing

You need a few services running, namely elasticsearch v1.5 running on localhost:9200 and PostgreSQL

Then set a few environment variables (your DB connection string might vary):

$ export OS_API_ENGINE=postgresql://postgres@/postgres
$ export DPP_DB_ENGINE=postgresql://postgres@/postgres
$ export OS_ELASTICSEARCH_ADDRESS=localhost:9200
$ export ELASTICSEARCH_ADDRESS=localhost:9200

Install a few dependencies:

$ npm install -g os-types
$ sudo apt-get install libleveldb-dev libleveldb1 libpq-dev python3-dev
$ pip3 install tox coveralls datapackage-pipelines[speedup] datapackage-pipelines-fiscal psycopg2-binary

# or for MacOS
$ npm install -g os-types
$ brew install leveldb
$ pip3 install tox coveralls datapackage-pipelines[speedup] datapackage-pipelines-fiscal psycopg2-binary

Fill the local DB with a sample fiscal data:

$ cd tests/sample_data && dpp run --verbose --concurrency=8 all

Then run:

$ tox

Tag summary

Content type

Image

Digest

Size

113.2 MB

Last updated

almost 7 years ago

docker pull openspending/os-api