### Базовая структура тела ответа Source: https://mpstats.io/integrations/docs/body-parameters JSON-объект, возвращаемый API, содержащий метаданные запроса, общее количество записей и массив данных. ```json { "startRow": 0, "endRow": 100, "filterModel": {}, "sortModel": [], "total": 42, "data": [{ "...": "..." }] } ``` -------------------------------- ### POST /wb/get/category Source: https://mpstats.io/integrations/docs/description Retrieves category data for a specified path and date range. ```APIDOC ## POST /wb/get/category ### Description Retrieves category data based on the provided path and date range filters. ### Method POST ### Endpoint https://mpstats.io/api/wb/get/category ### Query Parameters - **d1** (string) - Required - Start date (YYYY-MM-DD) - **d2** (string) - Required - End date (YYYY-MM-DD) - **path** (string) - Required - Category path ### Request Body - **startRow** (integer) - Required - Starting row index - **endRow** (integer) - Required - Ending row index - **filterModel** (object) - Required - Filter criteria - **sortModel** (array) - Required - Sorting configuration ``` -------------------------------- ### Period Comparison Request Source: https://mpstats.io/integrations/docs/body-parameters Describes the request body structure for methods that support period comparison, including pagination, filtering, sorting, and date ranges. ```APIDOC ## Request Body for Period Comparison ### Description This request body is used for methods that require comparing two distinct time periods. ### Request Body - **startRow** (number) - Starting row index for pagination - **endRow** (number) - Ending row index for pagination - **filterModel** (object) - Filtering criteria - **sortModel** (array) - Sorting criteria - **d11** (string) - Start date of the first period - **d12** (string) - End date of the first period - **d21** (string) - Start date of the second period - **d22** (string) - End date of the second period ### Request Example { "startRow": 0, "endRow": 100, "filterModel": {}, "sortModel": [], "d11": "2023-10-18", "d12": "2023-10-19", "d21": "2023-10-19", "d22": "2023-10-20" } ### Response #### Success Response (200) - **data** (array) - List of result objects - **total** (number) - Total count of records - **pinnedBottom** (object) - Aggregated summary data for the periods #### Response Example { "data": [{ "...": "..." }, { "...": "..." }], "total": 12401, "pinnedBottom": { "sales_count_1": 125570, "sales_count_2": 119968, "revenue_1": 278206980, "revenue_2": 264340823, "sales_count_diff": -5602, "revenue_diff": -13866157 } } ``` -------------------------------- ### Запрос данных через Node.js Native Source: https://mpstats.io/integrations/docs/description Пример выполнения POST-запроса к API с использованием встроенного модуля https в Node.js. ```javascript var https = require('https'); var fs = require('fs'); var options = { 'method': 'POST', 'hostname': 'mpstats.io', 'path': '/api/wb/get/category?d1=2020-07-13&d2=2020-08-11&path=%D0%96%D0%B5%D0%BD%D1%89%D0%B8%D0%BD%D0%B0%D0%BC%2F%D0%9E%D0%B4%D0%B5%D0%B6%D0%B4%D0%B0', 'headers': { 'X-Mpstats-TOKEN': '5edfe8277ff2a5.941835169784f269a9244f13350db36eedb814d1', 'Content-Type': 'application/json' }, 'maxRedirects': 20 }; var req = https.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); res.on("error", function (error) { console.error(error); }); }); var postData = JSON.stringify({"startRow":0,"endRow":100,"filterModel":{},"sortModel":[{"colId":"revenue","sort":"desc"}]}); req.write(postData); req.end(); ``` -------------------------------- ### Request Body for Period Comparison Source: https://mpstats.io/integrations/docs/body-parameters Structure for a request body that includes pagination, filtering, sorting, and two date ranges for period comparison. ```json { "startRow": 0, "endRow": 100, "filterModel": {}, "sortModel": [], "d11": "2023-10-18", "d12": "2023-10-19", "d21": "2023-10-19", "d22": "2023-10-20" } ``` -------------------------------- ### Base Request Body Structure Source: https://mpstats.io/integrations/docs/body-parameters The standard structure for request bodies in methods supporting pagination, filtering, and sorting. ```APIDOC ## Base Request Body Structure ### Description Standard JSON structure for API requests requiring data pagination and filtering. ### Request Body - **startRow** (number) - Required - The starting row index for data retrieval. - **endRow** (number) - Required - The ending row index for data retrieval (max 500 records per request). - **filterModel** (object) - Optional - A set of filters applied to the data. - **sortModel** (array) - Optional - A model defining the sorting order. ### Request Example { "startRow": 1, "endRow": 100, "filterModel": {}, "sortModel": [] } ``` -------------------------------- ### Запрос данных через cURL Source: https://mpstats.io/integrations/docs/description Пример выполнения POST-запроса к API с использованием cURL. ```bash curl --location --request POST 'https://mpstats.io/api/wb/get/category?d1=2020-07-13&d2=2020-08-11&path=%D0%96%D0%B5%D0%BD%D1%89%D0%B8%D0%BD%D0%B0%D0%BC/%D0%9E%D0%B4%D0%B5%D0%B6%D0%B4%D0%B0' \ --header 'X-Mpstats-TOKEN: 5edfe8277ff2a5.941835169784f269a9244f13350db36eedb814d1' \ --header 'Content-Type: application/json' \ --data-raw '{"startRow":0,"endRow":100,"filterModel":{},"sortModel":[{"colId":"revenue","sort":"desc"}]}' ``` -------------------------------- ### Base Response Body Structure Source: https://mpstats.io/integrations/docs/body-parameters The standard structure for response bodies returned by API methods. ```APIDOC ## Base Response Body Structure ### Description Standard JSON structure for API responses, including metadata and the requested data array. ### Response - **startRow** (number) - The starting row index of the returned data. - **endRow** (number) - The ending row index of the returned data. - **filterModel** (object) - The filters applied to the request. - **sortModel** (array) - The sorting model applied to the request. - **total** (number) - The total number of rows available without pagination. - **data** (array) - The array containing the requested data records. ### Response Example { "startRow": 0, "endRow": 100, "filterModel": {}, "sortModel": [], "total": 42, "data": [{"...": "..."}] } ``` -------------------------------- ### Response Body for Period Comparison Source: https://mpstats.io/integrations/docs/body-parameters Structure for a response body containing data, total count, and aggregated metrics in the pinnedBottom object. ```json { "data": [{ "...": "..." }, { "...": "..." }], "total": 12401, "pinnedBottom": { "sales_count_1": 125570, "sales_count_2": 119968, "revenue_1": 278206980, "revenue_2": 264340823, "sales_count_diff": -5602, "revenue_diff": -13866157 } } ``` -------------------------------- ### Базовая структура тела запроса Source: https://mpstats.io/integrations/docs/body-parameters JSON-объект, используемый для передачи параметров пагинации, фильтрации и сортировки в теле запроса. ```json { "startRow": 1, "endRow": 100, "filterModel": {}, "sortModel": [] } ``` -------------------------------- ### Базовый URL API Source: https://mpstats.io/integrations/docs/description Обязательный базовый URL для всех запросов к API. ```text https://mpstats.io/api/ ``` -------------------------------- ### Структура пагинации Source: https://mpstats.io/integrations/docs/body-parameters Объект для определения диапазона строк при запросе данных. ```json { startRow: number, endRow: number, ... // остальные параметры } ``` -------------------------------- ### Комбинированная модель фильтрации Source: https://mpstats.io/integrations/docs/body-parameters Интерфейс и пример использования фильтра с двумя условиями через логический оператор. ```typescript interface ICombinedSimpleModel { filterType: string; operator: string; // "AND" или "OR" condition1: M; condition2: M; } ``` ```json { "balance": { "filterType": "number", "operator": "OR", "condition1": { "filterType": "number", "type": "equals", "filter": 18 }, "condition2": { "filterType": "number", "type": "equals", "filter": 19 } } } ``` -------------------------------- ### Модель сортировки данных Source: https://mpstats.io/integrations/docs/body-parameters Массив объектов для указания колонок и направления сортировки. ```json { "sortModel": [ { "colId": "balance", "sort": "asc" }, { "colId": "sales", "sort": "desc" } ] } ``` -------------------------------- ### Запрос данных через PHP cURL Source: https://mpstats.io/integrations/docs/description Пример выполнения POST-запроса к API с использованием PHP cURL. ```php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://mpstats.io/api/wb/get/category?d1=2020-07-13&d2=2020-08-11&path=%D0%96%D0%B5%D0%BD%D1%89%D0%B8%D0%BD%D0%B0%D0%BC/%D0%9E%D0%B4%D0%B5%D0%B6%D0%B4%D0%B0", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"startRow\":0,\"endRow\":100,\"filterModel\":{},\"sortModel\":[{\"colId\":\"revenue\",\"sort\":\"desc\"}]}", CURLOPT_HTTPHEADER => array( "X-Mpstats-TOKEN: 5edfe8277ff2a5.941835169784f269a9244f13350db36eedb814d1", "Content-Type: application/json" ), )); $response = curl_exec($curl); curl_close($curl); echo $response; ``` -------------------------------- ### Интерфейсы фильтров Source: https://mpstats.io/integrations/docs/body-parameters Определения типов данных для текстовых, числовых и фильтров по дате. ```typescript interface TextFilterModel { filterType: string; // всегда "text" type: string; // тип фильтра, например "equals" filter?: string; } ``` ```typescript interface NumberFilterModel { filterType: string; // всегда "number" type: string; // тип фильтра, например "equals" filter?: number; filterTo?: number; } ``` ```typescript interface DateFilterModel { filterType: string; // всегда "date" type: string; // тип фильтра, например "equals" filter?: string; filterTo?: string; } ``` -------------------------------- ### Примеры числовых фильтров Source: https://mpstats.io/integrations/docs/body-parameters Примеры использования числового фильтра для одного значения и диапазона. ```json { "balance": { "filterType": "number", "type": "lessThan", "filter": 35 } } ``` ```json { "balance": { "filterType": "number", "type": "inRange", "filter": 35, "filterTo": 40 } } ``` -------------------------------- ### Альтернативная передача токена Source: https://mpstats.io/integrations/docs/description Альтернативный способ передачи токена через параметр запроса. ```http &auth-token=5a2a5f0e538dd5.6691914852255446e23a9bcac46ee5255625f5d5 ``` -------------------------------- ### Передача токена авторизации Source: https://mpstats.io/integrations/docs/description Основной способ передачи токена через заголовок HTTP-запроса. ```http X-Mpstats-TOKEN: 5a2a5f0e538dd5.6691914852255446e23a9bcac46ee5255625f5d5 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.