An open API service indexing awesome lists of open source software.

https://github.com/cfpb/ccdb5-api

An API that provides an interface to search complaint data.
https://github.com/cfpb/ccdb5-api

api django elasticsearch hacktoberfest

Last synced: 3 months ago
JSON representation

An API that provides an interface to search complaint data.

Awesome Lists containing this project

README

          

![ci](https://github.com/cfpb/ccdb5-api/workflows/ci/badge.svg)[![Coverage Status](https://coveralls.io/repos/github/cfpb/ccdb5-api/badge.svg?branch=main)](https://coveralls.io/github/cfpb/ccdb5-api?branch=main)

ccdb5-api
================

An API that provides an interface to search complaint data.

## Features

* Search complaint data
* Suggest complaint data based on input
* Get complaint based on ID

## Requirements

Requirements are batch-installed via pip (see below).

* django - Web framework
* django-localflavor - Country-specific Django helpers
* djangorestframework - Rest API framework
* opensearchpy - low-and-high-level client for OpenSearch
* requests - http requests to get different data format

## Setup & Running
This repository assumes that you have an instance of OpenSearch (or Elasticsearch) running with complaint data set up and running.

If not, please refer to the [CCDB Data Pipeline](https://github.com/cfpb/ccdb-data-pipeline/blob/main/INSTALL.md) to
load data into OpenSearch.

### Environment Variables
This project uses environment variables and uses autoenv to automatically define environment variables and launch the virtualenv upon cding to the project folder.

You will need to install Autoenv if you haven't:
```shell
brew install autoenv
```

After installation, Homebrew will output instructions similar to:

```shell
To finish the installation, source activate.sh in your shell:
source /Users/[YOUR USERNAME]/homebrew/opt/autoenv/activate.sh
```

Run that now for your initial setup. Any time you run the project you’ll need to run that last line, so if you’ll be working with the project consistently, we suggest adding it to your Bash profile by running:
```
echo 'source /Users/[YOUR USERNAME]/homebrew/opt/autoenv/activate.sh' >> ~/.bash_profile
```

If you need to find this info again later, you can run:
```shell
brew info autoenv
```

You can then copy the `.env_SAMPLE` file to `.env`, then update any environment variables accordingly.

### Dependencies
First, create a virtual environment for Python dependencies:
```
mkvirtualenv ccdb5-api
```

Next, use `pip` to install dependencies, which are defined in `setup.py`:
```
pip install -e '.[testing]'
```

With that, you just need a few additional commands to get up and running:
```
python manage.py runserver
```

## API Docs

Original API documentation is available at https://cfpb.github.io/ccdb5-api/, but the docs are not being updated at this time.

## Running Tests

If you have [Tox](https://tox.readthedocs.io/en/latest/) installed (recommended),
you can run the specs for this project with the `tox` command.

If not, this command will run the specs on the python version your local
environment has installed: `./manage.py test`.

If you run the tests via Tox, it will automatically display spec coverage information.
To get test coverage information outside of Tox, install [Coverage.py](https://coverage.readthedocs.io/en/coverage-4.5.1a/)
and run these commands:

```
coverage erase
coverage run manage.py test
coverage report
```