Product API
Product API
Product API Π΄Π»Ρ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΡΠΎΠ²Π°ΡΠ°ΠΌΠΈ Π² ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π΅ ΠΏΡΠΎΠ΄Π°Π²ΡΠ° Ρ 23 ΠΌΠ΅ΡΠΎΠ΄Π°ΠΌΠΈ Π΄Π»Ρ ΠΊΠΎΠΌΠΏΠ»Π΅ΠΊΡΠ½ΠΎΠ³ΠΎ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΡΠΎΠ²Π°ΡΠ½ΡΠΌ Π°ΡΡΠΎΡΡΠΈΠΌΠ΅Π½ΡΠΎΠΌ.
ΠΠ±Π·ΠΎΡ
Product API ΠΎΠ±Π΅ΡΠΏΠ΅ΡΠΈΠ²Π°Π΅Ρ ΠΏΠΎΠ»Π½ΡΠΉ ΠΆΠΈΠ·Π½Π΅Π½Π½ΡΠΉ ΡΠΈΠΊΠ» ΡΠΎΠ²Π°ΡΠΎΠ² ΠΎΡ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π΄ΠΎ Π°ΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΈΡ. ΠΠΊΠ»ΡΡΠ°Π΅Ρ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ Π°ΡΡΠΈΠ±ΡΡΠ°ΠΌΠΈ, ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡΠΌΠΈ, SKU, ΡΠ΅Π½Π°ΠΌΠΈ, ΠΎΡΡΠ°ΡΠΊΠ°ΠΌΠΈ ΠΈ ΠΌΠ΅ΡΠ°ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠ΅ΠΉ.
ΠΡΠ½ΠΎΠ²Π½ΡΠ΅ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΠΈ:
- π¦ ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΈ Π²ΠΎΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΡΠΎΠ²Π°ΡΠΎΠ²
- π ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠΏΠΈΡΠΊΠΎΠ² ΡΠΎΠ²Π°ΡΠΎΠ² Ρ ΡΠΈΠ»ΡΡΡΠ°ΡΠΈΠ΅ΠΉ
- π§ ΠΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ Π°ΡΡΠΈΠ±ΡΡΠΎΠ² ΠΈ Ρ Π°ΡΠ°ΠΊΡΠ΅ΡΠΈΡΡΠΈΠΊ
- π€ ΠΠΌΠΏΠΎΡΡ ΡΠΎΠ²Π°ΡΠΎΠ² ΠΏΠΎ SKU
- πΌοΈ Π£ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡΠΌΠΈ
- π ΠΠΎΠ½ΠΈΡΠΎΡΠΈΠ½Π³ ΡΠ΅Π½ ΠΈ ΠΎΡΡΠ°ΡΠΊΠΎΠ²
- β ΠΠ½Π°Π»ΠΈΠ· ΡΠ΅ΠΉΡΠΈΠ½Π³ΠΎΠ² ΠΈ ΠΎΡΠ·ΡΠ²ΠΎΠ²
- π Π‘Π²ΡΠ·Π°Π½Π½ΡΠ΅ SKU ΠΈ ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄Π°ΡΠΈΠΈ
ΠΠΎΡΡΡΠΏΠ½ΡΠ΅ ΠΌΠ΅ΡΠΎΠ΄Ρ
Π£ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΆΠΈΠ·Π½Π΅Π½Π½ΡΠΌ ΡΠΈΠΊΠ»ΠΎΠΌ ΡΠΎΠ²Π°ΡΠΎΠ²
archiveProducts(request) - ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠΎΠ²Π°ΡΠΎΠ²
const result = await productApi.archiveProducts({
product_id: [123456, 789012, 345678]
});
unarchiveProducts(request) - Π Π°Π·Π°ΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠΎΠ²Π°ΡΠΎΠ²
const result = await productApi.unarchiveProducts({
product_id: [123456, 789012]
});
deleteProducts(request) - Π£Π΄Π°Π»Π΅Π½ΠΈΠ΅ ΡΠΎΠ²Π°ΡΠΎΠ²
const result = await productApi.deleteProducts({
offers: [
{ offer_id: "ITEM001" },
{ product_id: 123456 }
]
});
ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠΈ ΠΎ ΡΠΎΠ²Π°ΡΠ°Ρ
getProductsList(request) - Π‘ΠΏΠΈΡΠΎΠΊ ΡΠΎΠ²Π°ΡΠΎΠ²
const products = await productApi.getProductsList({
filter: {
offer_id: ["ITEM001", "ITEM002"],
visibility: "VISIBLE"
},
limit: 100
});
getProductInfo(request) - ΠΠΎΠ΄ΡΠΎΠ±Π½Π°Ρ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ ΡΠΎΠ²Π°ΡΠ΅
const info = await productApi.getProductInfo({
sku: 987654321,
offer_id: "ITEM001",
product_id: 123456
});
getProductInfoListV3(request) - Π Π°ΡΡΠΈΡΠ΅Π½Π½Π°Ρ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ V3
const infoList = await productApi.getProductInfoListV3({
filter: {
offer_id: ["ITEM001", "ITEM002"],
product_id: [123456, 789012]
},
limit: 50
});
ΠΠΌΠΏΠΎΡΡ ΠΈ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΡΠΎΠ²Π°ΡΠ°ΠΌΠΈ
importProductsBySku(request) - ΠΠΌΠΏΠΎΡΡ ΠΏΠΎ SKU
const importResult = await productApi.importProductsBySku({
items: [
{ sku: 987654321, offer_id: "ITEM001" },
{ sku: 123456789, offer_id: "ITEM002" }
]
});
importProducts(request) - ΠΠ±ΡΠΈΠΉ ΠΈΠΌΠΏΠΎΡΡ ΡΠΎΠ²Π°ΡΠΎΠ²
const result = await productApi.importProducts({
items: [
{
offer_id: "NEW_ITEM",
barcode: "1234567890123",
category_id: 15621,
name: "ΠΠΎΠ²ΡΠΉ ΡΠΎΠ²Π°Ρ",
price: "1500",
old_price: "2000",
currency_code: "RUB",
attributes: [
{
complex_id: 0,
id: 85,
values: [{ dictionary_value_id: 971082156 }]
}
]
}
]
});
getImportProductsInfo(request) - Π‘ΡΠ°ΡΡΡ ΠΈΠΌΠΏΠΎΡΡΠ°
const status = await productApi.getImportProductsInfo({
task_id: "task_123456"
});
Π£ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ Π°ΡΡΠΈΠ±ΡΡΠ°ΠΌΠΈ ΠΈ Ρ Π°ΡΠ°ΠΊΡΠ΅ΡΠΈΡΡΠΈΠΊΠ°ΠΌΠΈ
updateProductAttributes(request) - ΠΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ Π°ΡΡΠΈΠ±ΡΡΠΎΠ²
const result = await productApi.updateProductAttributes({
items: [
{
offer_id: "ITEM001",
attributes: [
{
complex_id: 0,
id: 85,
values: [{ dictionary_value_id: 971082156 }]
}
]
}
]
});
getProductAttributes(request) - ΠΡΡΠΈΠ±ΡΡΡ ΡΠΎΠ²Π°ΡΠ°
const attributes = await productApi.getProductAttributes({
filter: {
offer_id: ["ITEM001"],
visibility: "VISIBLE"
},
limit: 100
});
getCertificationTypes(request) - Π’ΠΈΠΏΡ ΡΠ΅ΡΡΠΈΡΠΈΠΊΠ°ΡΠΈΠΈ
const certTypes = await productApi.getCertificationTypes({
category_id: 15621,
type_id: 1
});
Π£ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡΠΌΠΈ
importProductPictures(request) - ΠΠΌΠΏΠΎΡΡ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ
const result = await productApi.importProductPictures({
product_id: 123456,
images: [
{
file_name: "product1.jpg",
url: "https://example.com/images/product1.jpg"
},
{
file_name: "product2.jpg",
url: "https://example.com/images/product2.jpg"
}
]
});
getProductPictures(request) - ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ
const pictures = await productApi.getProductPictures({
product_id: [123456, 789012]
});
Π¦Π΅Π½Ρ ΠΈ ΠΎΡΡΠ°ΡΠΊΠΈ
getProductStocks(request) - ΠΡΡΠ°ΡΠΊΠΈ ΡΠΎΠ²Π°ΡΠΎΠ²
const stocks = await productApi.getProductStocks({
filter: {
offer_id: ["ITEM001", "ITEM002"],
visibility: "VISIBLE"
},
limit: 100
});
getProductPrices(request) - Π¦Π΅Π½Ρ ΡΠΎΠ²Π°ΡΠΎΠ²
const prices = await productApi.getProductPrices({
filter: {
offer_id: ["ITEM001", "ITEM002"],
visibility: "VISIBLE"
},
limit: 100
});
Π Π΅ΠΉΡΠΈΠ½Π³ΠΈ ΠΈ Π°Π½Π°Π»ΠΈΡΠΈΠΊΠ°
getProductRating(request) - Π Π΅ΠΉΡΠΈΠ½Π³ ΡΠΎΠ²Π°ΡΠ°
const rating = await productApi.getProductRating({
products: [
{ offer_id: "ITEM001" },
{ sku: 987654321 }
]
});
getRelatedSKU(request) - Π‘Π²ΡΠ·Π°Π½Π½ΡΠ΅ SKU
const relatedSku = await productApi.getRelatedSKU({
sku: [987654321, 123456789]
});
ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½Π°Ρ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ
getDiscountedProductInfo(request) - ΠΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎΠ± ΡΡΠ΅Π½ΠΊΠ΅
const discountedInfo = await productApi.getDiscountedProductInfo({
discounted_skus: ["987654321", "123456789"]
});
getProductDescription(request) - ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΡΠΎΠ²Π°ΡΠ°
const description = await productApi.getProductDescription({
offer_id: "ITEM001",
product_id: 123456
});
getProductSubscription(request) - ΠΠΎΠ΄ΠΏΠΈΡΠΊΠΈ Π½Π° ΡΠΎΠ²Π°Ρ
const subscription = await productApi.getProductSubscription({
offer_id: "ITEM001",
sku: 987654321
});
getUploadQuota(request) - ΠΠ²ΠΎΡΠ° Π·Π°Π³ΡΡΠ·ΠΊΠΈ
const quota = await productApi.getUploadQuota();
updateOfferID(request) - ΠΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ Π°ΡΡΠΈΠΊΡΠ»Π°
const result = await productApi.updateOfferID({
update_offer_id: [
{
offer_id: "OLD_ITEM",
new_offer_id: "NEW_ITEM"
}
]
});
TypeScript ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΡ
// ΠΡΠ½ΠΎΠ²Π½ΡΠ΅ Π·Π°ΠΏΡΠΎΡΡ
interface ProductArchiveRequest {
product_id: number[];
}
interface ProductUnarchiveRequest {
product_id: number[];
}
interface ProductListRequest {
filter: {
offer_id?: string[];
product_id?: number[];
visibility?: "VISIBLE" | "INVISIBLE" | "EMPTY_STOCK" | "NOT_MODERATED" | "MODERATED" | "DISABLED" | "STATE_FAILED_MODERATION" | "READY_TO_SUPPLY" | "VALIDATION_STATE_PENDING" | "VALIDATION_STATE_FAIL" | "VALIDATION_STATE_SUCCESS" | "TO_SUPPLY" | "IN_SALE" | "REMOVED_FROM_SALE" | "BANNED" | "OVERPRICED" | "CRITICALLY_OVERPRICED" | "EMPTY_BARCODE" | "BARCODE_EXISTS" | "QUARANTINE" | "ARCHIVED" | "OVERPRICED_WITH_STOCK" | "PARTIAL_APPROVED" | "IMAGE_ABSENT" | "MODERATION_BLOCK";
};
sort?: "created_at" | "updated_at" | "price" | "name";
sort_dir?: "asc" | "desc";
limit: number;
last_id?: string;
}
interface ProductInfoRequest {
sku?: number;
offer_id?: string;
product_id?: number;
}
interface ProductImportBySKURequest {
items: Array<{
sku: number;
offer_id: string;
}>;
}
interface ProductImportRequest {
items: Array<{
offer_id: string;
barcode?: string;
category_id?: number;
name?: string;
price?: string;
old_price?: string;
currency_code?: string;
vat?: string;
height?: number;
depth?: number;
width?: number;
dimension_unit?: string;
weight?: number;
weight_unit?: string;
images?: Array<{
file_name: string;
default?: boolean;
}>;
attributes: Array<{
complex_id: number;
id: number;
values: Array<{
dictionary_value_id?: number;
value?: string;
}>;
}>;
}>;
}
interface ProductAttributesUpdateRequest {
items: Array<{
offer_id: string;
attributes: Array<{
complex_id: number;
id: number;
values: Array<{
dictionary_value_id?: number;
value?: string;
}>;
}>;
}>;
}
interface ProductPicturesImportRequest {
product_id: number;
images: Array<{
file_name: string;
url: string;
}>;
}
interface ProductOfferIDUpdateRequest {
update_offer_id: Array<{
offer_id: string;
new_offer_id: string;
}>;
}
interface ProductDeleteRequest {
offers: Array<{
offer_id?: string;
product_id?: number;
}>;
}
// ΠΡΠ²Π΅ΡΡ
interface ProductListResponse {
items: Array<{
product_id: number;
offer_id: string;
is_fbo_visible: boolean;
is_fbs_visible: boolean;
archived: boolean;
is_discounted: boolean;
}>;
total: number;
last_id: string;
}
interface ProductInfoResponse {
product_id: number;
offer_id: string;
barcode: string;
category_id: number;
name: string;
offer_ids: string[];
price: string;
old_price: string;
premium_price: string;
currency_code: string;
marketing_price: string;
min_ozon_price: string;
min_price: string;
sources: Array<{
is_enabled: boolean;
sku: number;
source: string;
}>;
stocks: Array<{
coming: number;
present: number;
reserved: number;
type: string;
}>;
errors: string[];
vat: string;
visible: boolean;
visibility_details: {
has_price: boolean;
has_stock: boolean;
active_product: boolean;
};
price_index: string;
images: Array<{
file_name: string;
default: boolean;
index: number;
}>;
image360: string[];
pdf_list: Array<{
index: number;
name: string;
src_url: string;
}>;
attributes: Array<{
attribute_id: number;
complex_id: number;
values: Array<{
dictionary_value_id: number;
value: string;
}>;
}>;
complex_attributes: any[];
color_image: string;
last_id: string;
weight: number;
dimensions: {
height: number;
length: number;
weight: number;
width: number;
};
description_category_id: number;
type_id: number;
is_kgt: boolean;
sku: number;
rating: string;
tax_rate: string;
discounted_stocks: {
coming: number;
present: number;
reserved: number;
};
is_prepayment: boolean;
is_prepayment_allowed: boolean;
images360: any[];
has_discounted_item: boolean;
barcodes: string[];
updated_at: string;
price_indexes: {
external_index_data: {
minimal_price: string;
minimal_price_currency: string;
price_index_value: number;
};
ozon_index_data: {
minimal_price: string;
minimal_price_currency: string;
price_index_value: number;
};
price_index: string;
self_marketplaces_index_data: {
minimal_price: string;
minimal_price_currency: string;
price_index_value: number;
};
};
status: {
state: string;
state_failed_moderation_reasons: string[];
moderate_status: string;
decline_reasons: string[];
validation_state: string;
state_name: string;
state_description: string;
is_failed_moderation: boolean;
is_created: boolean;
state_tooltip: string;
item_errors: Array<{
code: string;
field: string;
attribute_id: number;
attribute_name: string;
optional_description_elements: any;
state_description: string;
level: string;
}>;
state_updated_at: string;
};
state: string;
service_type: string;
fbo_sku: number;
fbs_sku: number;
currency_code2: string;
tags: any[];
loyalty_earn_rate: number;
created_at: string;
parent_id: number;
rich_content_json: string;
primary_image: string;
brand: string;
acquisition?: {
url: string;
text: string;
};
}
interface ProductImportResponse {
task_id: string;
}
interface ProductImportInfoResponse {
result: Array<{
offer_id: string;
product_id: number;
status: string;
errors: Array<{
code: string;
message: string;
}>;
}>;
}
interface ProductAttributesResponse {
items: Array<{
product_id: number;
offer_id: string;
attributes: Array<{
attribute_id: number;
complex_id: number;
values: Array<{
dictionary_value_id: number;
value: string;
}>;
}>;
}>;
total: number;
last_id: string;
}
interface ProductCertificationTypesResponse {
certificate_types: Array<{
id: number;
name: string;
is_required: boolean;
}>;
}
interface ProductPicturesImportResponse {
pictures: Array<{
product_id: number;
status: string;
url: string;
error: string;
}>;
}
interface ProductPicturesResponse {
items: Array<{
product_id: number;
images: Array<{
file_name: string;
default: boolean;
index: number;
}>;
}>;
}
interface ProductRatingResponse {
products: Array<{
offer_id: string;
sku: number;
rating: string;
groups: Array<{
key: string;
rating: string;
count: number;
}>;
}>;
}
interface RelatedSKUResponse {
items: Array<{
sku: number;
related_skus: number[];
}>;
}
interface DiscountedProductInfoResponse {
items: Array<{
discounted_sku: number;
original_sku: number;
condition: string;
defects: string[];
discount_percentage: number;
}>;
}
interface ProductDescriptionResponse {
description: string;
short_description: string;
rich_content_json: string;
}
interface ProductSubscriptionResponse {
subscription_info: {
subscription_plan: string;
is_auto_renewal: boolean;
next_payment_date: string;
status: string;
};
}
interface UploadQuotaResponse {
quota: {
used: number;
limit: number;
reset_date: string;
};
}
interface UpdateOfferIDResponse {
errors: Array<{
offer_id: string;
error: string;
}>;
}
interface DeleteProductsResponse {
status: Array<{
is_deleted: boolean;
offer_id: string;
product_id: number;
error: string;
}>;
}
ΠΡΠΈΠΌΠ΅ΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ Π½ΠΎΠ²ΠΎΠ³ΠΎ ΡΠΎΠ²Π°ΡΠ°
// 1. ΠΠΌΠΏΠΎΡΡ ΡΠΎΠ²Π°ΡΠ°
const importResult = await productApi.importProducts({
items: [
{
offer_id: "SMARTPHONE_001",
barcode: "1234567890123",
category_id: 15621,
name: "Π‘ΠΌΠ°ΡΡΡΠΎΠ½ Premium XY",
price: "45000",
old_price: "50000",
currency_code: "RUB",
vat: "0.20",
height: 150,
depth: 10,
width: 75,
dimension_unit: "mm",
weight: 200,
weight_unit: "g",
images: [
{ file_name: "smartphone_main.jpg", default: true },
{ file_name: "smartphone_side.jpg", default: false }
],
attributes: [
{
complex_id: 0,
id: 85, // ΠΡΠ΅Π½Π΄
values: [{ dictionary_value_id: 971082156 }]
},
{
complex_id: 0,
id: 5076, // Π¦Π²Π΅Ρ
values: [{ value: "Π§Π΅ΡΠ½ΡΠΉ" }]
}
]
}
]
});
// 2. ΠΡΠΎΠ²Π΅ΡΠΊΠ° ΡΡΠ°ΡΡΡΠ° ΠΈΠΌΠΏΠΎΡΡΠ°
const status = await productApi.getImportProductsInfo({
task_id: importResult.task_id
});
// 3. ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ
if (status.result[0].status === "imported") {
await productApi.importProductPictures({
product_id: status.result[0].product_id,
images: [
{
file_name: "smartphone_main.jpg",
url: "https://example.com/images/smartphone_main.jpg"
},
{
file_name: "smartphone_side.jpg",
url: "https://example.com/images/smartphone_side.jpg"
}
]
});
}
Π£ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΎΠΌ ΡΠΎΠ²Π°ΡΠΎΠ²
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠΏΠΈΡΠΊΠ° ΡΠΎΠ²Π°ΡΠΎΠ² Ρ ΡΠΈΠ»ΡΡΡΠ°ΡΠΈΠ΅ΠΉ
const productsList = await productApi.getProductsList({
filter: {
visibility: "VISIBLE",
offer_id: ["SMARTPHONE_001", "TABLET_002"]
},
sort: "updated_at",
sort_dir: "desc",
limit: 50
});
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎΠ΄ΡΠΎΠ±Π½ΠΎΠΉ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠΈ
const productInfo = await productApi.getProductInfo({
offer_id: "SMARTPHONE_001"
});
// ΠΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ Π°ΡΡΠΈΠ±ΡΡΠΎΠ²
await productApi.updateProductAttributes({
items: [
{
offer_id: "SMARTPHONE_001",
attributes: [
{
complex_id: 0,
id: 5076, // Π¦Π²Π΅Ρ
values: [{ value: "Π‘ΠΈΠ½ΠΈΠΉ" }]
},
{
complex_id: 0,
id: 8229, // ΠΠ°ΠΌΡΡΡ
values: [{ value: "128 ΠΠ" }]
}
]
}
]
});
ΠΠ½Π°Π»ΠΈΠ· ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ ΡΠΎΠ²Π°ΡΠΎΠ²
// Π Π΅ΠΉΡΠΈΠ½Π³ ΡΠΎΠ²Π°ΡΠΎΠ²
const ratings = await productApi.getProductRating({
products: [
{ offer_id: "SMARTPHONE_001" },
{ offer_id: "TABLET_002" },
{ sku: 987654321 }
]
});
ratings.products.forEach(product => {
console.log(`Π’ΠΎΠ²Π°Ρ ${product.offer_id}: ΡΠ΅ΠΉΡΠΈΠ½Π³ ${product.rating}`);
product.groups.forEach(group => {
console.log(` ${group.key}: ${group.rating} (${group.count} ΠΎΡΠ·ΡΠ²ΠΎΠ²)`);
});
});
// Π‘Π²ΡΠ·Π°Π½Π½ΡΠ΅ ΡΠΎΠ²Π°ΡΡ
const relatedSkus = await productApi.getRelatedSKU({
sku: [987654321, 123456789]
});
relatedSkus.items.forEach(item => {
console.log(`SKU ${item.sku} ΡΠ²ΡΠ·Π°Π½ Ρ: ${item.related_skus.join(", ")}`);
});
Π‘Π»ΠΎΠΆΠ½ΡΠ΅ ΡΡΠ΅Π½Π°ΡΠΈΠΈ
ProductCatalogManager - Π‘ΠΈΡΡΠ΅ΠΌΠ° ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΎΠΌ
class ProductCatalogManager {
constructor(private api: ProductApi) {}
async createProductFamily(familyData: ProductFamilyData): Promise<ProductFamily> {
const tasks: string[] = [];
// ΠΠΌΠΏΠΎΡΡ Π²ΡΠ΅Ρ
ΡΠΎΠ²Π°ΡΠΎΠ² ΡΠ΅ΠΌΠ΅ΠΉΡΡΠ²Π°
for (const product of familyData.products) {
const importResult = await this.api.importProducts({
items: [product]
});
tasks.push(importResult.task_id);
}
// ΠΠΆΠΈΠ΄Π°Π½ΠΈΠ΅ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΡ ΠΈΠΌΠΏΠΎΡΡΠ°
const results = await Promise.all(
tasks.map(taskId => this.waitForImportCompletion(taskId))
);
// ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ
await Promise.all(
results.map(result => this.addProductImages(result))
);
return {
family_id: familyData.family_id,
products: results,
created_at: new Date().toISOString()
};
}
private async waitForImportCompletion(taskId: string): Promise<ProductImportResult> {
let attempts = 0;
const maxAttempts = 30;
while (attempts < maxAttempts) {
const status = await this.api.getImportProductsInfo({ task_id: taskId });
if (status.result[0].status === "imported") {
return status.result[0];
}
if (status.result[0].status === "failed") {
throw new Error(`Import failed: ${status.result[0].errors.map(e => e.message).join(", ")}`);
}
await new Promise(resolve => setTimeout(resolve, 2000));
attempts++;
}
throw new Error("Import timeout");
}
private async addProductImages(result: ProductImportResult): Promise<void> {
if (result.images && result.images.length > 0) {
await this.api.importProductPictures({
product_id: result.product_id,
images: result.images
});
}
}
async optimizeCatalog(): Promise<CatalogOptimizationReport> {
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ Π²ΡΠ΅Ρ
ΡΠΎΠ²Π°ΡΠΎΠ²
const allProducts = await this.getAllProducts();
// ΠΠ½Π°Π»ΠΈΠ· ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ
const performanceAnalysis = await this.analyzePerformance(allProducts);
// Π Π΅ΠΊΠΎΠΌΠ΅Π½Π΄Π°ΡΠΈΠΈ ΠΏΠΎ ΠΎΠΏΡΠΈΠΌΠΈΠ·Π°ΡΠΈΠΈ
return {
total_products: allProducts.length,
performance_analysis: performanceAnalysis,
recommendations: this.generateRecommendations(performanceAnalysis)
};
}
private async getAllProducts(): Promise<ProductInfo[]> {
const products: ProductInfo[] = [];
let lastId = "";
do {
const response = await this.api.getProductsList({
filter: { visibility: "VISIBLE" },
limit: 1000,
last_id: lastId || undefined
});
for (const product of response.items) {
const detailedInfo = await this.api.getProductInfo({
product_id: product.product_id
});
products.push(detailedInfo);
}
lastId = response.last_id;
} while (lastId);
return products;
}
}
interface ProductFamilyData {
family_id: string;
products: ProductImportRequest['items'];
}
interface ProductFamily {
family_id: string;
products: ProductImportResult[];
created_at: string;
}
interface ProductImportResult {
offer_id: string;
product_id: number;
status: string;
images?: Array<{ file_name: string; url: string; }>;
}
interface CatalogOptimizationReport {
total_products: number;
performance_analysis: PerformanceAnalysis;
recommendations: string[];
}
interface PerformanceAnalysis {
low_rating_products: number;
missing_images: number;
incomplete_attributes: number;
archive_candidates: number;
}
AutomatedProductAnalyzer - Π‘ΠΈΡΡΠ΅ΠΌΠ° Π°Π½Π°Π»ΠΈΡΠΈΠΊΠΈ ΡΠΎΠ²Π°ΡΠΎΠ²
class AutomatedProductAnalyzer {
constructor(private api: ProductApi) {}
async generateInsightsReport(filters?: ProductListRequest['filter']): Promise<ProductInsightsReport> {
// ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠΎΠ²Π°ΡΠΎΠ² Π΄Π»Ρ Π°Π½Π°Π»ΠΈΠ·Π°
const products = await this.getProductsForAnalysis(filters);
// ΠΠ°ΡΠ°Π»Π»Π΅Π»ΡΠ½ΡΠΉ ΡΠ±ΠΎΡ Π΄Π°Π½Π½ΡΡ
const [ratings, stocks, prices, relatedData] = await Promise.all([
this.collectRatingsData(products),
this.collectStocksData(products),
this.collectPricesData(products),
this.collectRelatedSkuData(products)
]);
// ΠΠ½Π°Π»ΠΈΠ· ΡΡΠ΅Π½Π΄ΠΎΠ²
const trends = this.analyzeTrends(products, ratings, stocks, prices);
// ΠΠ΅Π½Π΅ΡΠ°ΡΠΈΡ ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄Π°ΡΠΈΠΉ
const recommendations = this.generateActionableRecommendations(
products, ratings, stocks, prices, relatedData
);
return {
analysis_date: new Date().toISOString(),
products_analyzed: products.length,
ratings_analysis: this.analyzeRatings(ratings),
inventory_analysis: this.analyzeInventory(stocks),
pricing_analysis: this.analyzePricing(prices),
trends_analysis: trends,
cross_selling_opportunities: this.findCrossSelling(relatedData),
actionable_recommendations: recommendations
};
}
private async collectRatingsData(products: ProductInfo[]): Promise<Map<string, ProductRating>> {
const ratingsMap = new Map<string, ProductRating>();
const chunkSize = 100;
for (let i = 0; i < products.length; i += chunkSize) {
const chunk = products.slice(i, i + chunkSize);
const ratingsResponse = await this.api.getProductRating({
products: chunk.map(p => ({ offer_id: p.offer_id }))
});
ratingsResponse.products.forEach(rating => {
ratingsMap.set(rating.offer_id, rating);
});
// Rate limiting
await new Promise(resolve => setTimeout(resolve, 100));
}
return ratingsMap;
}
private generateActionableRecommendations(
products: ProductInfo[],
ratings: Map<string, ProductRating>,
stocks: Map<string, ProductStock>,
prices: Map<string, ProductPrice>,
relatedData: Map<number, number[]>
): ActionableRecommendation[] {
const recommendations: ActionableRecommendation[] = [];
products.forEach(product => {
const rating = ratings.get(product.offer_id);
const stock = stocks.get(product.offer_id);
const price = prices.get(product.offer_id);
// ΠΠΈΠ·ΠΊΠΈΠΉ ΡΠ΅ΠΉΡΠΈΠ½Π³
if (rating && parseFloat(rating.rating) < 4.0) {
recommendations.push({
type: "quality_improvement",
priority: "high",
offer_id: product.offer_id,
action: "ΠΠ½Π°Π»ΠΈΠ· ΠΎΡΠ·ΡΠ²ΠΎΠ² ΠΈ ΡΠ»ΡΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠ°ΡΠ΅ΡΡΠ²Π° ΡΠΎΠ²Π°ΡΠ°",
expected_impact: "ΠΠΎΠ²ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ΅ΠΉΡΠΈΠ½Π³Π° Π½Π° 0.5+ Π±Π°Π»Π»ΠΎΠ²"
});
}
// ΠΠ·Π±ΡΡΠΎΡΠ½ΡΠ΅ ΠΎΡΡΠ°ΡΠΊΠΈ
if (stock && stock.present > 100 && stock.reserved < 10) {
recommendations.push({
type: "inventory_optimization",
priority: "medium",
offer_id: product.offer_id,
action: "ΠΡΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ Π°ΠΊΡΠΈΠΈ ΠΈΠ»ΠΈ ΡΠ½ΠΈΠΆΠ΅Π½ΠΈΠ΅ ΡΠ΅Π½Ρ Π΄Π»Ρ ΡΡΠΊΠΎΡΠ΅Π½ΠΈΡ ΠΎΠ±ΠΎΡΠ°ΡΠΈΠ²Π°Π΅ΠΌΠΎΡΡΠΈ",
expected_impact: "Π‘Π½ΠΈΠΆΠ΅Π½ΠΈΠ΅ ΠΎΡΡΠ°ΡΠΊΠΎΠ² Π½Π° 30-50%"
});
}
// Π¦Π΅Π½ΠΎΠ²Π°Ρ ΠΎΠΏΡΠΈΠΌΠΈΠ·Π°ΡΠΈΡ
if (price && rating && parseFloat(rating.rating) > 4.5 && parseFloat(price.price) < parseFloat(price.old_price || "0") * 0.8) {
recommendations.push({
type: "pricing_optimization",
priority: "high",
offer_id: product.offer_id,
action: "ΠΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ ΠΏΠΎΠ²ΡΡΠ΅Π½ΠΈΡ ΡΠ΅Π½Ρ Π½Π° 10-15% ΠΏΡΠΈ Π²ΡΡΠΎΠΊΠΎΠΌ ΡΠ΅ΠΉΡΠΈΠ½Π³Π΅",
expected_impact: "Π£Π²Π΅Π»ΠΈΡΠ΅Π½ΠΈΠ΅ ΠΌΠ°ΡΠΆΠΈΠ½Π°Π»ΡΠ½ΠΎΡΡΠΈ Π½Π° 10-15%"
});
}
});
return recommendations.sort((a, b) => {
const priorityOrder = { "high": 3, "medium": 2, "low": 1 };
return priorityOrder[b.priority] - priorityOrder[a.priority];
});
}
}
interface ProductInsightsReport {
analysis_date: string;
products_analyzed: number;
ratings_analysis: RatingsAnalysis;
inventory_analysis: InventoryAnalysis;
pricing_analysis: PricingAnalysis;
trends_analysis: TrendsAnalysis;
cross_selling_opportunities: CrossSellingOpportunity[];
actionable_recommendations: ActionableRecommendation[];
}
interface ActionableRecommendation {
type: "quality_improvement" | "inventory_optimization" | "pricing_optimization" | "marketing_boost" | "cross_selling";
priority: "high" | "medium" | "low";
offer_id: string;
action: string;
expected_impact: string;
}
ΠΠ±ΡΠ°Π±ΠΎΡΠΊΠ° ΠΎΡΠΈΠ±ΠΎΠΊ
try {
const result = await productApi.importProducts({
items: [productData]
});
// ΠΡΡΠ»Π΅ΠΆΠΈΠ²Π°Π½ΠΈΠ΅ ΡΡΠ°ΡΡΡΠ° ΠΈΠΌΠΏΠΎΡΡΠ°
const status = await productApi.getImportProductsInfo({
task_id: result.task_id
});
status.result.forEach(item => {
if (item.errors.length > 0) {
console.error(`ΠΡΠΈΠ±ΠΊΠΈ Π΄Π»Ρ ${item.offer_id}:`, item.errors);
}
});
} catch (error) {
if (error.response?.status === 400) {
console.error("ΠΡΠΈΠ±ΠΊΠ° Π²Π°Π»ΠΈΠ΄Π°ΡΠΈΠΈ Π΄Π°Π½Π½ΡΡ
:", error.response.data);
} else if (error.response?.status === 429) {
console.error("ΠΡΠ΅Π²ΡΡΠ΅Π½ Π»ΠΈΠΌΠΈΡ Π·Π°ΠΏΡΠΎΡΠΎΠ², ΠΏΠΎΠ²ΡΠΎΡ ΡΠ΅ΡΠ΅Π· 60 ΡΠ΅ΠΊΡΠ½Π΄");
await new Promise(resolve => setTimeout(resolve, 60000));
} else {
console.error("ΠΠ΅ΠΎΠΆΠΈΠ΄Π°Π½Π½Π°Ρ ΠΎΡΠΈΠ±ΠΊΠ°:", error.message);
}
}
ΠΡΡΡΠΈΠ΅ ΠΏΡΠ°ΠΊΡΠΈΠΊΠΈ
ΠΠΏΡΠΈΠΌΠΈΠ·Π°ΡΠΈΡ ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ
// ΠΠ°ΡΡΠΈΠ½Π³ Π·Π°ΠΏΡΠΎΡΠΎΠ² Π΄Π»Ρ Π±ΠΎΠ»ΡΡΠΈΡ
ΠΎΠ±ΡΠ΅ΠΌΠΎΠ² Π΄Π°Π½Π½ΡΡ
async function batchProductOperations<T>(
items: T[],
operation: (batch: T[]) => Promise<any>,
batchSize: number = 100
): Promise<any[]> {
const results = [];
for (let i = 0; i < items.length; i += batchSize) {
const batch = items.slice(i, i + batchSize);
const result = await operation(batch);
results.push(result);
// Rate limiting ΠΌΠ΅ΠΆΠ΄Ρ Π±Π°ΡΡΠ°ΠΌΠΈ
if (i + batchSize < items.length) {
await new Promise(resolve => setTimeout(resolve, 200));
}
}
return results;
}
Π£ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠ΅ ΠΆΠΈΠ·Π½Π΅Π½Π½ΡΠΌ ΡΠΈΠΊΠ»ΠΎΠΌ ΡΠΎΠ²Π°ΡΠ°
class ProductLifecycleManager {
async createProduct(productData: ProductCreationData): Promise<string> {
// 1. ΠΠΌΠΏΠΎΡΡ β 2. ΠΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ β 3. ΠΡΡΠΈΠ±ΡΡΡ β 4. ΠΠΊΡΠΈΠ²Π°ΡΠΈΡ
const importResult = await this.api.importProducts({
items: [productData.basicInfo]
});
await this.waitForImport(importResult.task_id);
await this.addImages(productData.images);
await this.setAttributes(productData.attributes);
return productData.basicInfo.offer_id;
}
async retireProduct(offerId: string): Promise<void> {
// 1. ΠΡΡ
ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ β 2. ΠΠ½Π°Π»ΠΈΠ· ΡΠ²ΡΠ·Π°Π½Π½ΡΡ
β 3. ΠΡΠΈΡΡΠΊΠ°
const productInfo = await this.api.getProductInfo({ offer_id: offerId });
await this.api.archiveProducts({
product_id: [productInfo.product_id]
});
// ΠΠ½Π°Π»ΠΈΠ· Π²Π»ΠΈΡΠ½ΠΈΡ Π½Π° ΡΠ²ΡΠ·Π°Π½Π½ΡΠ΅ ΡΠΎΠ²Π°ΡΡ
await this.analyzeRelatedImpact(productInfo.sku);
}
}
ΠΠ½ΡΠ΅Π³ΡΠ°ΡΠΈΠΎΠ½Π½ΡΠ΅ Π·Π°ΠΌΠ΅ΡΠΊΠΈ
- Rate Limiting: API ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ Π΄ΠΎ 1000 Π·Π°ΠΏΡΠΎΡΠΎΠ² Π² ΠΌΠΈΠ½ΡΡΡ
- Batch Processing: Π Π΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΠ΅ΡΡΡ ΠΎΠ±ΡΠ°Π±Π°ΡΡΠ²Π°ΡΡ ΡΠΎΠ²Π°ΡΡ ΠΏΠ°ΡΡΠΈΡΠΌΠΈ ΠΏΠΎ 100 ΡΡΡΠΊ
- ΠΡΠΈΠ½Ρ ΡΠΎΠ½Π½ΡΠΉ ΠΈΠΌΠΏΠΎΡΡ: ΠΠΌΠΏΠΎΡΡ ΡΠΎΠ²Π°ΡΠΎΠ² Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ Π°ΡΠΈΠ½Ρ ΡΠΎΠ½Π½ΠΎ, ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΠΎΡΡΠ»Π΅ΠΆΠΈΠ²Π°Π½ΠΈΠ΅ ΡΡΠ°ΡΡΡΠ°
- ΠΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ: ΠΠ°Π³ΡΡΠ·ΠΊΠ° ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ ΠΎΡΠ΄Π΅Π»ΡΠ½ΠΎ ΠΏΠΎΡΠ»Π΅ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΡΠΎΠ²Π°ΡΠ°
- ΠΡΡΠΈΠ±ΡΡΡ: ΠΡΠΈΡΠΈΡΠ΅ΡΠΊΠΈ Π²Π°ΠΆΠ½Ρ Π΄Π»Ρ ΠΌΠΎΠ΄Π΅ΡΠ°ΡΠΈΠΈ ΠΈ Π²ΠΈΠ΄ΠΈΠΌΠΎΡΡΠΈ ΡΠΎΠ²Π°ΡΠ°
- SKU ΡΠ²ΡΠ·ΠΈ: Π‘ΠΈΡΡΠ΅ΠΌΠ° Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅Ρ ΡΠ²ΡΠ·Π°Π½Π½ΡΠ΅ ΡΠΎΠ²Π°ΡΡ Π΄Π»Ρ ΠΊΡΠΎΡΡ-ΠΏΡΠΎΠ΄Π°ΠΆ
- ΠΠ²ΠΎΡΡ: Π‘ΡΡΠ΅ΡΡΠ²ΡΡΡ Π»ΠΈΠΌΠΈΡΡ Π½Π° Π·Π°Π³ΡΡΠ·ΠΊΡ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ ΠΈ ΡΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΡΠΎΠ²Π°ΡΠΎΠ²