π¦ ClawHub
Coinbase
by @mtrab
Access Coinbase API to fetch balances, get EUR trading pairs, create market or limit crypto orders, and view order history and fills.
π‘ Examples
Get Balances
from scripts.coinbase import get_euro_balance, get_btc_balance, get_all_balanceseur = get_euro_balance()
btc = get_btc_balance()
all_balances = get_all_balances()
Get Products
from scripts.coinbase import get_eur_products, get_productAll EUR trading pairs
products = get_eur_products()Specific product
btc_eur = get_product('BTC-EUR')
Create Orders
from scripts.coinbase import create_orderMarket buy order
result = create_order(
product_id='BTC-EUR',
side='BUY',
size='0.001' # Amount in base currency
)Limit order
result = create_order(
product_id='BTC-EUR',
side='BUY',
size='0.001',
price='45000', # Limit price
order_type='LIMIT'
)
Order History
from scripts.coinbase import get_fills, get_ordersRecent trades
fills = get_fills()Specific product
fills_btc = get_fills(product_id='BTC-EUR')Order history
orders = get_orders()
βοΈ Configuration
Create these files in the same directory as the script:
.coinbase-api-key # Your API key
.coinbase-api-secret # Your private key (PEM format)
Get API Keys
1. Go to Coinbase Developer Platform 2. Create a new App 3. Copy API key and private key to the filesπ Tips & Best Practices
side='BUY' or side='SELL'size is in base currency (e.g., BTC, not EUR)TERMINAL
clawhub install openclaw-coinbase