import requests
import json
API_URL = "https://api.insplay.eu"
API_METHOD = "products"
API_ENDPOINT = "{}/{}".format(API_URL, API_METHOD)
API_KEY5 = "Your API Key",
data = {
"api_key": "Your API Key",
"language": "et_EE",
}
headers = {"content-type": "application/json"}
payload = {"params": data}
response = requests.post(API_ENDPOINT, data=json.dumps(payload), headers=headers)
print(response.json())
<?php //PHP cURL extension is needed define('API_URL', 'https://api.insplay.eu/'); define('API_METHOD', 'products'); define('API_KEY', 'Your API key here'); define('API_LANGUAGE', 'et_EE'); function getCURL($url, $fields = array(), $headers = array()) { $ch = curl_init(); $options[CURLOPT_URL] = $url; $options[CURLOPT_POST] = count($fields); $options[CURLOPT_POSTFIELDS] = json_encode($fields); $options[CURLOPT_RETURNTRANSFER] = true; if (is_array($headers) and count($headers)) { foreach ($headers as $k => $v) { $options[$k] = $v; } } curl_setopt_array($ch, $options); $result = curl_exec($ch); curl_close($ch); return $result; } $url = API_URL.API_METHOD; $fields = array( 'params' => array( 'api_key' => API_KEY, 'language' => API_LANGUAGE ) ); $headers = array( CURLOPT_HTTPHEADER => array('Content-Type: application/json') ); $APIResult = json_decode(getCURL($url, $fields, $headers));
print_r($APIResult);
if (isset($API['result']) and isset($API['result']['data'])) { foreach ($API['result']['data'] as $product_id=>$val) { foreach ($val['additional_images'] as $k=>$v) { $fn = DATA_DIR.'product_'.$product_id.'_'.$k.'.jpg'; $fp = fopen($fn, 'wb'); fwrite($fp, base64_decode($val['image_base64'])); fclose($fp); echo '<a href="'.$fn.'" target="_blank">'.$fn.'</a><br />'; } $fn = DATA_DIR.'product_'.$product_id.'.jpg'; $fp = fopen($fn, 'wb'); fwrite($fp, base64_decode($val['main_image_base64'])); fclose($fp); echo '<a href="'.$fn.'" target="_blank">'.$fn.'</a><br />'; } } exit; ?>
curl --location --request POST 'https://api.insplay.eu/products'
--header 'Content-Type: application/json' --data-raw '{"params":{
"api_key": "Your API Key",
"language": "et_EE"
}}'
{
"api_key": "...",
"language": "et_EE",
"limit": 1,
"search_name": "TTS",
}
{
"id": null,
"jsonrpc": "2.0",
"result": {
"data": [
{
"create_date": "2019-08-26 08:18:06",
"description": false,
"id": 35,
"last_change_date": "2019-12-06 08:26:03",
"logo_base64": "/9j/4AAQSkZJRgABAQAAA...",
"name": "TTS"
}
],
"status": "success"
}
}
{
"api_key": "...",
"language": "et_EE",
"limit": 1,
}
{
"id": null,
"jsonrpc": "2.0",
"result": {
"data": [
{
"code": false,
"create_date": "2019-10-29 15:01:52",
"id": 2950,
"is_published": false,
"last_change_date": "2020-01-03 10:00:17",
"name": "Robootika ja elektroonika",
"parent_category_id": false,
"priority": 10000
}
],
"status": "success"
}
}
{
"api_key": "...",
"language": "et_EE",
"limit": 1,
"brand_ids": [35],
}
{
"id": null,
"jsonrpc": "2.0",
"result": {
"status": "success",
"data": [{
"width": 0.0,
"video": false,
"origin_country": "CN",
"last_change_date": "2020-01-03 10:00:10",
"age_from": 3.0,
"quantity_available": 1.0,
"age_to": 0.0,
"keywords": false,
"dimensions": false,
"height": 0.0,
"wholesale_price": 47.94,
"length": 0.0,
"recommended_retail_price": 69.9,
"name": "Õuepintslid (tekstuuripintslid)",
"description_sale": "Nende uuenduslike pintslitega saab luua suurele pinnale mitmekesiseid mustreid, tekstuure ja märke tõmbamise, vajutamise, kaapimise ja keerutamise teel. Neljast varrest ja eri otstest koosnev komplekt sobib kasutamiseks värvi, vee (lombid) ja liivaga. Valmistatud plastist. Komplektis 4 tk. L 22 x P 55 cm.\n ",
"create_date": "2019-07-04",
"category_ids": [],
"description_sale_long": false,
"additional_picture_urls": ["https://www.insplay.eu/web/image/product.image/43195/image_raw"]
"main_picture_url": "https://www.insplay.eu/web/image/product.product/35/image_raw"
"net_weight": 1.24,
"more_info_url": "www.tts-international.com",
"id": 4022,
"brand_id": [
35,
"TTS"
],
"tariff_no": "95030095",
"under_3_forbidden": true,
"product_code": "AR00797B",
"ean13": false,
"related_products_ids_m2m": [],
"old_nav_category": "DE2F3A4E-877B-4C14-93C1-FB9F957F2748"
}]
},
}
{
"api_key": "...",
"ids": [1],
"language": "et_EE"
}
{
"id": null,
"jsonrpc": "2.0",
"result": {
"data": [
{
"associated_category": false,
"code": false,
"create_date": "2019-10-09 08:52:25",
"id": 1,
"last_change_date": "2019-10-09 08:52:25",
"name": "Arduino",
"product_ids_m2m": []
}
],
"status": "success"
}
}
{
"api_key": "...",
"language": "et_EE",
"product_ids": [1],
}
{
"id": null,
"jsonrpc": "2.0",
"result": {
"status": "success",
"data": {
"1": {
"main_image_base64": "/9j/4AAQSkZJRgABAQAAA...",
"additional_images": []
}
},
},
}
{
"api_key": "...",
"language": "et_EE",
"product_ids": [1],
}
{
"id": null,
"jsonrpc": "2.0",
"result": {
"data": {
"1": []
},
"status": "success"
}
}
Response data:
{
"api_key": "...",
"language": "et_EE",
"limit": 1
}
{
"id": null,
"jsonrpc": "2.0",
"result": {
"data": [
{
"create_date": "2019-10-10 14:16:52",
"description": "Komplektis on ~40 osa ja konstruktori kokkupanek on lihtne tänu samm-sammult järgitavale juhendile",
"id": 1,
"last_change_date": "2019-10-10 14:18:11",
"name": "Komplektis on ~40 osa ja konstruktori kokkupanek on lihtne tänu samm-sammult järgitavale juhendile",
"priority": 1,
"product_ids_m2m": []
}
],
"status": "success"
}
}
29.10.2020
Added code example for image request in php.
28.08.2020
Added product_id, product_image_ids, main_picture_url and additional_picture_urls to product request.