Invalid product_id using /api/v3/brokerage/orders API

Hi,

since March 29 2023, I cannot figure out why my application to make orders stopped working, using /api/v3/brokerage/orders API.
I am currently rececieving as response:
'{"error":"unknown","error_details":"Invalid product_id","message":"Invalid product_id"}'.

Have any of you encountered the same issue?

Currently I am triyng to debug the error using this python code (extracted from the application):

import os

from dotenv import load_dotenv
load_dotenv('../.env')
api_key=os.getenv('API_KEY_WRITE') 
api_secret=os.getenv('API_SECRET_WRITE') 

import json, hmac, hashlib, time, base64
from requests.utils import to_native_string
import requests

from urllib import parse
import http.client
import json

import uuid

def create_header(method = "GET", endpoint = "", body = ""):
  timestamp = str(int(time.time()))
  message = timestamp + method + endpoint + str(body or '')
  signature = hmac.new(api_secret.encode('utf-8'), message.encode('utf-8'), digestmod=hashlib.sha256).hexdigest()

  payload = body
  headers = {
    "Content-Type": "application/json",
    "CB-ACCESS-KEY": to_native_string(api_key),
    "CB-ACCESS-SIGN": to_native_string(signature),
    "CB-ACCESS-TIMESTAMP": to_native_string(timestamp)
  }
  return headers, payload


#### API CALL ####
conn = http.client.HTTPSConnection("api.coinbase.com")
endpoint= f'/api/v3/brokerage/orders'
method = 'POST'
guid = str(uuid.uuid1())

body = json.dumps({
  "order_configuration":{
    'limit_limit_gtd': {'base_size': '0.00216872', 'limit_price': '1375', 'end_time': '2023-04-13T18:23:00.000000Z',  'post_only': False},
  },
  "client_order_id": guid,
  "product_id": "ETH-EUR",
  "side": "BUY"
})
print(body)

headers, payload = create_header(method=method, endpoint=endpoint, body=body)

conn.request(method, endpoint, payload, headers)
res = conn.getresponse()
data = res.read()
print(data)

Thank you in advance.

It says you’re that your product_id is incorrect. Have you tried to use USDT or another product?

'{"error":"unknown","error_details":"Invalid product_id",**"message":"Invalid product_id"}'.**

Changing it to ETH-USDT worked for me.

Also if your using HTTPSConnection you don’t need the requests library and can use str() instead of to_native_string

Thank you Novixel.

Yes, I tried other products before writing like BTC-EUR or LTC-EUR and I have just tried, as you suggested, ETH-USDT but unfortunately I receive always invalid product _id message :frowning:
I also tried without success to generate new api key and api secret.

It’s comforting to know that the code works. I am thinking the problem it is related to my account but right now I do not know what can be and if it’s up to me (I wrote to the coinbase support). I hope to solve it soon.

Thank you also for the suggestion about requests library I will use it!

Were you able to fix this? I just realized that my script has been returning this error at least since yesterday (it ran just fine on March 29)

I’m using this script: [Python] Create market order example

Just realized that they did have issues they were aware of: Coinbase Status - Intermittent Issues for Advanced Trade. Although it’s marked resolved I seriously doubt this is the case.

I’m getting ‘invalid product ID’ errors, I believe this could be related: Invalid product_id using /api/v3/brokerage/orders API

I believe this could be related: Invalid product_id using /api/v3/brokerage/orders API

I suspect this might be a symptom of a bigger API issue, see this post: Invalid product_id using /api/v3/brokerage/orders API

They’ve apparently noticed API ‘intermittence’, I suspect it’s not solved yet despite being marked as resolved in the issue.

Yes I have noticed a few posts about the buy/sell issues. Not just on here but other forums also.
I have written the code in 5 different ways and used some other open source code and I get errors from unauthorized, 500, 401, and invalid product_ID. And then just for good measure 502.
Sometimes the same code will return 500, and if I just re-run with no change I get a 401.
It’s all fun and games when you don’t have access to the other side of the issue!

Looks like a matter of patiently waiting then.

I have the same feeling. It doesn’t work today either. I will keep you posted when coinbase support responds to my ticket.

coinbase support answered this:

We know this is frustrating that you are still getting “invalid product_id ” using /orders endpoint. We would like to let you know that this issue has been escalated internally to our engineering team.

I hope they find a solution soon :crossed_fingers:

Coinbase support suggest to add

wallet:user:read

permission and it worked!

So there was a change in api permission after March 29 because it has worked before that date. I suggested updating the documentation here Advanced Trade REST API Overview | Coinbase Cloud since it looks like that it is necessary only

wallet:buys:create

Thank you all for your support.

1 Like

It worked, thanks! I really hope they update the API docs because this is extremely difficult (and unintuitive) to spot.

thank you so much for posting this! i was going crazy!

still getting the “Invalid product_id” message. The keys no longer support granularity. I can only create a new Trade key, no wallet:buys:create option or any other option.

Here is what I just ran. Basically it is a copy/paste from

#Market BUY order using the official Coinbase Advanced SDK
from coinbase.rest import RESTClient
from json import dumps

symbol = ‘XLM-USD’
entryUSD = ‘15’
clientOID = ‘T5-20240307test’

#T5new TRADE key 2024-03-05
api_key = ‘organizations/my secret’
api_secret = ‘-----BEGIN EC PRIVATE KEY-----\nmy secret\n-----END EC PRIVATE KEY-----\n’

client = RESTClient(api_key=api_key, api_secret=api_secret)

order = client.market_order_buy(
client_order_id=“clientOID”,
product_id=“symbol”,
quote_size=“entryUSD”
)

order_id = order[“order_id”]

fills = client.get_fills(order_id=order_id)
print(dumps(fills, indent=2))

This is the gist of the response:
requests.exceptions.HTTPError: 400 Client Error: Bad Request {“error”:“INVALID_ARGUMENT”,“error_details”:“Invalid product_id”,“message”:“Invalid product_id”}

What gives?