First of all, you should understand that due to the specifics of some shopping cart platforms, we must perform multiple requests to the store to generate a response for you. The number of requests directly depends on the selected response fields and, for some platforms, may also exponentially depend on the number of items in the response (e.g., products or orders). Therefore, the more items you try to retrieve at once, the more requests we will need to make to the store.

That is why we recommend obtaining only the response fields that are truly necessary for your business logic.

Outputting only necessary fields has the following advantages:

  • Reduces the load on the store's server.
  • Reduces request execution time.
  • Ensures that request time does not increase if we add new fields to the response of a particular method.

The methods that can be filtered are those that return information about an object (the GET method is used when making an API request). These methods end in "list" or "info" (e.g., "order.list", "product.info," and so on). You can view a list of available methods for a specific platform using the "cart.methods" method or directly in the documentation.

To filter the response, you need to specify the "response_fields" parameter. The parameter's value is formed according to the response model of a specific API method. For example, for the "product.list" method, the value of the "response_fields" parameter may be as follows:

{return_code,return_message,pagination,result{product{id,type,model,u_sku,name,price,manage_stock,images{http_path,type},product_options{id,name,option_items{id,name}}}}}

Here is an example CURL request and response:

curl 'https://api.api2cart.com/v1.1/product.list.json?count=10&response_fields=%7Breturn_code%2Creturn_message%2Cpagination%2Cresult%7Bproduct%7Bid%2Ctype%2Cmodel%2Cu_sku%2Cname%2Cprice%2Cmanage_stock%2Cimages%7Bhttp_path%2Ctype%7D%2Cproduct_options%7Bid%2Cname%2Coption_items%7Bid%2Cname%7D%7D%7D%7D%7D' \
--header 'x-api-key: xxxxx' \
--header 'x-store-key: xxxxx'
Expand response

The "response_fields" parameter supports filtering of any nesting level, except for the "additional_fields" and "custom_fields" field values, for which only first-level filtering is supported, for example: response_fields={result{product{id,additional_fields{tags}}}}

In case you need to retrieve all possible fields for any reason, you can specify the value of response_fields as follows: {return_code,return_message,pagination,result}

Most API methods also support response field filtering using the 'params' and 'exclude' parameters, but they are limited to the first level of nesting and are considered deprecated. We will not be adding support for these parameters in new API methods.