An unofficial python package for interacting with the Coinbase Pro API
Project description
python-coinbasepro
An unofficial python package for interacting with the Coinbase Pro API. This package can be used to query both public and authenticated endpoints.
WARNING
Use at your own risk. This project is currently under development.
Installation
# Install from pypi (most common)
pip install cbp-client
# Install from Github
pip install git+https://github.com/TerrellV/python-coinbasepro.git
Quick Start - Public
from cbp_client import CBProPublic
public_api = CBProPublic()
# Bitcoin Price
price = public_api.usd_price('btc')
print(price) # returns most recent usd price as a string
# Available Trading Pairs
trading_pairs = public_api.trading_pairs()
print(trading_pairs)
# Historical Prices
# Example: Hourly prices for LTC from 2017-10-01 to 2018-01-01
price_history = public_api.historical_prices(
product_id='LTC-USD',
candle_interval='hourly',
start='2017-10-01',
end='2018-01-01'
)
print(price_history)
Quick Start - Authenticated
In order to use the authenticated api, you will need to create a file named credentials.json with a secret, passphrase, and api_key. The credentials file should be formatted as follows.
# credentials.json
{
"secret": "[api secret]",
"passphrase": "[api passphrase]",
"api_key": "[api key]"
}
Load your credentials file and pass it as a dictionary to the CBProAuthenticated class upon initialization.
Warnings:
- Never store your api credentials directly in your code
- Never commit your credentials.json file to a git repository
from cbp_client import CBProAuthenticated
with open('credentials.json') as f:
credentials = json.loads(f.read())
auth_api = CBProAuthenticated(credentials)
asset_activity = auth_api.asset_activity(
asset_symbol='BTC',
start_date='2019-01-01',
end_date='2020-01-01'
)
print(asset_activity)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cbp-client-0.0.2.tar.gz
(7.0 kB
view hashes)
Built Distribution
Close
Hashes for cbp_client-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f44b98a796522bb217522ca7ec5dc750031243ed49a62f688da3033f0ffba787 |
|
MD5 | a013c3cd35d5839bfdd78586de61344e |
|
BLAKE2b-256 | c00b2f7e29d59b7180e952c8cdb6ce998ce8ead7fcef840415828df05aa44904 |