List Products Parameters

Hello, I am receiving Unauthorized error response whenever I put offset and limit in the query params. What’s missing? I just followed what is stated in the documentation. Also, what are product types? Help me, thanks

Hi @goodboy! Welcome to the forum! :wave:

We appreciate your interest in using Coinbase APIs. With regards to your concern on receiving the unauthorized error response when requesting the List Products endpoint, we are happy to help but first we need to provide us the following information to further assist you with your concern.

  • Are you able to successfully request the List Products endpoint without the limit and offset query parameters?
  • To send requests to the Advanced Trade API, you must sign and authenticate each endpoint with an API key. Can you share with us a code snippet that demonstrates how you request the said API endpoint? Please ensure not to send any sensitive information that may compromise your account.
  • Can you check in your API settings if the API key you are using has the required wallet:user:read permission when using the List Products endpoint?

Once you send us the information requested above, we’ll work to quickly address your concerns. Thank you and have a great day! :sun_behind_small_cloud:

1 Like
  • Are you able to successfully request the List Products endpoint without the limit and offset query parameters?
    Yes, I am able to successfully retrieve responses from List products endpoint without the query parameters.

  • To send requests to the Advanced Trade API, you must sign and authenticate each endpoint with an API key. Can you share with us a code snippet that demonstrates how you request the said API endpoint? Please ensure not to send any sensitive information that may compromise your account.
    Sure, here it is. My pre-request script is inside the collection itself

// 1. Import crypto-js library
var CryptoJS = require("crypto-js");
 
// 2. Create the JSON request object
var req = {
    timestamp: Math.floor(Date.now()/1000), // seconds since Unix epoch
    method: pm.request.method,
    path: pm.request.url.getPathWithQuery(),
    body: (pm.request.method === 'GET' || !data) ? '' : pm.request.body, // empty for GET requests
    message: undefined,
    secret: pm.collectionVariables.get("coinbase-api-secret"), // read value from collection variable
    hmac: undefined,
    signature: undefined,
};
 
// 3. Create the message to be signed
req.message = req.timestamp + req.method + req.path + req.body;
 
// 4. Create HMAC using message and API secret
req.hmac = CryptoJS.HmacSHA256(req.message, req.secret);
 
// 5. Obtain signature by converting HMAC to hexadecimal String
req.signature = req.hmac.toString(CryptoJS.enc.Hex);
 
// 6. Log the request
console.info("request: ", req);
 
// 7. Set Postman request's authentication headers for Coinbase REST API call
pm.collectionVariables.set("coinbase-api-timestamp", req.timestamp);
pm.collectionVariables.set("coinbase-api-signature", req.signature);

Hello user! :wave:

Thank you for the details you have provided. We can see that upon creation of your JSON request object, your path uses the “getPathWithQuery()” method. This means that it returns the complete path, including the query string which leads to the unauthorized error response.

In the documentation, it is stated that the path (requestPath) should only be the full path minus the base URL and query parameters. For the List Products endpoint to be working, you should use the “getPath()” method instead.

We hope this helps. Have a great day!

1 Like

Wow! Great. It’s working now. Thank you for your help! How about the product_type parameter, is this like the fiat or cryptocurrency type?

Hi @goodboy! We’re glad we are able to resolve your concern.

For your other query about the value to be specified in the query parameter product_type, please be informed that currently “SPOT” is the only product_type listed under Advanced Trade. This product_type applies to all trading pairs being supported by this Coinbase product. Hence, we wish to inform you that we have already notified the relevant teams with this and the documentation will be updated accordingly.

We hope this helps. Thank you and have a great day!

2 Likes