OpenSpending API Server
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docker
os_api
tests
.dockerignore
.gitignore
.travis.yml
Dockerfile Comment out dev dep in Dockerfile Oct 3, 2018
LICENSE
Makefile
README.md
dev_server.py
docker-compose.ci.yml
requirements.in
requirements.txt
setup.py
tox.ini

README.md

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 v5.x 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