Error with params

    def get_fills(self):
        params = {
            'limit': 50,
        }
        return self._send_message('get', '/orders/historical/fills')
        # return self._send_message('get', '/orders/historical/fills', params=params)

Without params, it works well, but with params, it gives an error with code 401. Did I miss anything?

The URL with params:
https://www.coinbase.com/api/v3/brokerage/orders/historical/fills?limit=50

The URL without params:
https://www.coinbase.com/api/v3/brokerage/orders/historical/fills

Check Authenticating Messages. With Advanced Trade query part should not be included in requestPath when creating signature.

1 Like

Make sure you aren’t signing it with the params. Regardless of what your params are, the signature should always just use
https://www.coinbase.com/api/v3/brokerage/orders/historical/fills

But then the actual endpoint that you call should be
https://www.coinbase.com/api/v3/brokerage/orders/historical/fills?limit=50

Idk if this helps, but here’s my code in JS using axios. It’s a little specific to my app, but it shows how I’m differentiating the urls.

async function getLimitedFillsNew(userID, limit) {
  return new Promise(async (resolve, reject) => {
    try {
      const userAPI = cache.getAPI(userID);
      const secret = userAPI.CB_SECRET;
      const key = userAPI.CB_ACCESS_KEY;

      const method = 'GET';
      const path = "/api/v3/brokerage/orders/historical/fills";
      const body = "";

      function sign(str, apiSecret) {
        const hash = CryptoJS.HmacSHA256(str, apiSecret);
        return hash.toString();
      }
      const timestamp = Math.floor(Date.now() / 1000).toString();
      const str = timestamp + method + path + body
      const sig = sign(str, secret)

      const options = {
        method: 'GET',
        timeout: 10000,
        url: `https://coinbase.com/api/v3/brokerage/orders/historical/fills?limit=250`,
        headers: {
          Accept: 'application/json',
          'CB-ACCESS-KEY': key,
          'CB-ACCESS-SIGN': sig,
          'CB-ACCESS-TIMESTAMP': timestamp
        }
      };

      let response = await axios.request(options);
      resolve(response.data);
    } catch (err) {
      reject(err);
    }
  });
}
2 Likes

@muktupavels Thank you! This solves the issue.

@jmicko Thank you for your reply.