Working example of /api/v3/brokerage/products/{product_id}/candles in Python?

I’ve been trying to get this working and I’m receiving a 403?
/api/v3/brokerage/products/{product_id}/candles

According to the documentation the message for signing should look like this:
1679750419GET/https://api.coinbase.com/api/v3/brokerage/products/BTC-GBP/candles?start=1679619600&end=1679648400&granularity=ONE_HOUR

I’m receiving an error 401 which suggests it’s something to do with authentication. The documentation on this page says there is no required scope: REST API Overview | Coinbase Cloud

I’m having a similar problem with /transaction_summary which also requires params to be passed. I’m wondering if there is something unusual about the way the message needs to be signed or the params need to be passed. I expect both issues I’m experiencing have the same issue.

The code example in Python looks the same as mine, but that’s not saying much as I’m having a problem with another endpoint as well where it should work and it doesn’t.

If you don’t have a Python example, any other language should be fine as I should be able to see how it’s done and convert it.

Thanks in advance.

Do not include query params when generating signature for advanced trade API :

Thanks a lot, that fixed that one.

Message to sign: 1679754673GET/api/v3/brokerage/products/BTC-GBP/candles
GET request to: https://api.coinbase.com/api/v3/brokerage/products/BTC-GBP/candles?start=1679619600&end=1679648400&granularity=ONE_HOUR

print(len(resp.json()[“candles”]))
9

The fees one still isn’t working for some reason. I’m getting a 403 on it.

Message to sign: 1679755190GET/api/v3/brokerage/transaction_summary
GET request to: https://api.coinbase.com/api/v3/brokerage/transaction_summary?user_native_currency=USD

Can you see what is wrong with this one?

Do you have wallet:transactions:read permission? Otherwise no idea…

A 403 means the request itself is not right, and 401 is to do with authentication. I’m getting a 403 so there is something wrong with the request. It’s not clear from the docs which fields are optional or not. I was told in another post that it’s only user_native_currency is needed but I’m not sure.

Did not you get 401 when you were incorrectly signing message? And after fixing you now get 403, right?

I just removed mentioned permission and got 403 Invalid scope error. Check your API key permissions.

Just checked, user_native_currency is no longer needed, it was in past.

Hmm, can no longer find related info, but there used to be info about error code meaning. Are you reading response body for your 40x errors? If not check if there is info that might help.

Sadly error message does not say what scope are needed:

{"error":"unknown","error_details":"incorrect scopes","message":"incorrect scopes"}

It’s working now, thanks.

I had more than one API key and I had wallet:transactions:send checked instead of wallet:transactions:read.