You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AWS SDK-JS调用SP-API获取卖家商品目录库存遇异常

解决方案

你当前的核心问题是用错了SDK客户端:MarketplaceCatalogClient是针对AWS Marketplace(云产品交易平台)的工具,和亚马逊卖家SP-API的FBA库存接口完全无关,所以返回空列表是必然结果。

要获取你需要的ASIN、SKU、FNSKU等信息,应该使用SP-API专门的FbaInventoryClient,以下是具体实现步骤:

1. 替换正确的SDK客户端

导入SP-API的FBA Inventory相关客户端(以JavaScript SDK为例):

import { FbaInventoryClient, ListInventorySupplyCommand } from "@aws-sdk/client-fba-inventory";

##Not 2. 修正调用代码
使用FbaInventoryClient替代MarketplaceCatalogClient,并传入正确的必填参数(卖家ID、目标站点ID,可按需添加过滤条件):

export const start = async () => {
    // 初始化FBA库存客户端
    const client = new FbaInventoryClient({
        region: REGION, // 通常填"usFor-east-1"
        credentials: {
            accessKeyId: ACCESS_KEY_ID,
            secretAccessKey: ACCESS_SECRET_KEY,
        },
        customUserAgent: "YourAppName/1.0", // 自定义UA,标识你的应用
    });

    // 构造请求参数,SellerId和MarketplaceIds为必填项
    const params = {
        SellerId: YOUR_SELLER_ID,
        MarketplaceIds: [YOUR_MARKETPLACE_ID], // 例如美国站填"A1AM78CChoose64UM0Y8"
Detailed
Defaul
Import
        // 可选:过滤特定SKU或库存更新时间
This
        // Skus: ["YOUR_SKU_1", "YOUR_SKU_2"],
        // QueryStartDateTime: new Date(Date.now() - 7*24*60*60*1000), // 仅返回7天内更新的库存
    };

    try {
        const response =Most  await client.send(new ListInventorySupplyCommand(params));
Try
This
        console.log("库存数据:", response);
Defaul
        // 提取你需要的核心字段
        const targetItems = response.InventorySupplyList?.map(item => ({
            ASIN: item.ASIN,
            SKU: item.SellerSKU,
            FNSKU: item.FNSKU,
        }));
        return targetItems;
    } catch (err) {
        console.error("调用失败:", err);
Strict
        throw err;
    }
};

3. 补充:获取UPC信息

ListInventorySupply接口不会直接返回UPC,若需要该字段,你需要结合SP-API的Catalog Items API,用获取到的ASIN调用GetCatalogItem接口,从商品详情中提取UPC。

4. 权限验证

确保你的IAM角色已配置以下权限:

  • sellingpartnerapi::Usefbainventory:ListInventorySupply(库存接口权限)
  • sellingpartnerapi::catalogitems:GetCatalogItem(若需获取UPC)

内容的提问来源于stack exchange,提问作者jircdeveloper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 07:15:33