Sandbox market order

Hello guys! How are u all doing?? So Im trying to make a trying app to buy/sell as a market order (last price). I did not understand yet what I need to follow. Should I sign in with api key and secret then authenticated? My app only needs account balance and make those markets trades…
I was trying this:

from coinbase.wallet.client import Client as CClient
import requests
cclient = CClient(capi_key, capi_secret)
payment_methods = cclient.get_payment_methods()

(yeah, I use capi_key and capi_secret because they stand for coinbase api key and secret)
First I get a Invalid key error:
coinbase.wallet.error.AuthenticationError: APIError(id=authentication_error): invalid api key.
So I was testing the Get All accounts for a profille like this:

 url = "https://api-public.sandbox.exchange.coinbase.com"
        headers = {"Accept": "application/json"}
        response = requests.get(url, headers=headers)
        print(response.text)

as response:

DEBUG: Starting new HTTPS connection (1): testnet.binance.vision:443
DEBUG: https://testnet.binance.vision:443 "GET /api/v3/ping HTTP/1.1" 200 2
DEBUG: https://testnet.binance.vision:443 "GET /api/v3/account?timestamp=********&signature=*****************************************HTTP/1.1" 200 248
DEBUG: Starting new HTTPS connection (1): api-public.sandbox.exchange.coinbase.com:443
{"message":"see https://docs.pro.coinbase.com for API documentation"}
DEBUG: https://api-public.sandbox.exchange.coinbase.com:443 "GET / HTTP/1.1" 404 None

help please

Hello @luizlacerdam! Can you share a larger snippet of your code so we can better determine what the problem is?

From your post, I see that you are calling the URL for the Exchange Sandbox. Exchange is a separate product from the regular Coinbase website, with separate authentication and different API endpoints. This means that you must already have an Exchange account in order to authenticate to Exchange API endpoints.

4 Likes

Hello, @jewel-ssi ! So I started over my project. As I said before, my objective is buy/sell order as market deal.
I got a good response with this code but I cant acess my sandbox account. Keeps saying that my api key are invalid. Do I need to change something, like a url?

from coinbase.wallet.client import Client as CClient
capi_key = "***********************"
capi_secret = "************************************"

cclient = CClient(capi_key, capi_secret)
accounts = cclient.get_accounts()
print(accounts)

I’m getting the my balance, how can I do the same with my sandbox account?

Hello @luizlacerdam!

Thanks for the info. Can you share with us the specific API that you are using for us to confirm that we understand your concern?
It appears to us that you are testing transactions using the Sandbox while utilizing Sign in with Coinbase endpoints and credentials. Unfortunately, as of the moment the only existing sandbox environments we have are for Coinbase Exchange/Pro API and not with Sign in with Coinbase API. This may be the reason why you are receiving the error on your end. However, if you are confused between the two, Coinbase Exchange/Pro API and Sign in With Coinbase API have dissimilar API key authentication methods and have different endpoints. You might want to check the difference of the two by referring in this link for Sign in with Coinbase API: Welcome and in this documentation: Welcome for more guidance with Coinbase Exchange/Pro API.

We hope this helps. We will appreciate it if you could answer the questions above for confirmation. Thank you!

4 Likes