Using Filters

Using filters

Use field filtering to receive in the response only the data that is necessary. This allows to significantly speed up the response from the server and reduce the load on it.

To filter fields, use the params parameter.

The request example:

https://api.api2cart.com/v1.1/.json?api_key=&store_key=&start=0&count=4&params=<the list of displayed fields are separated by comma

The methods by which you can apply filtering are those methods that return information about the object (when making an API request GET method is used). These methods end in “list”, “info” or “find” (eg order.listproduct.info, etc.) You can see the list of available methods for a specific platform by using method cart.methods.

Value force_all

To get all the fields (attributes) that the platform supports in this method, the value force_all is used. It is specified in the params parameter. When using the value force_all, the list of other fields that need to be displayed can not be specified. They will be presented in the response. With force_all, the received fields of the first nesting level can be applied as filter names in the params parameter. Therefore, when displaying a list of required fields in the response, the params parameter values are the names of these fields, separated by commas.

Fields to which filtering can be applied can be divided into several groups:

General (unified):

These fields are available on any platform. For example, for a product, it can be a name, description, price; for orders - status, delivery address, payment method. In some cases, when the platform does not support some common field for all platforms, “null” will be returned in the corresponding field.

Additional:

Additional fields are only available on a specific platform. They may differ in name from the fields of another platform, or even be absent on it. For example, on Opencart there is a field "product_tag", and on Bigcommerce there is "search_keywords" field.

Additional fields are obtained (filtered) in the same way as the main ones. In the request, they are returned in the "additional_fields" array:


To select (filter) additional fields in params, specify additional_fields and NECESSARILY a list of additional fields that need to be received.

For example:

https://api.api2cart.com/v1.1/order.info.json?api_key=<api_key>&store_key=<store_key>&order_id=2127450013827&params=id, order_id, additional_fields, order_name, financial_status

Special (custom)

To expand the functionality of a particular store, owners install plugins or add an array of standard fields for a particular platform. Accordingly, the list of these special fields will be absent for another store on this platform and even on the same version. Therefore, to take into account all changes in the data structure and obtain all data with changes, an individual approach is required.

Special fields are returned in the array "custom_fields".

For selection (filtering) of special fields the same principle is used, as for additional. Only in this case the list of special fields does not need to be specified:

https://api.api2cart.com/v1.1/product.list.json?api_key=&store_key=&start=0&count=10&params=id,name,description,custom_fields

Additional parameter exclude

The additional parameter exclude is used in conjunction with the force_all parameter to exclude from the array all returned fields that are not required.

For example:

https://api.api2cart.com/v1.1/order.info.json?api_key=&store_key=&order_id=1&params=force_all&exclude=additional_fields,order_products