An RESTful API for U.S. federal spending data.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bulk_downloads Adding bulk_downloads folder Nov 3, 2017
config removing newrelic.ini Aug 22, 2018
csv_downloads re-adding missing readme Feb 1, 2018
requirements Merge remote-tracking branch 'origin/dev' into feature/dev-1346-disas… Sep 7, 2018
usaspending_api Merge branch 'dev' into mod/dev-1527-download-specific-cols Sep 20, 2018
.codeclimate.yml Merge remote-tracking branch 'origin/dev' into codeclimate-tweaks May 7, 2018
.gitignore Consolidating .idea folder ignores. Adding bulk_downloads Sep 10, 2018
.pyup.yml adding pyup file so pyup.io stops making PRs Aug 27, 2018
.style.yapf Work on detached_award_procurement_id basis Nov 6, 2017
.travis.yml Adding migration, added references to matviews in helper sql Sep 13, 2018
Dockerfile adding memcache deps to dockerfile Mar 28, 2017
README.md Showing venv prompt Sep 10, 2018
data_reformatting.md Remove State Code -> Foreign Province mapping May 11, 2017
docker-compose.yml upgrade postgres version in compose Jun 20, 2018
docker_django_management.py Fixing flake8 in root folder Jan 29, 2018
loading_data.md Adding files to be hotfixed to correct usaspending readme Sep 6, 2018
manage.py Fixing flake8 in root folder Jan 29, 2018
pull_request_template.md Adding PR template for Github Sep 14, 2018
readme.jpg Adding files to be hotfixed to correct usaspending readme Sep 6, 2018
sample_api.json added sample api response, big model update for awards and related mo… Sep 20, 2016
setup.cfg Removing .git which is excluded by default Sep 10, 2018
test.json Surrogate CFDA keys May 15, 2017

README.md

USAspending API

Build Status Test Coverage Code Climate

This API is utilized by USAspending.gov to obtain all federal spending data which is open source and provided to the public as part of the DATA Act.

USAspending Landing Page

Install

Ensure the following dependencies are installed and working prior to continuing:

Requirements

  • python3
  • pyenv using Python 3.5.x
    • NOTE: Read full install. brew install needs to be followed by additional steps to modify and source your ~/.bash_profile
  • PostgreSQL 10.x (with a dedicated data_store_api database)
  • direnv
    • For Mac OSX, be sure to put the hook in your ~/.bash_profile, not ~/.bashrc
  • Bash or another Unix Shell equivalent
  • Command line package manager
    • Windows' WSL bash uses apt-get
    • OSX users will use Homebrew

Setup

Navigate to the base file directory for the USAspending repositories

$ mkdir -p usaspending && cd usaspending
$ git clone https://github.com/fedspendingtransparency/usaspending-api.git
$ cd usaspending-api

Create and activate the virtual environment using venv, and ensure the right version of Python 3.5.x is being used (the latest RHEL package available for python35u, currently 3.5.5)

$ pyenv install 3.5.5
$ pyenv local 3.5.5
$ python -m venv .venv/usaspending-api
$ source .venv/usaspending-api/bin/activate

Your prompt should then look as below to show you are in the virtual environment named usaspending-api (to exit that virtual environment, simply type deactivate at the prompt).

(usaspending-api) $ 

pip install application dependencies

💡 (try a different WiFi if you're current one blocks dependency downloads)

(usaspending-api) $ pip install -r requirements/requirements.txt

Set environment variables (fill in the connection string placeholders, e.g. USER, PASSWORD, HOST, PORT) *note: default port for PostgreSQL is 5432

(usaspending-api) $ echo "export DATABASE_URL='postgres://USER:PASSWORD@HOST:PORT/data_store_api'" >> .envrc

Test the database connection and upate the data_store_api schema

(usaspending-api) $ ./manage.py migrate

Start up the site

(usaspending-api) $ ./manage.py runserver

The application will be available at http://localhost:8000

API

In your local development environment, available API endpoints may be found at http://localhost:8000/docs/endpoints

Deployed production API endpoints and docs are found by following links here: https://api.usaspending.gov

Loading Data

For details on loading reference data, DATA Act Broker submissions, and current USAspending data into the API, see loading_data.md.

For details on how our data loaders modify incoming data, see data_changes.md.

Public Domain License

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.