Cannot get filled orders

Hi there,

Thanks for having created this forum :slightly_smiling_face:.
I have a little question:
I’m trying to get data from the Coinbase PRO API, but I’m not able to connect to the Get all fills endpoint.
Each time I try to connect, I get the following error:
HTTP request for https://api.exchange.coinbase.com/fills has failed, 400: Bad Request

I don’t understand why it doesn’t works since I have been able to get data from at least 5 others endpoints.
Here is the function that I have wrote to make the request:

async makeRequest(endpoint) {

    const timestamp = Math.trunc(Date.now() / 1000);

    const method = 'GET';

    const message = timestamp + method + endpoint;

    const key = Buffer(this.SECRET_KEY, 'base64');

    const hmac = crypto.createHmac('sha256', key);

    const signature = hmac.update(message).digest('base64');

    const headers = {

      'CB-ACCESS-KEY': this.API_KEY,

      'CB-ACCESS-SIGN': signature,

      'CB-ACCESS-TIMESTAMP': timestamp,

      'CB-ACCESS-PASSPHRASE': this.PASSWORD,

    };

    const url = this.BASE + endpoint;

    const response = await fetch(url, {method: method, headers: headers});

    if (response.ok) {

      debug(url, ' succes');

      const data = await response.json();

      return data;

    } else {

      debug(`HTTP request for ${url} has failed, ${response.status}: ${response.statusText}`);

    }

  }

Do you have any idea why it doesn’t works ?
Thanks and have a good day

How are you setting endpoint?

I mean the actual variable you are passing to that function, I would say it’s malformed, but you don’t have it’s declaration in your code here.

Thanks for the answer :slightly_smiling_face:
I am setting it in this line:
const txs = await this.makeRequest('/fills');

But as I said, it does works with other endpoints, for example when I am using those:

    const txs = await this.makeRequest('/transfers');
    const infos = await this.makeRequest(`/currencies/${symbol}`);
    const accounts = await this.makeRequest('/accounts');

everything works. But when I use “/fills” :
HTTP request for https://api.exchange.coinbase.com/fills has failed, 400: Bad Request

–url ‘https://api.exchange.coinbase.com/fills?profile_id=default&limit=100’ \

Your request should look like this according to the documentation
https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getfills

Yes, I also tried it before, and got the same error:
const txs = await this.makeRequest('/fills?profile_id=default&limit=100');

HTTP request for https://api.exchange.coinbase.com/fills?profile_id=default&limit=100 has failed, 400: Bad Request

Tried adding code to get the profile_id? Instead of the default item

Hmm, no
But I just gave it a try and it return the same error (I will not put all the chain for security reason, but basically):
const txs = await this.makeRequest('/fills?profile_id=84236984-h8kj-...&limit=100');
return same error.
It’s strange, maybe it’s the endpoint that have an issue, but I made a quick search before asking for help here and nobody talk about it.

Hi @Terry971 - Thank you for reaching out and joining our community! Also, thank you @cleggink for being so active and helpful! I am working with the team here to see what more we can help with regarding this error - will update soon. Thanks again!

Hi @arood, thanks !
Waiting for your update :slightly_smiling_face:

For that call I believe you must either specify a

product_id=btc-usd

OR

order_id=123

See Query Params section here - Get all fills

Thank you @PattyO608 ! You are on point! @Terry971 you need to specify a product_id=btc-usd OR order_id=123 with that endpoint - https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getfills#:~:text=a%20specific%20order.-,Eit[…]uct_id%20is%20required.,-product_id

Yep, it worked !
Thanks @PattyO608 and @arood :slightly_smiling_face: