Integration Basics
Integrate with 30+ Shopping Platforms
API2Cart provides a single API to integrate with many shopping carts, including industry leaders like Shopify, Magento, WooCommerce, Bigcommerce, Volusion, PrestaShop, OpenCart, and others.
The API is accessed over HTTPS protocol and is available for authenticated users only. It is based on the RESTful principles, which makes it easier to test and implement.
Getting Started with API2Cart
Following the idea that it takes trying to see if it works as needed, we suggest the following steps :
- Register an API2Cart account and access the system.
- Add online stores and execute API methods to see how it works with orders, products, customers, shipments, and other data from stores.
-
How to Add an Online Store to Your API2Cart Account.
How to connect a store to API2Cart depends on the type of shopping cart it is based on, hosted (e.g. 3dcart, Volusion, Shopify) or open-source (e.g. PrestaShop, WooCommerce, OpenCart). You can see what you need to add stores here.
About Hosted Carts
You can add the stores in 2 ways:
- Using the interface in your account. Press the Add Store button, paste the store’s URL, select its type, and enter the API key and API password. (Read our FAQ on how to get API Key and Token from your API-based shopping cart)
- By calling the cart.create method. To add the store correctly, provide all the necessary parameters that are described in the documentation.
public function apiCreate() { $params = array( 'cart_id' => 'BigcommerceApi', 'store_url' => 'http://example.com', 'verify' => 'false',//set this param=false for test only 'store_key' => 'ab37fc230bc5df63a5be1b11220949be',//for self-hosted cart only 'AdminAccount' => 'admin', 'ApiPath' => 'http://example.com/api/v1', 'ApiKey' => '6b89704cd75738cb0f9f6468d5462aba', ); return $api->request('cart.create', $params); }
Note: Hosted carts generate store keys automatically.
About Open-Source Carts
API2Cart connects stores built on such platforms through connection bridges.
You can add the stores in 2 ways:
- Using the interface in your account. Press the Add Store button, paste the store’s URL, select its type, download the bridge, and add it to the store’s root folder via an FTP client. (Read our FAQ on what is a connection bridge is and why you need it)
- By calling the API methods mentioned below in the right order.
- Call the cart.bridge method and get the store_key.
- Call the bridge.download method and pass the store_key.
- Upload the bridge to the root folder of the store.
- Call the cart.create method and paste the previously generated store_url.
-
How to Create a User Wizard
API2Cart’s wizard leads the customers through a series of well-defined steps to simplify the process of performing integration.
E.g. User wizard in API2Cart demo module.
You can also create a user wizard yourself so that it suits your unique business needs. The number of steps may vary, but the first step is always to add the store to your API2Cart account.
Include the following parameters to add the store correctly:
- the type of the store (e.g Magento, Shopify, etc.).
To make data entry easier, use the drop down list. See the cart.list method get all the supported platforms and call the cart.bridge method to receive the store key.
- store’s URL
- choose a way to set the bridge (automatically or manually)
E.g. User wizard in API2Cart admin panel.
In case if you would like us to help you with the user wizard, leave us a message.
-
How to Work With Products
The Product API methods allow you to manage products in the store. In particular, you can do the following:
- Create - add products
- Read - find and retrieve lists and specific info
- Update - update item data
- Delete - delete products
Call the product.add method to add new products to the store. Do not forget to specify the necessary parameters.
public function apiAdd($params) { $params = array( 'name' => 'Bag', 'model' => 'bag_01', 'description' => 'This is new product', 'price' => 99.9, 'quantity' => 12, 'manufacturer'=> 'Test', ); return $api->request('product.add', $params); }
Note: You can add image, tax, manufacturer, option, variant, or other info to the product by calling the following methods:
- product.image.add
- product.manufacturer.add
- product.option.add
-
product.option.assign
- product.option.value.add
- product.option.value.assign
-
product.tax.add
- product.variant.add
To see the whole list of supported API methods, jump into documentation.
To update a product, call the product.list method and retrieve the product id.
public function apiList($params) { $params = array( 'start' => 0, 'count' => 50, 'params' => 'id,name,price', ); return $api->request('product.list', $params); }
Use the product id to update the price and inventory(quantity) for this product by executing the product.update method.
public function apiUpdate($params) { $params = array( 'id' => 69, 'price' => 89, ); return $api->request('product.update', $params); }
Tip: To update variant, image, and product option values, call the following methods:
For more API methods visit our documentation.
-
Instruction for working with Products for API2Cart API v1.1
First, we recommend you to explore the Product Methods documentation. Most methods support filters like modified_from, modified_to.
When working with shopping platforms that support multilanguage or/and multistore, you need to pass store_id and/or lang_id parameters. In case the parameter is not passed, we automatically set the default value of store_id and lang_id.
API2Cart returns response only for one language and one store in one request. To get the data for other stores or in other languages, send a request specifying other store_id and lang_id. Use cart.info method to retrieve the list of stores and languages if they are multiple.
Use product.count method to get the amount of products.
Use product.list or product.info to get information on products. The response structure can be found in the end of description of each method.
There can be the following types of products in product.list or product.info response: simple, virtual, configurable, bundle, grouped, downloadable, gift_card. For WooCommerce there are also supported simple-subscription і configurable-subscription product types.
- simple - a simple product that can be a standalone product or as a part of configurable, bundle or grouped product.
- virtual - a non-physical product like service, warranty, subscription. It can be a standalone product or a part of configurable or grouped types.
- configurable - a product that contains variants based on option combinations.
- bundle - a product that consists of separate products both physical and virtual. The customer can select which products and how many of them will form the final bundle product. This product type is often used in in electronics, e.g. cameras or computers.
- grouped - several separate products gathered into a group. You can find the ids of products included in a group in the grouped_products_ids massive in response of product.list or product.info. To get the info about these products, use product.list method specifying products_ids parameter. The parameter value must be unique ids that are in grouped_products_ids.
- downloadable - an electronic product that can be downloaded: multimedia or software.
- gift_card - a gift certificate of a certain value.
- simple-subscription and configurable-subscription are similar to virtual products. These types are used only in WooCommerce stores when WooCommerce Subscriptions module is active. Configurable-subscription type has variants.
To get variants or bundle items use product.child_item.list, specifying product_id or product_ids parameter to get list of child items of a certain product or few. If you specify “product_id=1”, the method will return child items for product with id=1, using product_ids parameter you can get list of child items for multiple products (max 100).
product.child_item.list does not have a separate method for getting total number of child items. However, there is a total_count field in response that returns the total number of child items for a specific request with the specified parameters. For example, if you make two requests for the same product_ids, but in one request you specify avail_sale parameter, their total_count values can be different. There can be requests with zero count, in that case you can find out only the number of variants, for example “product.child_item.list.json?product_ids=a,b,c&count=0”.
product.child_item.list method has a combination field in response, which contains option ids and their values that form a particular variant or bundle item. But not always all the options contained in the product form a combination of variants. Some platforms (like Magento or WooCommerce) allow custom options, that don’t form combination but allow to additionally customize the product, even if it has variants.
Use “params=force_all” parameter only when you really need all the available information. Otherwise, it is better to specify the needed fields, for example “params=id, name, price, advanced_price, quantity”.
-
Retrieve the needed products using product.list or product.info methods
-
Get product ids if the type of product is configurable, bundle or configurable-subscription
-
Get all ids from grouped_products_ids if the product type is grouped
-
Get all ids from grouped_products_ids if the product type is grouped. Retrieve variants and bundle components using product.child_item.list method specifying product_ids parameter. (See how to get product ids in step 3)
-
Retrieve all products contained in groups using product.list method specifying product_ids parameter. (See how to get product ids in step 3)
Data retrieval order:
An example of data retrieval for products and their child items (variant, bundle items).
-
Call product.list or product.info method and collect received ids for products of configurable or bundle types.
Request example: product.list.json?api_key=xxxxx&store_key=xxxxx&start=0&count=5¶ms=id,name,price,type,product_optionsResponse example:
{ "return_code": 0, "return_message": "", "result": { "product": [ { "id": "93", "type": "configurable", "name": "[Sample] 1 L Le Parfait Jar", "price": 9.95, "product_options": [ { "id": "32", "product_option_id": 112, "name": "Size", "description": "Size", "sort_order": 1, "type": "radio", "required": true, "option_items": [ { "id": "95", "product_option_item_id": null, "name": "Small", "sort_order": 0, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "Small" } }, { "id": "96", "product_option_item_id": null, "name": "Medium", "sort_order": 1, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "Medium" } }, { "id": "97", "product_option_item_id": null, "name": "Large", "sort_order": 2, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "Large" } } ], "additional_fields": { "default_option_id": null } }, { "id": "3", "product_option_id": 111, "name": "Color", "description": "Color", "sort_order": 0, "type": "radio", "required": true, "option_items": [ { "id": "7", "product_option_item_id": null, "name": "Silver", "sort_order": 1, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "#cccccc" } }, { "id": "8", "product_option_item_id": null, "name": "Black", "sort_order": 2, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "#000000" } }, { "id": "10", "product_option_item_id": null, "name": "Blue", "sort_order": 4, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "#123c91" } }, { "id": "13", "product_option_item_id": null, "name": "Orange", "sort_order": 7, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "#e35e20" } } ], "additional_fields": { "default_option_id": null } } ] }, { "id": "107", "type": "configurable", "name": "[Sample] Dustpan & Brush", "price": 34.95, "product_options": [ { "id": "3", "product_option_id": 114, "name": "Color", "description": "Color", "sort_order": 0, "type": "radio", "required": true, "option_items": [ { "id": "7", "product_option_item_id": null, "name": "Silver", "sort_order": 1, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "#cccccc" } }, { "id": "8", "product_option_item_id": null, "name": "Black", "sort_order": 2, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "#000000" } }, { "id": "10", "product_option_item_id": null, "name": "Blue", "sort_order": 4, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "#123c91" } }, { "id": "13", "product_option_item_id": null, "name": "Orange", "sort_order": 7, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "#e35e20" } } ], "additional_fields": { "default_option_id": null } } ] }, { "id": "111", "type": "simple", "name": "[Sample] Smith Journal 13", "price": 25, "product_options": [ { "id": "31", "product_option_id": 113, "name": "EULA", "description": "EULA", "sort_order": 0, "type": "checkbox", "required": true, "option_items": [ { "id": "93", "product_option_item_id": null, "name": "Yes", "sort_order": 0, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "Yes" } }, { "id": "94", "product_option_item_id": null, "name": "No", "sort_order": 1, "price": 0, "weight": 0, "quantity": null, "type_price": "percent", "sku": null, "additional_fields": { "full_description": "No" } } ], "additional_fields": { "default_option_id": "94" } } ] } ] } }
-
Call product.child_item.list specifying “product_ids” parameter
Request example: product.child_item.list.json?api_key=xxxxx&store_key=xxxxxx&start=5&count=10¶ms=id,default_price,advanced_price,combination,sku,parent_id&product_ids=93,107Response example:
{ "return_code": 0, "return_message": "", "result": { "total_count": 16, "children": [ { "id": "56", "parent_id": "93", "sku": "SLLPJ-973630F5", "combination": [ { "option_id": "111", "option_value_id": "10" }, { "option_id": "112", "option_value_id": "97" } ], "default_price": 7, "advanced_price": [ { "id": "sp", "value": 7, "avail": true, "group_id": null, "quantity_from": null, "start_time": null, "expire_time": null } ] }, { "id": "57", "parent_id": "93", "sku": "SLLPJ-889E9C0A", "combination": [ { "option_id": "111", "option_value_id": "13" }, { "option_id": "112", "option_value_id": "97" } ], "default_price": 7, "advanced_price": [ { "id": "sp", "value": 7, "avail": true, "group_id": null, "quantity_from": null, "start_time": null, "expire_time": null } ] }, { "id": "77", "parent_id": "107", "sku": "SIL-EDF0AC9C", "combination": [ { "option_id": "114", "option_value_id": "7" } ], "default_price": 34.95, "advanced_price": [ ] }, { "id": "78", "parent_id": "107", "sku": "BLA-6D013D80", "combination": [ { "option_id": "114", "option_value_id": "8" } ], "default_price": 34.95, "advanced_price": [ ] }, { "id": "79", "parent_id": "107", "sku": "BLU-2D71C660", "combination": [ { "option_id": "114", "option_value_id": "10" } ], "default_price": 34.95, "advanced_price": [ ] }, { "id": "80", "parent_id": "107", "sku": "ORA-446C93BB", "combination": [ { "option_id": "114", "option_value_id": "13" } ], "default_price": 34.95, "advanced_price": [ ] } ] } }
-
How to Work With Orders
The Order API methods allow you to manage orders in the store. In particular, you can do the following:
- Create - add orders
- Read - find and retrieve lists and specific info
- Update - update order data
Call the order.add method to add orders to the store. Do not forget to specify the necessary parameters.
public function apiAdd($params) { $params = array( 'customer_email' => '[email protected]', 'order_status' => 'Complete', 'bill_first_name' => 'Adam', 'bill_last_name' => 'Smith', 'bill_address_1' => 'Green str. 35', 'bill_city' => 'Chicago', 'bill_postcode' => '12345', 'bill_state' => 'IL', 'bill_country' => 'US', 'total_price' => '23.56', 'order_item_id_1' => 8, 'order_item_name_1' => 'Bag', 'order_item_model_1' => 'bag_01', 'order_item_price_1' => 89, 'order_item_quantity_1' => 3, ); return = $api->request('order.add', $params); }
If you want to update an order, call the order.list method and get the order id.
public function apiList($params) { $params = array( 'start' => 0, 'count' => 5, 'params' => 'id,customer,status' ); return $api->request('order.list', $params); }
Use the order id to update the comment and order status by calling the order.update method.
public function apiUpdate($params) { $params = array( 'order_id' => 11, 'order_status' => 'Pending', 'comment' => 'Order comment' ); return $api->request('order.update', $params);//returns the number of updated orders }
Tip: To count orders in the store, execute the order.count method.
For more API methods explore our documentation.
-
How to Work With Customers
The Customer API methods allow you to manage customers in the store. In particular, you can do the following:
- Create - add customers
- Read - find and retrieve lists and specific info
- Update - update customer details
- Delete - delete customers
Call the customer.add method to add customers to the store. Do not forget to specify the necessary parameters.
public function apiAdd($params) { $params = array( 'email' => '[email protected]', 'first_name' => 'John', 'last_name' => 'Smith', ); return $api->request('customer.add', $params); }
To update a customer, call the customer.list method and retrieve the customer id.
public function apiList($params) { $params = array( 'start' => 0, 'count' => 5 ); return $api->request('customer.list', $params); }
Use the customer id to call the customer.update method.
public function apiUpdate($params) { $params = array( 'id' => 11, 'first_name' => 'Jack', 'last_name' => 'Smith', ); return $api->request('customer.update', $params); }
For more API methods explore our documentation.
-
How to Work With Categories
The Category API methods allow you to manage categories in the store. In particular, you can do the following:
- Create - add categories
- Read - find and retrieve lists and specific info
- Update - update category data
- Delete - delete categories
Use the category.add method to add categories to the store. Do not forget to specify the necessary parameters.
public function apiAdd($params) { $params = array( 'name' => 'Shoes' ); return $api->request('category.add', $params); }
To update a category, call the category.list method and get the category id.
public function apiList($params) { $params = array( 'start' => 2, 'count' => 2, ); return $api->request('category.list', $params); }
Use the category id to execute the category.update method.
public function apiUpdate($params) { $params = array( 'id' => 20, 'avail' => 'false', 'meta_title' => 'meta title for category' ); return $api->request('category.update', $params); }
To assign a product to a category, call the product.list and category.list methods and get product id and category id.
Then use the ids to call the category.assign method.
public function apiAssign($params) { $params = array( 'product_id' => 69, 'category_id' => 20, ); return $api->request('category.assign', $params); }
For more API methods jump into our documentation.