Product Get Translate Data API 文档
接口信息
- 接口地址:
{your-site-url}/api/skill/product/get-product-translate-data - 基础 URL:
{your-site-url}需替换为你自己的独立站 URL 地址,如https://your-domain.com/apimanager666 - 请求方式:
POST - Content-Type:
application/json - 说明: 此接口用于获取商品需要进行多语言翻译的属性数据。获取翻译数据后,可对其进行翻译,再调用 商品-保存翻译后的商品数据 将翻译结果保存到商品中。两个 API 需组合使用。
认证
请求头中需要携带 skill-access-token:
| Header | 值 |
|---|---|
skill-access-token |
{your-skill-access-token} (请替换为你自己的 token) |
请求参数 (Body - JSON)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
product_id |
int | ✅ 必填 | 商品 ID |
force |
bool | 选填 | 是否强制翻译。true 强制翻译(即使已翻译过也会返回数据),false 非强制(已翻译过的语言不再返回) |
translate_lang_codes |
Array[string] | 选填 | 需要翻译的目标语言代码数组。不填写则获取后台多语言插件已开启的所有语种对应的商品数据;填写后仅返回指定语种的数据,起限定作用 |
支持的语言代码
| 代码 | 中文名称 | 英文名称 | Origin名称 |
|---|---|---|---|
cn |
简体中文 | Simplified Chinese | 简体中文 |
tw |
繁体中文 | Traditional Chinese | 繁體中文 |
en |
英语 | English | English |
de |
德语 | German | Deutsch |
fr |
法语 | French | Français |
it |
意大利语 | Italian | Italiano |
ja |
日语 | Japanese | 日本語 |
ko |
韩语 | Korean | 한국어 |
es |
西班牙语 | Spanish | Español |
pt |
葡萄牙语 | Portuguese | Português |
ru |
俄语 | Russian | Русский |
nl |
荷兰语 | Dutch | Nederlands |
ar |
阿拉伯语 | Arabic | العربية |
th |
泰语 | Thai | แบบไทย |
vi |
越南语 | Vietnamese | Tiếng Việt |
my |
缅甸语 | Burmese | မြန်မာ |
lo |
老挝语 | Lao language | ພາສາລາວ |
id |
印尼语 | Indonesian | Indonesian |
sv |
瑞典语 | Swedish | Svenska |
fi |
芬兰语 | Finnish | Suomalainen |
pl |
波兰语 | Polish | Polski |
ro |
罗马尼亚语 | Romanian | Română |
cs |
捷克语 | Czech | čeština |
el |
希腊语 | Greek | Ελληνικά |
hi |
印地语 | Hindi | हिंदी |
no |
挪威语 | Norwegian | norsk |
返回结果
code 为 200 表示调用成功;code 不为 200 表示调用失败。
成功响应
返回数据按语言代码分组,包含三部分:common_attrs(基本属性)、options(规格名称)、option_items(规格子项)。
{
"code": 200,
"data": {
"product_id": 4932,
"common_attrs": {
"cn": {
"feed_title": "google feed title",
"feed_description": "google feed description",
"title": "Cartoon Bear Printing Women's Cardigan Pajamas...",
"sub_title": "Cute bear print loungewear set...",
"body_html": "<p>Stay comfortable and stylish...</p>",
"meta_title": "Women's Cartoon Bear Cardigan Pajama Set...",
"meta_keywords": "women pajamas, bear print pajama...",
"meta_description": "Shop this cute women's cartoon bear pajama set..."
},
"ja": {
"feed_title": "google feed title",
"feed_description": "google feed description",
"title": "Cartoon Bear Printing Women's Cardigan Pajamas...",
"sub_title": "Cute bear print loungewear set...",
"body_html": "<p>Stay comfortable and stylish...</p>",
"meta_title": "Women's Cartoon Bear Cardigan Pajama Set...",
"meta_keywords": "women pajamas, bear print pajama...",
"meta_description": "Shop this cute women's cartoon bear pajama set..."
}
},
"options": {
"cn": {
"Color": "Color",
"Size": "Size"
},
"ja": {
"Color": "Color",
"Size": "Size"
}
},
"option_items": {
"cn": {
"grey": "grey",
"white": "white",
"L": "L",
"M": "M"
},
"ja": {
"grey": "grey",
"white": "white",
"L": "L",
"M": "M"
}
}
},
"message": "success"
}
返回字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
code |
Number | 状态码,200 表示成功 |
message |
String | 执行结果的文字描述 |
data.product_id |
int | 商品 ID |
data.common_attrs |
Object | 按语言代码分组的基本属性集合 |
data.options |
Object | 按语言代码分组的规格名称集合 |
data.option_items |
Object | 按语言代码分组的规格子项集合 |
common_attrs 子字段
每个语言代码下包含以下字段:
| 字段 | 类型 | 说明 |
|---|---|---|
feed_title |
string | Feed 自定义 title |
feed_description |
string | Feed 自定义 description |
title |
string | 商品标题 |
sub_title |
string | 商品副标题 |
body_html |
string | 商品描述(HTML) |
meta_title |
string | SEO 标题 |
meta_keywords |
string | SEO 关键字 |
meta_description |
string | SEO 描述 |
options 子字段
每个语言代码下,key 为规格名称,value 为该规格在当前语言下的显示名称。
option_items 子字段
每个语言代码下,key 为规格子项名称,value 为该子项在当前语言下的显示名称。
请求示例
cURL
curl --location --request POST '{your-site-url}/api/skill/product/get-product-translate-data' \
--header 'skill-access-token: {your-skill-access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"product_id": 4932,
"force": true,
"translate_lang_codes": ["cn", "ja"]
}'
非强制翻译示例
curl --location --request POST '{your-site-url}/api/skill/product/get-product-translate-data' \
--header 'skill-access-token: {your-skill-access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"product_id": 4932,
"force": false,
"translate_lang_codes": ["cn"]
}'
注意事项
- 系统必须启用多语言插件(language),否则此 API 无法使用
force=true时即使某语言已有翻译数据,仍会返回该语言对应的字段,供重新翻译force=false时跳过已翻译过的语言,只返回未翻译或为空的字段- 返回数据按语言代码三层分组:
common_attrs→options→option_items