Table of Contents
Get source code
git clone git@github.com:ilya-bc/blockchain-exchange-api.git
cd blockchain-exchange-api
Install package. Since there are hundred ways to do that, a standardised way for this project is with Makefile
. It will create virtual environment with pipenv and will use python 3.7
as its interpreter
# For general use
make install
# For development
make install-dev
Actual trading and accessing balance of your account requires authentication with an API key. In order to get one:
You should have an account at blockchain.com | exchange
Create API key here and store information. Note, you can have setup key with permissions view
and view & trade
.
You should receive an email asking you to activate API key.
Setup the following environment variable
export BLOCKCHAIN_API_SECRET="__ENTER_YOUR_API_SECRET_HERE__"
Note
If you use pipenv
then you can just put it into .env
file (ignored by git) at the root of the cloned directory.
All API is available though a websocket client:
import logging
from bcx.client import BlockchainWebsocketClient
logging.basicConfig(level=logging.INFO)
client = BlockchainWebsocketClient()
client.subscribe_to_heartbeat()
client.subscribe_to_orderbook_l2("BTC-USD")
See API reference and gallery of examples for more info.