Coinbase Pro API Authentication

I just signed up to this forum and there is NO button to create a new thread. I am forced to hijack this thread and ask how I am supposed to create new threads/topics? Do I need to request special permission to post a new topic or is the UI truly that horrendous that I can’t find a button to do so?

Thanks!

2 Likes

It takes some time as your user account starts off with no permissions, but after reading the blog posts and becoming a basic user, you can write threads. I too had the same problem. In the badges it tells you what is needed to become a basic user.
Take it easy

1 Like

Thanks for clearing this up, @SubStandard! There are not that many threads on this forum, so I am not sure how long I need to look at them before I am granted permissions to create my own threads.

My issue is that I seem to be unable to get a sandbox account created via https://public.sandbox.pro.coinbase.com/ because it redirects me to https://www.coinbase.com/setup/identity which is ostensibly is not a Sandbox account (based on the URL). I am missing something?

Note that I already have a Coinbase Pro account and I do not want regular Coinbase account. So, what’s the right way to get Sandbox account created?

Thanks!

The link you provided https://public.sandbox.pro.coinbase.com/ is the one I used. I did have to sign in with Coinbase Logins information (which if you have a coinbase Pro account it should be the same login information) after logging in the User interface looks like your coinbase pro interface but it says Sandbox in the URL. Obtaining the API Key, Secret and Pass Phrase by clicking on your name in the upper right and selecting API. Now if only I could figure out this CB-signature stuff in python I could play with pretend currencies in the SandBox…

1 Like

Hi Larry
I would like to get the Python example as well. I am trying to make API call in Coinbase Exchange but getting issues making the signature. It would be great if we could get a sample code in Python to generate the signature.
Thanks

@achuckoury , I went ahead and translated the JavaScript sample I provided above to Python. I have tested and this works for me.

import time
import base64
import hmac
import hashlib
import requests

# current unix timestamp (seconds)
cb_access_timestamp = str(time.time())

# obtained API key, secret, and passphrase from https://pro.coinbase.com/profile/api
cb_access_passphrase = ''
cb_api_key = ''
secret = ''
path = '/orders?status=done' # fetching my completed orders
body = '' # body is empty in this case
method = 'GET'
message = '{}{}{}{}'.format(cb_access_timestamp, method, path, body)
url = 'https://api.exchange.coinbase.com{}'.format(path)

hmac_key = base64.b64decode(secret)
digest = hmac.new(hmac_key, message.encode('utf-8'), digestmod=hashlib.sha256).digest()
signature = base64.b64encode(digest).decode('utf-8')

headers = {
    'Content-Type': 'application/json',
    'CB-ACCESS-KEY': cb_api_key,
    'CB-ACCESS-PASSPHRASE': cb_access_passphrase,
    'CB-ACCESS-SIGN': signature,
    'CB-ACCESS-TIMESTAMP': cb_access_timestamp
}

r = requests.get(url, headers=headers)
print(r.json())

Cheers!

2 Likes

@larry.kubin Thank you so much for the python signature code. I can talk with the API now!!!

2 Likes

So I deleted that last post because of a stupid error on my part with a swapped variable in my signature function. I’ve got full function on the pro api now. However I’m not sure if I’m ready to start making actual trades. I am ready to sandbox my algorithm. But when I change my credentials over to the sandbox api keys and urls I get this mess


Any ideas as to the source of this connection exception?

Jesus help me I did it again. Forgot a / in my url. I should sleep more

1 Like

Thanks Larry. The Python code is working.

1 Like

please could you document an example … not as code but as result. something alike

signing: <1643877611GET/accounts>
secret(encoded) :<Be0gsYS52jo0NG2EwU7JCE/jXSozFlKusQ4qYitXkdIhaOGburNFfjYBO/mIZfymMreLm81AZLKnHEZcH6mXow==>
signature: <5MRIa5n4rIupKQD/O/uhbP/QcQO4RTdnQdib5KhH8vQ>

thank you

Hi @SwissGeorge - Welcome to our Forum! Unfortunately, we cannot provide hashed examples of signatures on this forum. Hoping the sample code here will suffice. Thanks!

Hello,

I am currently working in the Coinbase Pro API sandbox. When trying to complete my orders, i get the error that the product_id is not valid. However, this does not apply for the product_id “BTC-EUR”. All others dont work. Is the Sandbox version limited to only Bitcoin and are all other currencies blocked?
Thank you!

Coinbase limits access to certain trading pairs based on the users location. Are you saying that you get that error for all other 400+ trading pairs or at least the ones you tried but NOT for BTC-EUR only? I have not read anywhere that the sandbox only allows testing of BTC pairs.

I can retrieve the data for all trading pairs (Websocket) but when placing the market order i receive the following message “product_id is not a valid product”.
To note, I am not located in the US.
For instance, the following code gives me the product_id error:
url = “https://api-public.sandbox.exchange.coinbase.com
client = cbpro.AuthenticatedClient(coinbase_API_key, coinbase_API_secret, passphrase, url)
client.place_market_order(product_id = “ETH-EUR”,
side = “buy”,
size = 0.01,
overdraft_enabled = False))

I have tried sending orders for trading pairs such as ETH-EUR but they did not go through, only BTC-EUR worked. To note, I am not in the US. I can retrieve the data for ETH-EUR via the Websocket but cannot place the order

It states that the order books available are limited within the sandbox since it is only for testing.

1 Like

A lot of functionality is absent in the sandbox. I couldn’t make trades there. While testing my code i was trying BTC-USD. The order would execute and then cancel itself. A week or so ago it was working fine, not sure what happened but my code works fine on the live server.

Hi All! and welcome @BVermeulen ! Loving the conversation and feedback - thank you! To follow up, yes, Sandbox is limited - only a few currency pairs as you’ve pointed out. BTC books are the healthiest and we have to fix the Order books manually because of crazy limit orders put on the book. Then Price Protection cancel orders automatically.

Funny thing about that is the only reason anyone comes here is to ask a aquestion.

@blah
People come for different reasons. I come here to answer questions and to participate in this community collectively called Coinbase. Did you have another question? As far as I can see you asked about privileges on the forum and you got some people interested in helping with the answer.