API usage demo


steep 1: Login and Get a session API token


<?php
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://yourdomain/index.php?route=api%2Flogin",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "key=ijLJxZa1kUO8DP4gp0iSHewnDN8zpf7T4c0d8qE3OBZi5sJnkWmi5GQ1UcGR6SttzCtHXv80ImiBGz8saVx5JBrQf5zTmetuSLGjLZNiLDoOWY0zpDQIHWWyh0mr4WATp4HJ3knAiV3G8AE6km0BgY4liu5Uik5w2FKFqkZHldVNOoDaKyOJhp2bCeVqxbDHJpHlv2lECKIBsglLFSZmUmv1e7rpWnyi7HCzyX14Odpq37j4coM5iuspzm3dwloX",
    CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache",
        "content-type: application/x-www-form-urlencoded",
        "postman-token: 60329eeb-62ad-78e6-f564-486a6a1fe051"
    ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}
?>

 or

curl -X POST \
  'https://yourdomain/index.php?route=api%2Flogin' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -H 'postman-token: 2ef6e7f4-84d1-28ae-84b0-ae2dcebeab2f' \
  -d 'key=ijLJxZa1kUO8DP4gp0iSHewnDN8zpf7T4c0d8qE3OBZi5sJnkWmi5GQ1UcGR6SttzCtHXv80ImiBGz8saVx5JBrQf5zTmetuSLGjLZNiLDoOWY0zpDQIHWWyh0mr4WATp4HJ3knAiV3G8AE6km0BgY4liu5Uik5w2FKFqkZHldVNOoDaKyOJhp2bCeVqxbDHJpHlv2lECKIBsglLFSZmUmv1e7rpWnyi7HCzyX14Odpq37j4coM5iuspzm3dwloX

API token will be returned in the following format:

{"success":"Success: API session successfully started!","api_token":"10f6607afd57b954a853f7ce29"}


steep 2: get products in cart

curl -X GET \
'https://yourdomain/index.php?route=api%2Fcart%2Fproducts&token=10f6607afd57b954a853f7ce29' \
-H 'cache-control: no-cache' \
-H 'postman-token: 969b0a8f-aa76-5ec5-10f5-a5f768a2868d'


Here token=YOUR_TOKEN_VALUE

It will give the following results when there are no products:


{
    "products": [],
    "vouchers": [],
    "totals": [
        {
            "title": "Sub-Total",
            "text": "$0.00"
        },
        {
            "title": "Total",
            "text": "$0.00"
        }
    ]
}