### Authentication and Product Retrieval Examples (PHP) Source: https://b2b.i-t-p.pro/download/docs/api/api Example PHP code demonstrating how to authenticate with the API, retrieve catalog tree, and get active products. ```APIDOC ## Authentication and Product Retrieval Examples (PHP) ### Description This section provides example PHP code using cURL to interact with the API. It covers authentication, fetching the product catalog tree, and retrieving a list of active products. ### Method POST (for authentication and product retrieval), GET (for catalog tree) ### Endpoint - Authentication: `https://%domain%/api/2` - Catalog Tree: `https://%domain%/download/catalog/json/catalog_tree.json` - Active Products: `https://%domain%/api/2` ### Request Example (PHP) ```php array( "method" => "login", "model" => "auth" , "module" => "quickfox" ), "data" => array( "login" => "SomeLogin", "password" => "SomePassword" ) ); $dataAuthString = json_encode($dataAuth); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $dataAuthString); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($dataAuthString) )); $result = curl_exec($ch); curl_close ($ch); $resAuth = json_decode($result); if (!($resAuth) || !($resAuth->success) || ($resAuth->success != 1)) { echo "Auth Error\n"; print_r($resAuth); die(); } echo "Auth success. session=" . $resAuth->session; $session = $resAuth->session; // --- Get Catalog Tree --- $ch = curl_init("https://%domain%/download/catalog/json/catalog_tree.json"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Cookie: session=' . $session ) ); $result = curl_exec($ch); curl_close ($ch); $resCatalogTree = json_decode($result); print_r($resCatalogTree); // --- Get Active Products --- $ch = curl_init("https://%domain%/api/2"); $dataProducts = array("request" => array( "method" => "get_active_products", "model" => "client_api", "module" => "platform" ), "session" => $session ); $dataProductsString = json_encode($dataProducts); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $dataProductsString); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Length: ' . strlen($dataProductsString) )); $result = curl_exec($ch); curl_close ($ch); $resProducts = json_decode($result); print_r($resProducts); ?> ``` ### SSL Certificate Handling For cURL requests, ensure a valid SSL certificate is installed or disable verification: ```php curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); ``` ``` -------------------------------- ### GET /api/2 - Get Active Products by Multiple SKUs Source: https://b2b.i-t-p.pro/download/docs/api/api Retrieves pricing and stock information for a list of products specified by their SKUs. ```APIDOC ## GET /api/2 - Get Active Products by Multiple SKUs ### Description Retrieves pricing and stock information for a list of products specified by their SKUs. ### Method GET ### Endpoint /api/2 ### Parameters #### Query Parameters - **request** (object) - Required - Specifies the method to call. - **method** (string) - Required - Must be "get_active_products". - **model** (string) - Required - Must be "client_api". - **module** (string) - Required - Must be "platform". - **filter** (array) - Optional - Filters to apply to the query. - **property** (string) - Required - Must be "sku". - **operator** (string) - Required - Must be "IN". - **value** (array) - Required - An array of product SKUs. - **session** (string) - Required - Your session token. ### Request Example ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "filter" : [ { "property" : "sku", "operator" : "IN", "value" : [1586891, 1586892, 1586893] } ], "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` ### Response #### Success Response (200) (Response structure is similar to the default 'Get Active Products' but contains information for the specified SKUs.) #### Response Example ```json { "data": { "products": [ { "price": 58.21, "qty": "***", "nearest_logistic_center_qty": "**", "sku": 1586891, "delivery_days": 0, "multiplicity": 1 } ], "total": 3 }, "message": "read", "success": true } ``` ``` -------------------------------- ### GET /api/2 - Get Active Product by SKU Source: https://b2b.i-t-p.pro/download/docs/api/api Retrieves pricing and stock information for a single, specific product identified by its SKU. ```APIDOC ## GET /api/2 - Get Active Product by SKU ### Description Retrieves pricing and stock information for a single, specific product identified by its SKU. ### Method GET ### Endpoint /api/2 ### Parameters #### Query Parameters - **request** (object) - Required - Specifies the method to call. - **method** (string) - Required - Must be "get_active_products". - **model** (string) - Required - Must be "client_api". - **module** (string) - Required - Must be "platform". - **filter** (array) - Optional - Filters to apply to the query. - **property** (string) - Required - Must be "sku". - **operator** (string) - Required - Must be "=". - **value** (integer) - Required - The SKU of the product. - **session** (string) - Required - Your session token. ### Request Example ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "filter" : [ { "property" : "sku", "operator" : "=", "value" : 1586891 } ], "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` ### Response #### Success Response (200) (Response structure is similar to the default 'Get Active Products' but contains information for only the specified SKU.) #### Response Example ```json { "data": { "products": [ { "price": 58.21, "qty": "***", "nearest_logistic_center_qty": "**", "sku": 1586891, "delivery_days": 0, "multiplicity": 1 } ], "total": 1 }, "message": "read", "success": true } ``` ``` -------------------------------- ### GET /api/2 - Get Active Products (All) Source: https://b2b.i-t-p.pro/download/docs/api/api Retrieves a list of all active products that are currently in stock. This is the default call and returns product information for the central warehouse (MSK). ```APIDOC ## GET /api/2 - Get Active Products (All) ### Description Retrieves a list of all active products that are currently in stock. This is the default call and returns product information for the central warehouse (MSK). ### Method GET ### Endpoint /api/2 ### Parameters #### Query Parameters - **request** (object) - Required - Specifies the method to call. - **method** (string) - Required - Must be "get_active_products". - **model** (string) - Required - Must be "client_api". - **module** (string) - Required - Must be "platform". - **session** (string) - Required - Your session token. ### Request Example ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` ### Response #### Success Response (200) - **data** (object) - Contains product information. - **products** (array) - List of products. - **price** (number) - Price in RUB. - **qty** (string) - Stock level at central warehouse (MSK). "*" - low, "**" - medium, "***" - high. - **nearest_logistic_center_qty** (string) - Stock level at nearest logistic center. "*" - low, "**" - medium, "***" - high. - **sku** (integer) - Product SKU. - **delivery_days** (integer) - Number of delivery days. 0 means same-day dispatch from main warehouse. - **multiplicity** (integer) - Product order multiplicity. - **total** (integer) - Total number of products found. - **message** (string) - "read". - **success** (boolean) - True if the request was successful. #### Response Example ```json { "data": { "products": [ { "price": 58.21, "qty": "***", "nearest_logistic_center_qty": "**", "sku": 1586891, "delivery_days" : 0, "multiplicity": 1 } ], "total": 119982 }, "message": "read", "success": true } ``` ``` -------------------------------- ### GET /api/2 - Get Active Products by Category Source: https://b2b.i-t-p.pro/download/docs/api/api Retrieves a list of active products belonging to a specified category, including products in its child categories. ```APIDOC ## GET /api/2 - Get Active Products by Category ### Description Retrieves a list of active products belonging to a specified category, including products in its child categories. ### Method GET ### Endpoint /api/2 ### Parameters #### Query Parameters - **request** (object) - Required - Specifies the method to call. - **method** (string) - Required - Must be "get_active_products". - **model** (string) - Required - Must be "client_api". - **module** (string) - Required - Must be "platform". - **filter** (array) - Optional - Filters to apply to the query. - **property** (string) - Required - Must be "category". - **operator** (string) - Required - Must be "=". - **value** (integer) - Required - The ID of the category. - **session** (string) - Required - Your session token. ### Request Example ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "filter" : [ { "property" : "category", "operator" : "=", "value" : 71 } ], "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` ### Response #### Success Response (200) (Response structure is similar to the default 'Get Active Products' but filtered by the specified category.) #### Response Example ```json { "data": { "products": [ { "price": 58.21, "qty": "***", "nearest_logistic_center_qty": "**", "sku": 1586891, "delivery_days": 0, "multiplicity": 1 } ], "total": 50 }, "message": "read", "success": true } ``` ``` -------------------------------- ### Order Creation Response Source: https://b2b.i-t-p.pro/download/docs/api/api This is an example of a successful response after creating an order. It includes details about the order such as its ID, status, creation date, partner comment, and the logistic center it was assigned to. ```json { "Full_Time": 50, "commandid": 260767355, "data": { "orders": [ { "partner_comment": " Комментарий ", "create_date": "2017-07-25T17:08:54", "logistic_center" : 1, "id": 123, "status": 1 } ], "total": 1 }, "event": "", "message": "create", "success": true } ``` -------------------------------- ### GET /api/2 - Get Delivery Cost for Products to Address Source: https://b2b.i-t-p.pro/download/docs/api/api Calculates the delivery cost for specified products to a given address. ```APIDOC ## GET /api/2 - Get Delivery Cost for Products to Address ### Description Calculates the delivery cost for specified products to a given address. ### Method GET ### Endpoint /api/2 ### Parameters #### Query Parameters - **request** (object) - Required - Specifies the method to call. - **method** (string) - Required - Must be "get_active_products". - **model** (string) - Required - Must be "client_api". - **module** (string) - Required - Must be "platform". - **data** (object) - Required - Contains address information. - **address** (integer) - Required - Identifier for the delivery address. - **filter** (array) - Optional - Filters to apply to the query. - **property** (string) - Required - Must be "sku". - **operator** (string) - Required - Must be "IN". - **value** (array) - Required - An array of product SKUs for which to calculate delivery costs. - **session** (string) - Required - Your session token. ### Request Example ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "data": { "address": 1 }, "filter" : [ { "property" : "sku", "operator" : "IN", "value" : [9701817, 9858545, 9858543] } ], "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` ### Response #### Success Response (200) - **Full_Time** (integer) - Total time taken for the request in milliseconds. - **data** (object) - Contains product information with delivery costs. - **products** (array) - List of products with delivery details. - **cost_delivery** (integer) - Cost of delivery to the specified address. - **delivery_days** (integer) - Number of delivery days. - **multiplicity** (integer) - Product order multiplicity. - **nearest_logistic_center_qty** (string) - Stock level at the nearest logistic center. - **price** (integer) - Product price. - **qty** (string) - Stock level at the central warehouse. - **sku** (integer) - Product SKU. - **total** (integer) - Total number of products found. - **success** (boolean) - True if the request was successful. - **time** (integer) - Time taken for the request in milliseconds. #### Response Example ```json { "Full_Time": 1814, "data": { "products": [ { "cost_delivery": 1, "delivery_days": 0, "multiplicity": 0, "nearest_logistic_center_qty": "0", "price": 1, "qty": "*", "sku": 9701817 }, { "cost_delivery": 2, "delivery_days": 0, "multiplicity": 0, "nearest_logistic_center_qty": "0", "price": 2, "qty": "*", "sku": 9858545 }, { "cost_delivery": 3, "delivery_days": 0, "multiplicity": 0, "nearest_logistic_center_qty": "0", "price": 3, "qty": "*", "sku": 9858543 } ], "total": 3 }, "success": true, "time": 1814 } ``` ``` -------------------------------- ### Authenticate and Get Product Prices from Web Server (1C) Source: https://b2b.i-t-p.pro/download/docs/api/api This client-side procedure initiates the process of retrieving product prices from a web server. It first obtains an authentication session if one is not already available, then calls the server-side function to fetch the product and price data. It includes basic error handling for authentication failures. ```1c //Процедура нажатия кнопки по вызову метода получения цен и товаров с веб-сервера // &НаКлиенте Процедура ОсновныеДействияФормыПолучитьЦеныПоТоварам(Команда) ИдентификаторСессии = Неопределено; Если ИдентификаторСессии = неопределено Тогда ClientLogin = «Логин»; ClientPasswod = «пароль»; ИдентификаторСессии = ПолучитьАутентификацию("%domain%", "/api/2", ClientLogin, ClientPasswod); КонецЕсли; Если ИдентификаторСессии = "" Тогда #Если Клиент Тогда Сообщить("В аутентификации https://%domain%/api/2 отказано"); #КонецЕсли возврат; КонецЕсли; ТоварыЦены = ПолучитьТоварыИЦены("%domain%", "/api/2", ИдентификаторСессии); КонецПроцедуры ``` -------------------------------- ### Get Catalog Data using PHP Source: https://b2b.i-t-p.pro/download/docs/api/api This PHP script demonstrates how to authenticate with the API using cURL, retrieve a catalog tree, and fetch active product information. It requires PHP 7.0 with cURL and JSON extensions. Ensure valid SSL certificates are configured or use the provided options to bypass verification. ```php array( "method" => "login", "model" => "auth" , "module" => "quickfox" ), "data" => array( "login" => "SomeLogin", "password" => "SomePassword" ) ); $dataAuthString = json_encode($dataAuth); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $dataAuthString); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($dataAuthString) )); $result = curl_exec($ch); curl_close ($ch); $resAuth = json_decode($result); if (($resAuth) && ($resAuth->success) && ($resAuth->success == 1)) echo "Auth success. session=" . $resAuth->session; else { echo "Auth Error\n"; print_r($resAuth); die(); } //Запоминаем сессию $session = $resAuth->session; //Получение дерева категорий $ch = curl_init("https://%domain%/download/catalog/json/catalog_tree.json"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Cookie: session=' . $session ) ); $result = curl_exec($ch); curl_close ($ch); $resCatalogTree = json_decode($result); print_r($resCatalogTree); //Список товаров получаем аналогичным образом //Получение всех товаров в наличии их цены $ch = curl_init("https://%domain%/api/2"); $dataAuth = array("request" => array( "method" => "get_active_products", "model" => "client_api", "module" => "platform" ), "session" => $session ); $dataAuthString = json_encode($dataAuth); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $dataAuthString); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Length: ' . strlen($dataAuthString) )); $result = curl_exec($ch); curl_close ($ch); $resProducts = json_decode($result); print_r($resProducts); ?> ``` -------------------------------- ### Get All Available Products (JSON) Source: https://b2b.i-t-p.pro/download/docs/api/api Retrieves a list of all currently available products. The response includes pricing, stock levels (central warehouse and nearest logistic center), SKU, delivery days, and multiplicity. Stock levels are represented by asterisks: '*' for low, '**' for medium, and '***' for high. ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` -------------------------------- ### Get Price and Stock for a Specific Product SKU (JSON) Source: https://b2b.i-t-p.pro/download/docs/api/api Fetches the price and stock availability for a single product identified by its SKU. This is a targeted query for specific item details. ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "filter" : [ { "property" : "sku", "operator" : "=", "value" : 1586891 } ], "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` -------------------------------- ### Get Price and Stock for Multiple Product SKUs (JSON) Source: https://b2b.i-t-p.pro/download/docs/api/api Retrieves pricing and stock information for a list of products specified by their SKUs using the 'IN' operator. This allows for batch queries of multiple items. ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "filter" : [ { "property" : "sku", "operator" : "IN", "value" : [1586891, 1586892,1586893] } ], "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` -------------------------------- ### Get Product Images by SKU (JSON) Source: https://b2b.i-t-p.pro/download/docs/api/api Retrieves images for a specific product SKU. Supports filtering by a single SKU or multiple SKUs (up to 100). Images for 18+ categories are without watermarks; others include a watermark. Rate limiting applies. ```json { "filter": [ { "operator": "=", "property": "sku", "value": 43950 // фильтр по артикулу товара } ], "request": { "method": "read_new", "model": "products_clients_images", "module": "platform" }, "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` ```json { "filter": [ { "operator": "IN", "property": "sku", "value": [43950, 88943, ...] // фильтр по артикулам товаров ( не более 100 шт) } ], "request": { "method": "read_new", "model": "products_clients_images", "module": "platform" }, "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` -------------------------------- ### GET /api/2 - Retrieve 18+ Product Characteristics Source: https://b2b.i-t-p.pro/download/docs/api/api Retrieves a list of all 18+ products along with their characteristics. Note: This method does not support retrieving characteristics for regular products. ```APIDOC ## GET /api/2 - Retrieve 18+ Product Characteristics ### Description Retrieves a list of all 18+ products along with their characteristics. Note: This method does not support retrieving characteristics for regular products. ### Method GET ### Endpoint /api/2 ### Parameters #### Request Body - **request** (object) - Required - The request details. - **method** (string) - Required - The method to use ('get_adult_products_characteristics'). - **model** (string) - Required - The model to query ('client_api'). - **module** (string) - Required - The module ('platform'). - **session** (string) - Required - The user session token. ### Request Example ```json { "request": { "method": "get_adult_products_characteristics", "model": "client_api", "module": "platform" }, "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` ### Response #### Success Response (200) - **Full_Time** (integer) - Processing time in milliseconds. - **commandid** (integer) - Unique command identifier. - **data** (object) - Contains characteristics for 18+ products. - **adult_products_characteristics** (array) - List of characteristics for 18+ products. - **characteristics** (array) - Array of characteristics for a product. - **name** (string) - The name of the characteristic (e.g., 'Описание', 'Цвет'). - **value** (string) - The value of the characteristic. - **sku** (integer) - Product SKU. - **total** (integer) - Total number of 18+ products found. - **event** (string) - Event identifier. - **message** (string) - Any messages related to the request. - **success** (boolean) - Indicates if the request was successful. #### Response Example ```json { "Full_Time": 20307, "commandid": 318125009, "data": { "adult_products_characteristics": [ { "characteristics": [ { "name": "Описание", "value": "..." }, { "name": "Страна производства", "value": "США, Китай" }, ... ], "sku": 10524309 }, ... ], "total": 15970 }, "event": "177", "message": "", "success": true } ``` ``` -------------------------------- ### GET /api/2 - Retrieve Product Images Source: https://b2b.i-t-p.pro/download/docs/api/api Fetches images for specified products. Images for 18+ category products are returned without watermarks, while others include a watermark. Supports filtering by single SKU or multiple SKUs (up to 100). ```APIDOC ## GET /api/2 - Retrieve Product Images ### Description Fetches images for specified products. Images for 18+ category products are returned without watermarks, while others include a watermark. Supports filtering by single SKU or multiple SKUs (up to 100). ### Method GET ### Endpoint /api/2 ### Parameters #### Request Body - **filter** (array) - Required - Filter criteria for products. - **operator** (string) - Required - The comparison operator (e.g., '=', 'IN'). - **property** (string) - Required - The property to filter on (e.g., 'sku'). - **value** (number|array) - Required - The value(s) to filter by. For 'IN' operator, this should be an array of SKUs (max 100). - **request** (object) - Required - The request details. - **method** (string) - Required - The method to use ('read_new'). - **model** (string) - Required - The model to query ('products_clients_images'). - **module** (string) - Required - The module ('platform'). - **session** (string) - Required - The user session token. ### Request Example **Single Product:** ```json { "filter": [ { "operator": "=", "property": "sku", "value": 43950 } ], "request": { "method": "read_new", "model": "products_clients_images", "module": "platform" }, "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` **Multiple Products:** ```json { "filter": [ { "operator": "IN", "property": "sku", "value": [43950, 88943, ...] } ], "request": { "method": "read_new", "model": "products_clients_images", "module": "platform" }, "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` ### Response #### Success Response (200) - **Full_Time** (integer) - Processing time in milliseconds. - **commandid** (integer) - Unique command identifier. - **data** (object) - Contains product image information. - **product_images** (array) - List of product images. - **id** (integer) - Image ID. - **sku** (integer) - Product SKU. - **url** (string) - Relative URL for the image. Full URL: `https:///` + `url` + `?size=`. - **deleted** (boolean) - Indicates if the image is deleted. - **priority** (integer) - Image priority. - **total** (integer) - Total number of images found. - **event** (string) - Event identifier. - **message** (string) - Any messages related to the request. - **success** (boolean) - Indicates if the request was successful. #### Response Example ```json { "Full_Time": 36, "commandid": 318125009, "data": { "product_images": [ { "id": 2217386, "sku": 43950, "url": "product_images/with_watermark/472/4335472.jpg", "deleted" : false, "priority" : 100 }, ... ], "total": 3 }, "event": "177", "message": "", "success": true } ``` **Image URL Parameters:** - `?size=medium` - `?size=original` - `?size=large" ``` -------------------------------- ### Get Delivery Cost and Availability for Products to an Address (JSON) Source: https://b2b.i-t-p.pro/download/docs/api/api Calculates the delivery cost and provides availability details for specified products intended for a particular address. This endpoint combines product filtering with delivery information. ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "data": { "address": 1 }, "filter" : [ { "property" : "sku", "operator" : "IN", "value" : [9701817, 9858545,9858543] } ], "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` -------------------------------- ### Download Product Catalog Data from B2B ITP Pro Download API in 1C Source: https://b2b.i-t-p.pro/download/docs/api/api This server-side function downloads the product catalog from the B2B ITP Pro Download API. It sends the session identifier in the HTTP request headers and saves the response to a temporary file. It's designed to handle GET requests for catalog data. Error handling is included, returning a boolean to indicate success or failure. ```1C &НаСервере Функция ПолучитьКаталог(СерверAPI, РесурсAPI, session) Экспорт ЗапросJSON_Логин = Новый Структура; ЗапросJSON_Логин.Вставить("session", session); ЗаписьJSON = Новый ЗаписьJSON; ЗаписьJSON.ПроверятьСтруктуру = ложь; ПараметрыЗаписиJSON = Новый ПараметрыЗаписиJSON(,Символы.Таб); ЗаписьJSON.УстановитьСтроку(ПараметрыЗаписиJSON); ЗаписатьJSON(ЗаписьJSON, ЗапросJSON_Логин); СтрокаJSON = ЗаписьJSON.Закрыть(); Попытка НТТР = Новый HTTPСоединение(СерверAPI); ЗаголовокHTTP = Новый Соответствие(); ЗаголовокHTTP.Вставить("Cookie", "session="+СокрЛП(session)+""); HTTPЗапрос = Новый HTTPЗапрос(РесурсAPI, ЗаголовокHTTP); HTTPЗапрос.УстановитьТелоИзСтроки(СтрокаJSON, , ИспользованиеByteOrderMark.НеИспользовать); ИмяВыходногоФайла = ПолучитьИмяВременногоФайла("txt"); НТТР.Получить(HTTPЗапрос, ИмяВыходногоФайла); //GET HTTPЗапроc = неопределено; НТТР = неопределено; ОтветJSON = истина Исключение ОтветJSON = ложь ``` -------------------------------- ### Fetch Products and Prices from Web Server (1C) Source: https://b2b.i-t-p.pro/download/docs/api/api This server-side function retrieves product and price information from a web API. It constructs a JSON request, sends it via HTTP, and then parses the JSON response. The function handles potential errors during the HTTP request and JSON parsing, returning the data or undefined in case of failure. It utilizes temporary files for storing the response before parsing. ```1c //Процедура получения информации по товарам и ценам с веб-сервера (возвращаемый формат данных массив структур) // &НаСервере Функция ПолучитьТоварыИЦены(СерверAPI, РесурсAPI, session) ЗапросJSON_Логин = Новый Структура; ЗапросJSON_СтруктураПараметров = новый Структура; ЗапросJSON_СтруктураПараметров.Вставить("method","get_active_products"); ЗапросJSON_СтруктураПараметров.Вставить("model","client_api"); ЗапросJSON_СтруктураПараметров.Вставить("module","platform"); ЗапросJSON_Логин.Вставить("request" , ЗапросJSON_СтруктураПараметров); ЗапросJSON_Логин.Вставить("session", session); ЗаписьJSON = Новый ЗаписьJSON; ЗаписьJSON.ПроверятьСтруктуру = ложь; ПараметрыЗаписиJSON = Новый ПараметрыЗаписиJSON(,Символы.Таб); ЗаписьJSON.УстановитьСтроку(ПараметрыЗаписиJSON); ЗаписатьJSON(ЗаписьJSON, ЗапросJSON_Логин); СтрокаJSON = ЗаписьJSON.Закрыть(); Попытка НТТР = Новый HTTPСоединение(СерверAPI); ЗаголовокHTTP = Новый Соответствие(); ЗаголовокHTTP.Вставить("Cookie", "session="+СокрЛП(session)+""); HTTPЗапрос = Новый HTTPЗапрос(РесурсAPI, ЗаголовокHTTP); HTTPЗапрос.УстановитьТелоИзСтроки(СтрокаJSON, , ИспользованиеByteOrderMark.НеИспользовать); ИмяВыходногоФайла = ПолучитьИмяВременногоФайла("txt"); НТТР.ОтправитьДляОбработки(HTTPЗапрос, ИмяВыходногоФайла); HTTPЗапроc = неопределено; НТТР = неопределено; ОтветJSON = истина Исключение ОтветJSON = ложь КонецПопытки; Если НЕ ОтветJSON Тогда Возврат неопределено; КонецЕсли; ЧтениеJSON = Новый ЧтениеJSON; ЧтениеJSON.ОткрытьФайл(ИмяВыходногоФайла); Попытка МассивРезультат = ПрочитатьJSON(ЧтениеJSON); ЧтениеJSON.Закрыть(); УдалитьФайлы(ИмяВыходногоФайла); Исключение СтрокаJSON = ЧтениеJSON.Закрыть(); #Если Клиент Тогда Сообщить("Ошибка получения в файле JSON: "+ИмяВыходногоФайла + " " + ОписаниеОшибки()); #КонецЕсли КонецПопытки; Если МассивРезультат = неопределено Тогда Возврат неопределено; КонецЕсли; Возврат МассивРезультат; КонецФункции ``` -------------------------------- ### GET /api/2 - Get Active Products (Nearest Logistic Center Only) Source: https://b2b.i-t-p.pro/download/docs/api/api Retrieves a list of active products with stock and pricing information exclusively from the nearest logistic center, excluding the central warehouse (MSK). ```APIDOC ## GET /api/2 - Get Active Products (Nearest Logistic Center Only) ### Description Retrieves a list of active products with stock and pricing information exclusively from the nearest logistic center, excluding the central warehouse (MSK). ### Method GET ### Endpoint /api/2 ### Parameters #### Query Parameters - **request** (object) - Required - Specifies the method to call. - **method** (string) - Required - Must be "get_active_products". - **model** (string) - Required - Must be "client_api". - **module** (string) - Required - Must be "platform". - **filter** (array) - Optional - Filters to apply to the query. - **property** (string) - Required - Must be "nearest_logistic_center_only". - **session** (string) - Required - Your session token. ### Request Example ```json { "request": { "method": "get_active_products", "model": "client_api", "module": "platform" }, "filter" : [ { "property" : "nearest_logistic_center_only" } ], "session": "F123123123AAD8776E1B20E87ED26BDD9DFFFFFFFAAAAEEEEE" } ``` ### Response #### Success Response (200) (Response structure is similar to the default 'Get Active Products' but reflects data only from the nearest logistic center.) #### Response Example ```json { "data": { "products": [ { "price": 58.21, "qty": "***", "nearest_logistic_center_qty": "**", "sku": 1586891, "delivery_days": 0, "multiplicity": 1 } ], "total": 100 }, "message": "read", "success": true } ``` ``` -------------------------------- ### GET /api/2 - Retrieve Addresses Source: https://b2b.i-t-p.pro/download/docs/api/api Fetches a list of available addresses. ```APIDOC ## GET /api/2 - Retrieve Addresses ### Description Fetches a list of available addresses. ### Method GET ### Endpoint /api/2 ### Parameters #### Request Body - **request** (object) - Required - The request details. - **module** (string) - Required - The module ('platform'). - **model** (string) - Required - The model to query ('client_api'). - **method** (string) - Required - The method to use ('get_addresses'). - **session** (string) - Required - The user session token. ### Request Example ```json { "request": { "module": "platform", "model": "client_api", "method": "get_addresses" }, "session": "123" } ``` ### Response #### Success Response (200) - **Full_Time** (integer) - Processing time in milliseconds. - **data** (object) - Contains address information. - **addresses** (array) - List of available addresses. - **address** (string) - The address string. - **id** (integer) - The ID of the address. - **total** (integer) - Total number of addresses found. - **success** (boolean) - Indicates if the request was successful. #### Response Example ```json { "Full_Time": 21, "data": { "addresses": [ { "address": "адрес1", "id": 1 }, { "address": "адрес2", "id": 2 }, { "address": "адрес3", "id": 3 } ], "total": 3 }, "success": true } ``` ```