How can I connect to the Coinbase Sandbox API
How can I use the Rest Client to connect to Coinbase Sandbox API?
Thanks
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).
You do:
from coinbase.rest import RESTClient
from coinbase.websocket import WSClient,
http = RESTClient(
api_key=key.api,
api_secret=key.secret,
timeout=5,
base_url="api-sandbox.coinbase.com"
)
ws = WSClient(
api_key=key.api,
api_secret=key.secret,
base_url="wss://ws-feed-public.sandbox.exchange.coinbase.com"
)
Thanks for your answer @melukasz . I was unable to connect to the API. Maybe I'm confused about the sandbox API in general. I created an account here https://public-sandbox.exchange.coinbase.com/ and as a base_url I use the following https://api-public.sandbox.exchange.coinbase.com . I also found that I have to use an API key, Secret Key, Passphrase combination, but the coinbase.rest.RESTClient doesnt even have a passphrase argument.
Thanks for your answer @melukasz . I was unable to connect to the API. Maybe I'm confused about the sandbox API in general. I created an account here https://public-sandbox.exchange.coinbase.com/ and as a base_url I use the following https://api-public.sandbox.exchange.coinbase.com . I also found that I have to use an API key, Secret Key, Passphrase combination, but the coinbase.rest.RESTClient doesnt even have a passphrase argument.
O wow, I didn't know something like this exists https://public-sandbox.exchange.coinbase.com/ Thanks a lot!
Just FYI I saw that the cbpro library does the trick, but it's really outdated, so I ended up using the requests library and send custom HTTP requests.
Och right, that sandbox is for buisness owners only :/
For anyone looking to connect to the sandbox, you can monkeypatch the BASE_URL constant:
import os
import coinbase.constants
coinbase.constants.BASE_URL = "api-sandbox.coinbase.com"
from coinbase.rest import RESTClient
client = RESTClient(
api_key=os.environ.get('COINBASE_KEY'),
api_secret=os.environ.get('COINBASE_SECRET'),
)
accounts = client.get_accounts()
print(accounts)
Hope that helps