VPCart API: List

This List method allow developers to retrieve more than a record based on provided fieldname(s) and tablename supplied in the Endpoint url and also other related parameters.

List Endpoint URL and Request Parameters

POST  <VPCart site url>/cart_api/<table name>/list/


Example of request parameters in JSON request:

{

      "fieldnames": "firstname,lastname,email",

      "orderby": "contactid",

      "sortby": "asc",

      "howmany": "2",

      "filter1_field": "firstname",

      "filter1_operator": "like",

      "filter1_value": "vpcart",

      "filter2_field": "lastname",

      "filter2_operator": "=",

      "filter2_value": "testing"

}

<table name>

Mandatory parameter in List Endpoint url.
Please replace with the VPCart table name you want.

For the list of tables allowed to be included in this endpoint url, is stored in the config xapi_allowtables.

Default tables for config “xapi_allowtables” are :
blogs
categories

content

contentcategories

currencyvalues

customers

news

orders

products

shopcountries

shopstates

NOTE : Although you are able to enter any other VPCart table(s) into the list if you need, however we are strongly advise you to not enter other VPCart table(s) for security reasons.

fieldnames

Optional parameter. If blank, will return a max of 200 fieldnames by default.
You can enter fieldnames of a related table specified in <table name> end point, separated by comma, eg. firstname,lastname,email.

orderby

Optional parameter. This parameter allow you to include one field used for ordering records in the result.
If no parameter value is passed, the orderby field will use the primary key field of the table as default.

sortby

Optional parameter. Default value is asc if you do not pass this parameter value. 
Valid value :
asc   : To order your records result in ascending.

desc : To order your records result in descending.

howmany

Optional parameter. Must be a numeric value.
Default value is 200 if you do not pass this parameter value.
Used to specify how many rows returned for the result.

filter(x)_field

Optional parameter. You can specify a ‘WHERE’ clause like you use in common SQL query.
Used to define a fieldname for ‘WHERE’ clause and can be in array if you need more.
If this parameter is specified, you must also include filter(x)_operator and filter(x)_value in the JSON request.
Max number of array supported for this filter is 2, that means you can only pass until filter2_field.

Example, if you want to retrieve list of customer records based on their first name and last name, then you should include fieldname firstname and lastname in the array of your JSON request eg :


"filter1_field": "firstname",



"filter2_field": "lastname",

filter(x)_operator

Optional parameter. You can specify a ‘WHERE’ clause operator like you use in common SQL query.
Used to define operator for ‘WHERE’ clause and can be in array if you need more.
If this parameter is specified, you must also include filter(x)_field and filter(x)_value in the JSON request.
Max number of array supported for this filter is 2, that means you can only pass until filter2_operator.
Valid value : = , < , <= , > , >= , like

Example, if you want to retrieve list of customer records based on their first name and last name, then you should include operator for both fieldname firstname and lastname in the array of your JSON request eg :


"filter1_operator": "like",

"filter2_operator": "=",

 

filter(x)_value

Optional parameter. You can specify a ‘WHERE’ clause value like you use in common SQL query.
Used to define any value you would like for ‘WHERE’ clause and can be in array if you need more.
If this parameter is specified, you must also include filter(x)_field and filter(x)_operator in the JSON request.
Max number of array supported for this filter is 2, that means you can only pass until filter2_value.

Example, if you want to retrieve list of customer records based on their first name and last name contains John Due, then you should include value for both fieldname firstname and lastname in the array of your JSON request eg :


"filter1_value": "John",

"filter2_value": "Due"