Python bindings for the Cryptowatch API. Cryptocurrency markets, assets, instruments and exchanges data.
Cryptowatch Python SDK
The Cryptowatch Python library provides a convenient access to the Cryptowatch API from applications written in the Python language.
It includes the following features:
- Auto-serialization of API responses into Python objects
- API credentials automatically read from your
- Custom exceptions for API-specific issues (e.g.: Requests Allowance)
- Smart back-off retries in case of API connectivity loss
pip install cryptowatch-sdk
- python v3.7+
- requests v0.8.8+
- marshmallow v3.2.2+
- pyyaml v5.1.2+
Using a credential file will allow you to authenticate your requests and grant you the API access of your account tier (Free, Basic or Pro).
Setup your credential file
- Generate an Cryptowatch API key from your account
- Create your credential file on your machine by running in order:
echo "apikey: 123" > $HOME/.cw/credentials.yml(where
123is your 20 digits public key)
- Verify with
cat $HOME/.cw/credentials.ymlthat you see something like below (
123being your public key):
The SDK will read your public key as soon as
import cryptowatch is ran in your script.
import cryptowatch as cw # Assets cw.assets.list() cw.assets.get("BTC") # Exchanges cw.exchanges.list() cw.exchanges.get("KRAKEN") # Instruments cw.instruments.list() cw.instruments.get("BTCUSD") # Markets cw.markets.list() # Returns list of all markets on all exchanges cw.markets.list("BINANCE") # Returns all markets on Binance # Returns market summary (last, high, low, change, volume) cw.markets.get("KRAKEN:BTCUSD") # Return market candlestick info (open, high, low, close, volume) on some timeframes cw.markets.get("KRAKEN:BTCUSD", ohlc=True, periods=["4h", "1h", "1d"]) # Returns market last trades cw.markets.get("KRAKEN:BTCUSD", trades=True) # Return market current orderbook cw.markets.get("KRAKEN:BTCUSD", orderbook=True) # Return market current orderbook liquidity cw.markets.get("KRAKEN:BTCUSD", liquidity=True)
Logging can be enabled through Python's
import logging logging.basicConfig() logging.getLogger("cryptowatch").setLevel(logging.DEBUG)
The library exposes a simple utility, named
cryptowatch, to return last market prices.
By default it returns Kraken's BTCUSD market
> cryptowatch 7425.0
Add another Kraken market to return this market last price
> cryptowatch btceur 6758.1
You can also specify your own exchange
> cryptowatch binance:ethbtc 0.020359
When the market doesn't exist a return code of
1 will be set (
> cryptowatch binance:nosuchmarketusd > echo $? 1
Unit tests are under the tests folder and use
pytest, run them all with:
Integration tests sending real HTTP requests to the Cryptowatch API can be run with:
Testing and developement dependencies are in the requirements.txt file, install them with:
pip install -r requirements.txt
The code base use the Black linter, run it with:
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size cryptowatch_sdk-0.0.3-py3-none-any.whl (14.3 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size cryptowatch-sdk-0.0.3.tar.gz (11.5 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for cryptowatch_sdk-0.0.3-py3-none-any.whl