Набор методов для получения данных об ассортименте S3.
Данный документ содержит методы работы с ассортиментом компании S3.
Взаимодействие с сервисом требует клиентской авторизации. Авторизация клиентов обеспечивается с применением протокола OAuth 2.0. Для получения токена необходимо отправить POST-запрос (x-www-form-urlencoded) на URL:
Далее, при обращении к методам сервиса полученный токен передается в заголовке запроса в следующем виде:
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY29wZSI6WyJvcmRlcjphbGw...
Пример запроса:
| Аргумент | Значение |
|---|---|
| grant_type | password |
| client_id | 1 |
| client_secret | dkslfj>Kuew429rfaldfndkfn |
| username | test@test.ru |
| password | XFkj235482 |
Ответ:
{ "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ…” "token_type": "Bearer", "expires_in": 31622400, }
Не более 5 запросов в секунду, 300 запросов в минуту и не более 10 000 запросов в сутки.
Параметры конкретного товара,
Фильтр по коду товара,
Параметры товаров из каталога,
Параметры товаров бренда,
default: 1,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/etim';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'product_id' => '1',
'code' => 'Б230022',
'catalog_id' => '1',
'brand_id' => '1',
'page' => '1',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"etim_items": [
{
"id": 58,
"product_id": 142,
"product_code": "",
"product_class_code": "",
"name": "Номин. напряжение",
"value": "1.5",
"feature_code": "EF000002",
"value_code": ""
},
{
"id": 58,
"product_id": 142,
"product_code": "",
"product_class_code": "",
"name": "Номин. напряжение",
"value": "1.5",
"feature_code": "EF000002",
"value_code": ""
}
],
"pagination": {
"current_page": 1,
"final_page": true
}
}
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/brands/1';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"brand": {
"id": null,
"name": "Voluptatum cum.",
"description": "Ut quis omnis.",
"logo": "https://www.s3.ru/640x480.png/0000dd"
}
}
default: 1,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/brands';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'page' => '1',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"brands": [
{
"id": null,
"name": "Ea excepturi.",
"description": "Eaque ullam.",
"logo": "https://www.s3.ru/640x480.png/009966"
},
{
"id": null,
"name": "Accusantium et.",
"description": "Ea sint.",
"logo": "https://www.s3.ru/640x480.png/00bb00"
}
],
"pagination": {
"current_page": 1,
"final_page": true
}
}
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/passports';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'product_id' => '1',
'code' => 'Б04148',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"info_items": [
{
"id": 60,
"product_id": null,
"product_code": "",
"type": "-",
"name": null,
"url": "https://www.s3.ru"
},
{
"id": 61,
"product_id": null,
"product_code": "",
"type": "-",
"name": null,
"url": "https://www.s3.ru"
}
]
}
Параметры конкретного товара,
Параметры товаров из каталога,
Параметры товаров бренда,
default: no,
default: 1,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/images';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'product_id' => '1',
'codes' => '"Б0059885,Б0042991" не более 20 кодов',
'channel' => 'site или ozon или wildberries',
'catalog_id' => '1',
'brand_id' => '1',
'original_image' => 'yes',
'page' => '1',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"items": [
{
"code": "Similique.",
"channels": []
}
]
}
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/categories/1';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"category": {
"id": null,
"name": "Corrupti totam.",
"parent_id": 91
}
}
default: 1,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/categories';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'parent_id' => '1',
'page' => '1',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"categories": [
{
"id": null,
"name": "Sapiente aut.",
"parent_id": 65
},
{
"id": null,
"name": "Ut eos numquam.",
"parent_id": 11
}
],
"pagination": {
"current_page": 1,
"final_page": true
}
}
Информация об остатках товаров сформировать ссылку на полный файл с остатками
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/inventories/full';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"uuid": "3b8fdd4c-5a7e-4419-b2eb-e1741772d71b",
}
Получить информацию о статусе формирования файла с остатками
Must be a valid UUID.
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/inventories/full/3b8fdd4c-5a7e-4419-b2eb-e1741772d71b';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'uuid' => '0fd674bc-df34-3331-af55-a3ade2eca31f',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"uuid": "3b8fdd4c-5a7e-4419-b2eb-e1741772d71b",
"status": "IN_PROGRESS",
"url": null
}
Если файл готов - скачать файл, в противном случае код ответа - 404
Must be a valid UUID.
$opts = [
"http" => [
"method" => "GET",
"header" => "Authorization: Bearer YOUR_ACCESS_TOKEN"
]
];
$context = stream_context_create($opts);
$url = 'https://api.s3.ru/api/v1/inventories/full_download/3b8fdd4c-5a7e-4419-b2eb-e1741772d71b';
$file = file_get_contents($url, false, $context);
<items>
<item>
<code>Б3400923</code>
<product_id>76</product_id>
<warehouse_id>3</warehouse_id>
<quantity>очень много</quantity>
</item>
<item>
<code>Б3400925</code>
<product_id>80</product_id>
<warehouse_id>3</warehouse_id>
<quantity>очень много</quantity>
</item>
...
</items>
Остатки товаров на определенном складе,
Остатки товаров из каталога,
Остатки товаров бренда,
Остатки конкретного товара,
Получить только строки с положительным/нулевым остатком,
default: 1,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/inventories';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'warehouse_id' => '1',
'catalog_id' => '1',
'brand_id' => '1',
'product_id' => '2',
'code' => 'voluptas',
'in_stock' => '1',
'page' => '1',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"inventories": [
{
"product_id": null,
"code": null,
"warehouse_id": null,
"quantity": "очень много"
},
{
"product_id": null,
"code": null,
"warehouse_id": null,
"quantity": "очень много"
}
],
"pagination": {
"current_page": 1,
"final_page": true
}
}
Параметры конкретного товара,
Фильтр по коду товара,
Параметры товаров из каталога,
Параметры товаров бренда,
Название параметра,
default: 1,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/properties';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'product_id' => '1',
'code' => 'Б230022',
'catalog_id' => '1',
'brand_id' => '1',
'name' => '"Страна производства"',
'page' => '1',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"properties": [
{
"id": null,
"product_id": 82,
"code": "",
"name": "Voluptas.",
"value": 43
},
{
"id": null,
"product_id": 47,
"code": "",
"name": "Delectus vitae.",
"value": 22
}
],
"pagination": {
"current_page": 1,
"final_page": true
}
}
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/certificates';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'product_id' => '1',
'code' => 'Б04148',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"certificates": [
{
"type": "Laborum.",
"url": "https://www.s3.ru/sert.pdf",
"link": "",
"reg_number": "81",
"number": "49"
},
{
"type": "Magnam ad.",
"url": "https://www.s3.ru/sert.pdf",
"link": "",
"reg_number": "97",
"number": "29"
}
]
}
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/warehouses/1';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"warehouse": {
"id": 79,
"name": "Ut quaerat ex."
}
}
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/warehouses';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"warehouses": [
{
"id": 80,
"name": "Fugiat eos et."
},
{
"id": 81,
"name": "Excepturi."
}
]
}
default: no,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/products/1';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'original_image' => 'yes',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"product": {
"id": null,
"url": "https://www.s3.ru/ru/item/",
"code": "Rerum eos sit.",
"code_wms": "Cum debitis.",
"etim_class_code": "",
"barcodes": [],
"name": "In vel in.",
"catalog_id": 47,
"tn_ved_code": "Doloremque.",
"brand_id": 97,
"okpd2": null,
"is_marked": null,
"description": "Eaque cumque.",
"consumer_price_type": "",
"images": [],
"extra_images": [],
"min_multiplicity": 2,
"weight": "0.150",
"vendor_code": "Ea incidunt.",
"multiplicity": null
}
}
default: no,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/products/by_code/Б234221';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'original_image' => 'yes',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"product": {
"id": null,
"url": "https://www.s3.ru/ru/item/",
"code": "Quae dolorum.",
"code_wms": "Veritatis in.",
"etim_class_code": "",
"barcodes": [],
"name": "Omnis labore.",
"catalog_id": 13,
"tn_ved_code": "Repellat ipsa.",
"brand_id": 64,
"okpd2": null,
"is_marked": null,
"description": "Voluptates.",
"consumer_price_type": "",
"images": [],
"extra_images": [],
"min_multiplicity": 2,
"weight": "0.150",
"vendor_code": "Qui voluptate.",
"multiplicity": null
}
}
default: no,
default: 1,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/products';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'warehouse_id' => '1',
'catalog_id' => '1',
'brand_id' => '1',
'original_image' => 'yes',
'page' => '1',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"products": [
{
"id": null,
"url": "https://www.s3.ru/ru/item/",
"code": "Molestiae.",
"code_wms": "Beatae nemo.",
"etim_class_code": "",
"barcodes": [],
"name": "Optio ipsam.",
"catalog_id": 61,
"tn_ved_code": "Voluptas.",
"brand_id": 25,
"okpd2": null,
"is_marked": null,
"description": "Ipsa ut porro.",
"consumer_price_type": "",
"images": [],
"extra_images": [],
"min_multiplicity": 1,
"weight": "0.150",
"vendor_code": "Nemo atque.",
"multiplicity": null
},
{
"id": null,
"url": "https://www.s3.ru/ru/item/",
"code": "Aut odio.",
"code_wms": "Aut mollitia.",
"etim_class_code": "",
"barcodes": [],
"name": "Perspiciatis.",
"catalog_id": 52,
"tn_ved_code": "Nostrum.",
"brand_id": 88,
"okpd2": null,
"is_marked": null,
"description": "Nam laboriosam.",
"consumer_price_type": "",
"images": [],
"extra_images": [],
"min_multiplicity": 2,
"weight": "0.150",
"vendor_code": "Quod quia.",
"multiplicity": null
}
],
"pagination": {
"current_page": 1,
"final_page": true
}
}
Информация о ценах товаров - сформировать ссылку на полный файл с ценами
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/product_prices/full';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"uuid": "3b8fdd4c-5a7e-4419-b2eb-e1741772d71b",
}
Получить информацию о статусе формирования файла с ценами
Must be a valid UUID.
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/product_prices/full/3b8fdd4c-5a7e-4419-b2eb-e1741772d71b';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'uuid' => '07255236-8ece-3983-8d91-cd47fdc75af4',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"uuid": "3b8fdd4c-5a7e-4419-b2eb-e1741772d71b",
"status": "IN_PROGRESS",
"url": null
}
Если файл готов - скачать файл, в противном случае код ответа - 404
Must be a valid UUID.
$opts = [
"http" => [
"method" => "GET",
"header" => "Authorization: Bearer YOUR_ACCESS_TOKEN"
]
];
$context = stream_context_create($opts);
$url = 'https://api.s3.ru/api/v1/product_prices/full_download/3b8fdd4c-5a7e-4419-b2eb-e1741772d71b';
$file = file_get_contents($url, false, $context);
<items>
<item>
<code>Б3400923</code>
<product_id>76</product_id>
<rrc_price>
<value>180.90</value>
<vat_sum>36.18</vat_sum>
<vat_rate>20</vat_rate>
</rrc_price>
<client_price>
<value>110.6</value>
<vat_sum>22.12</vat_sum>
<vat_rate>20</vat_rate>
</client_price>
<price_scale>
<price_scale_item>
<name>Мелкооптовая</name>
<value>104.28</value>
</price_scale_item>
<price_scale_item>
<name>Оптовая</name>
<value>102.72</value>
</price_scale_item>
</price_scale>
</item>
...
</items>
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/product_prices/1';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"price": {
"product_id": null,
"code": "Consequatur.",
"rrc_price": {
"value": "0.0",
"vat_sum": "0.00",
"vat_rate": 22
},
"client_price": null
}
}
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/product_prices/by_code/Б2403222';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"price": {
"product_id": null,
"code": "Iure.",
"rrc_price": {
"value": "0.0",
"vat_sum": "0.00",
"vat_rate": 22
},
"client_price": null
}
}
default: 1,
$client = new \GuzzleHttp\Client();
$url = 'https://api.s3.ru/api/v1/product_prices';
$response = $client->get(
$url,
[
'headers' => [
'Accept' => 'application/json',
],
'query' => [
'warehouse_id' => '1',
'catalog_id' => '1',
'brand_id' => '1',
'page' => '1',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
{
"prices": [
{
"product_id": null,
"code": "Accusamus.",
"rrc_price": {
"value": "0.0",
"vat_sum": "0.00",
"vat_rate": 22
},
"client_price": null
},
{
"product_id": null,
"code": "Dicta quos.",
"rrc_price": {
"value": "0.0",
"vat_sum": "0.00",
"vat_rate": 22
},
"client_price": null
}
],
"pagination": {
"current_page": 1,
"final_page": true
}
}