Skip to main content

An unofficial python package for interacting with the Coinbase Pro API

Project description

Coinbase Pro Python API

An unofficial python package for interacting with the Coinbase Pro API. This package can be used to query both public and user specific exchange data.

Installation

pip install git+https://github.com/TerrellV/python-coinbasepro-api.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:

  1. Never store your api credentials directly in your code
  2. 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


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.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

cbp_client-0.0.1-py3-none-any.whl (9.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page