Coinbase Pro API Authentication

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.

I came here to ask questions at first, now I find myself answering more than I do anything else :smile:

2 Likes

And we very much appreciate you for that @cleggink !!

1 Like

@blah - bringing your question regarding the Sandbox here:

No Text For API Keys from Sandbox

There seems to be an issue with 2factor auth for the sandbox accounts. I use text for Pro, and it works fine. However, when I attempt to generate API keys for the Sandbox account, no text message is sent, and the window that pops up to receive the auth code contains a broken link and some text suggesting that “authenticator” must be used.

Checking on this for you.

Thank you. Before reading this, I posted the following update elsewhere:

Ruskel5070

Haha, same here. I kept wiping my glasses to make sure I wasn’t missing a the “Post” button (yes, I searched prior to even attempting to post). I guess I will wait it out and hopefully figure it out by then.

Hi, I’m having some issues with the sandbox exchange api. I cant get my api keys to work, I keep getting an “Invalid API Key” message. Is there something that im missing? (I’m using cbpro on python)

Hi @Nick_of_Time ! Thank you for joining and letting us know about your issue. Will you please provide a bit more information about the error you are receiving? A screenshot or some other description will help us test and attempt to recreate your issue. Thanks!

Anyone using Golang to interact with the API? This is what I have right now and I’m getting invalid signature in the Coinbase response:

prehashString := now + method + coinbaseProURL + path
hmacKey, _ := base64.StdEncoding.DecodeString(secret)
signature := hmac.New(sha256.New, hmacKey)
signature.Write([]byte(prehashString))
cbAccessSignature := base64.URLEncoding.EncodeToString(signature.Sum(nil))

u, _ := url.ParseRequestURI(coinbaseProURL)
u.Path = path
urlString := u.String()

request, err := http.NewRequest(method, urlString, nil)
if err != nil {
	log.Fatalln(err)
}
request.Header.Add("Content-Type", "application/json")
request.Header.Set("CB-ACCESS-KEY", key)
request.Header.Add("CB-ACCESS-SIGN", cbAccessSignature)
request.Header.Set("CB-ACCESS-TIMESTAMP", now)
request.Header.Set("CB-ACCESS-PASSPHRASE", passphrase)

I had to delete and redo my API keys on Sandbox site the first time. Also make sure, you’re using the API generated keys from the Sandbox site and not your actual API keys from your live accounts.

Secondly, in the CBPRO LIbrary, the URLs in the Authenticated Client automatically refer to either an older or actual (non sand boxed API). Specifying the API URL helped me.

Hi @SubStandard I was attempting to bypass the sandbox API and use the production API. I created a few different keys with varying permissions (e.g. View/Trade/Transfer)…non of them worked. The URL I’m using is https://api.exchange.coinbase.com and set in an .env file, I’m not using a library. I don’t think there is one for Golang.

I’ll add the SANDBOX configs and see if I have any better success with that.

@arood @SubStandard Hello! Sorry for the delay, I’m not at my program today, but I can grab a screenshot tomorrow. If I remember, my code is basically:

client = cbpro.AuthenticatedClient(key, secret, passphrase, api_url = "https://api-
public.sandbox.pro.coinbase.com)
print(client.get_accounts())

and this prints an ‘Invalid API key’ message. Its just a message not an error. I’ve already tried deleting the API key for the sandbox and I made sure to use the url.
I’m thinking that maybe I have to activate the API key or something? I’m a little confused on what I’ve actually set up in terms of accounts but I don’t know what all is required.

So far my steps are: Create a sandbox account, create a testing portfolio, create an API key for both portfolios, and tried both keys in my program.

@jacobH the first thing i see you are missing is:
.header(​"​Accept​"​, ​"​application/json​"​)

Second check your api keys, the api key itself goes into the hash encryption method not the secret key.