As an example we're going to retrieve all your products for a specific shop. For this we're going to use PHP as the programming language.
Step 1
Please sign up and then log in to your account. Under "Settings → API settings" you can find your API Key, which is needed for every interaction with the API.
Step 2
To generate the API call we use cURL, a open source software that runs under a wide variety of OS'.
Ondango is all about shops, due this you should start with retrieving your shop ID's (or creating a new shop. On success, you will get the shop ID as answer). A simple PHP example could looks like this:
$api_key = "YOUR_API_KEY";
$api_url = "http://api.ondango.com/";
$api_function = "shops/ids/"; // See: http://apidocs.ondango.com/rest/shops/ids/get.php
$api_method = "GET";
$api_params = array (
"api_key" => $api_key
);
$curl = curl_init ();
curl_setopt_array ($curl, array (
CURLOPT_URL => $api_url . $api_function . "?" . http_build_query ($api_params),
CURLOPT_CUSTOMREQUEST => $api_method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true
));
$response = json_decode (curl_exec ($curl));
curl_close ($curl);
print_r ($response);
// Output:
stdClass Object (
[is_error] => 0
[status_code] => 200
[status_text] => OK
[data] => Array (
[0] => 10 // <-- Shop ID #1
[1] => 21 // <-- Shop ID #2
)
)
Step 3
Now we can retrieve all our products data, i.e. from our first shop:
$api_function = "products/all/"; // See: http://apidocs.ondango.com/rest/products/all/get.php
$api_method = "GET";
$api_params = array (
"api_key" => $api_key,
"shop_id" => $response->data[0] // First shop ID from Step 2
);
$curl = curl_init ();
curl_setopt_array ($curl, array (
CURLOPT_URL => $api_url . $api_function . "?" . http_build_query ($api_params),
CURLOPT_CUSTOMREQUEST => $api_method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true
));
$response = json_decode (curl_exec ($curl));
curl_close ($curl);
print_r ($response); // For the output see: http://apidocs.ondango.com/rest/products/all/get.php
Step 4
You should improve the code by encapsulating cURL into a function. We also strongly recommend you to use a SECRET KEY to sign your requests in order to increase the security. If you don't want to take care of that, you can just start using one of our SDK's - They are very straight forward.
