coinbase / coinbase-advanced-py

The Advanced API Python SDK is a Python package that makes it easy to interact with the Coinbase Advanced API. The SDK handles authentication, HTTP connections, and provides helpful methods for interacting with the API.
https://docs.cdp.coinbase.com/advanced-trade/docs/welcome/
Apache License 2.0
101 stars 27 forks source link

401 every time #56

Closed elmutt closed 2 months ago

elmutt commented 3 months ago

I am following the example from the coinbase advanced trade getting started guide verbatim and no matter what I do I get a 401 error. I have tried recreating the api keys, toggling them on / off, nothing works. Super frustrating and it is not possible to talk to someone about this issue at coinbase support

Here is the example code Im following:

from coinbase.rest import RESTClient from json import dumps import math

api_key = "organizations/{org_id}/apiKeys/{key_id}" api_secret = "-----BEGIN EC PRIVATE KEY-----\nYOUR PRIVATE KEY\n-----END EC PRIVATE KEY-----\n"

client = RESTClient(api_key=api_key, api_secret=api_secret)

product = client.get_product("BTC-USD") btc_usd_price = float(product["price"]) adjusted_btc_usd_price = str(math.floor(btc_usd_price - (btc_usd_price * 0.05)))

limit_order = client.limit_order_gtc_buy( client_order_id="00000002", product_id="BTC-USD", base_size="0.0002", limit_price=adjusted_btc_usd_price )

limit_order_id = limit_order["order_id"]

client.cancel_orders(order_ids=[limit_order_id])

github-actions[bot] commented 3 months ago

Thank you for reporting! If this is an SDK specific issue, we will look into it and get back to you soon. If this is an API related request, report it in our Advanced API Discord instead (use this invite link if it's your first time accessing the Discord).