/blitz_api

Primary LanguagePythonMIT LicenseMIT

blitz_api

Configuration

Create a .env file with your bitcoind and lnd configuration. See the .env_sample file for all configuration options.

Dependencies

Installation

⚠️ To setup a development environment for BlitzAPI skip to the Development section.

Linux / macOS

make install

or

python -m pip install -r requirements.txt

Windows

py -m pip install -r requirements.txt

Run the application

Linux / macOS

make run

or

python -m uvicorn app.main:app --reload

Windows

py -m uvicorn app.main:app --reload

Development

It is recommended to have python-poetry installed.

From within the blitz_api folder open a poetry shell via:

poetry shell

(To exit the poetry shell use: exit)

Installation

poetry install

or

make install_dev

If python dependencies have been changed it's necessary to freeze all requirements to requirements.txt:

poetry export -f requirements.txt --output requirements.txt

ℹ️ This will skip all dev dependencies by default.
This step is required to avoid having to install poetry for final deployment.

Testing

Make sure to include tests for important pieces of submitted code.

Run the tests with pytest

make tests

Run tests and generate a coverage

make coverage

This will run tests and generate a coverage html file in this folder: ./htmlcov

Once the API is running swagger docs can be found here:

http://127.0.0.1:8000/latest/docs

Useful cURL commands to test the API

curl -N http://127.0.0.1:8000/v1/sse/subscribe
curl -N http://127.0.0.1:8000/v1/bitcoin/getblockchaininfo
curl -X POST -N http://127.0.0.1:8000/v1/setup/type/1
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{"password":"12345678"}' \
  http://127.0.0.1:8000/system/login

Acknowledgements

Integrated Libraries: