im having problems with this 404 error through the advanced trade API written in python here is the code and the API response please help.
Response Code: 404
Response Data: b’{“error”:“NOT_FOUND”,“error_details”:“ProductID \“product_id\” could not be found.”,“message”:“ProductID \“product_id\” could not be found.”}’
b’{“error”:“NOT_FOUND”,“error_details”:“ProductID \“product_id\” could not be found.”,“message”:“ProductID \“product_id\” could not be found.”}’
import configparser
import hashlib
import hmac
import time
from http import client
from ratelimiter import RateLimiter
import loggingconfig = configparser.ConfigParser()
config.read(r"D:\repos\repo\Coinbase\config.ini")
API_KEY = config.get(‘coinbase’, ‘API_KEY’)
SECRET_KEY = config.get(‘coinbase’, ‘SECRET_KEY’)limiter = RateLimiter(max_calls=70, period=1, callback=1)
@limiter
def get_market_trades(product_id=“BTC-USD”, limit=10):
api_key = API_KEY
api_secret = SECRET_KEY
api_version = ‘2021-07-09’
timestamp = str(int(time.time()))
method = ‘GET’
payload = ‘’
path = f"/v3/brokerage/products/{product_id}/ticker"
query_params = f"limit={limit}"
message = f"{timestamp}{method}{path}?{query_params}"
signature = hmac.new(api_secret.encode(‘utf-8’), message.encode(‘utf-8’), digestmod=hashlib.sha256).hexdigest()
conn = client.HTTPSConnection(“api.coinbase.com”)
headers = {
‘CB-ACCESS-KEY’: api_key,
‘CB-ACCESS-SIGN’: signature,
‘CB-ACCESS-TIMESTAMP’: timestamp,
‘Content-Type’: ‘application/json’,
‘CB-VERSION’: api_version
}
conn.request(method=method, url=f"{path}?{query_params}", body=payload, headers=headers)
res = conn.getresponse()
response_code = res.status
data = res.read()
print(“Response Code:”, response_code)
print(“Response Data:”, data)
logging.info(“Response Code: %s”, response_code)
logging.info(“Response Data: %s”, data)
conn.close()
return datadef fetch_market_trades():
result = get_market_trades(“product_id”, 10)
print(result)fetch_market_trades()