Buy using API seems to be blocking

I was able to use the API with python and place a buy yesterday. Now when I try to buy with the api I get a response like:

{“success”:true,“failure_reason”:“UNKNOWN_FAILURE_REASON”,“order_id”:“5d9bcc48-eb62-41a1-98ba-516224c48ec8”

I can go to the website and look at the details of this order and see that it’s this order id and it’s the one I bought using the API yesterday. I can buy through the website with no issues, but when I try to buy (again) with the API (python) I get this error over and over even if I try to buy different crypto. It’s as if this order that I bought yesterday (with the order_id above) with the API is blocking the API from buying now. Is there any way to clear it or something?

Any Ideas?

Ok, maybe I’m looking at this wrong. It’s saying “success”:true.

However, it’s giving the order_id of the order I placed yesterday (anytime I try to buy anything). The buy isn’t going through. Any ideas on how to deal with this?

Thanks again.

1 Like

Are you using unique client_order_id when you create new order?

Yes, thanks for the reply. In my case, I’m using my USD client_order_id. You mention unique client_order_id but it’s the account you want to buy from isn’t it? It’s going to be the same each time since I’m using the one I have for USD from my accounts list. Maybe that’s the issue. I thought I read that client_order_id was the uuid of the account you are using to buy. Is that wrong? Is it simply just a unique id?

Here is my code. It authenticates fine (otherwise I get an “unauthorized”). I can’t see what I’m doing wrong.

request_path = “/api/v3/brokerage/orders”
method = “POST”

conn = http.client.HTTPSConnection(“api.coinbase.com”)

payload = json.dumps({“client_order_id”: account_uuid,“product_id”: “BAT-USD”,“side”: “BUY”,“order_configuration”: {“market_market_ioc”:{“quote_size”: “10”}}})

message= str(timestamp) + method + request_path + payload
signature = hmac.new(secret_key.encode(“utf-8”), message.encode(“utf-8”), hashlib.sha256).hexdigest()

headers={
“Content-Type”: “application/json”,
“CB-ACCESS-KEY”: api_key,
“CB-ACCESS-TIMESTAMP”: timestamp,
“CB-ACCESS-SIGN”: signature}

conn.request(“POST”, “/api/v3/brokerage/orders”, payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode(“utf-8”))

EDIT: It does appear to be the client_order_id needing to be unique. Thanks for that.

yeah i was confused too, but docs mention client_order_id needs to be unique it seems: Create Order | Coinbase Cloud