jlevers / selling-partner-api

A PHP client library for Amazon's Selling Partner API
BSD 3-Clause "New" or "Revised" License
404 stars 198 forks source link

Look up sellerSku by fnSku? #765

Open risner opened 3 months ago

risner commented 3 months ago

Problem description:

Per my understanding of Amazon's SP-API documentation, I should be able to look up a inventory summary by fnSku.

Error:

% php fnsku.php
PHP Fatal error:  Uncaught Error: Call to undefined method SellingPartnerApi\Api\FbaInventoryV1Api::InventorySummary() in fnsku.php:36
Stack trace:
#0 {main}
  thrown in fnsku.php on line 36

Code

$apiInstance = new SellingPartnerApi\Api\FbaInventoryV1Api($config);
$included_data = "summaries";
$locale = "en_US";
$result = $apiInstance->InventorySummary($fnsku, $marketplace_ids, $included_data, $locale);

Seller Central SP API config page screenshot

image

I have no idea what this asked me to provide, even after spending 23 minutes searching and looking at other issues that they didn't know what to put and got cancelled due to inactivity. This is the closest to what I thought.


I can use the AP for most other things, I just can't figure out how to query by fnsku. So I'm building a local translation db to convert fnsku to sellersku.

misterakko commented 3 months ago

You are missing a step or two. SP-API is not monolithic, after you have iitialized the thing you must instantiate an API connector to the specific API you need. In your case, InventorySummary is part of Amazon Warehousing and Distribution API v2024-05-09 https://developer-docs.amazon.com/sp-api/docs/awd_2024-05-09-reference#inventorysummary

So you need this: $awdApi = $apiInstance->AmazonWarehousingAndDistributionV20240509(); And then you make your InventorySummary() request to $awdApi

risner commented 3 months ago

Thanks for the reply.

You are missing a step or two. SP-API is not monolithic, after you have iitialized the thing you must instantiate an API connector to the specific API you need. In your case, InventorySummary is part of Amazon Warehousing and Distribution API

I feel like I am not instantiating the right thing, but that is for the warehousing and distribution service. We don't use that, we just use FBA. So it was this call I was trying to make queries against: https://developer-docs.amazon.com/sp-api/docs/fbainventory-api-v1-reference#inventorysummary

misterakko commented 3 months ago

In that case you go for $fbaApi = $apiInstance->FBAInventoryV1(); and continue from there.

risner commented 3 months ago

In that case you go for $fbaApi = $apiInstance->FBAInventoryV1(); and continue from there.

Thanks.

The code I initially tried is in the first message of the ticket. I'm not seeing how it differs from your suggestion materially?

$apiInstance = new SellingPartnerApi\Api\FbaInventoryV1Api($config);
$included_data = "summaries";
$locale = "en_US";
$result = $apiInstance->InventorySummary($fnsku, $marketplace_ids, $included_data, $locale);

Of note, I have also tried all these:

$apiInstance = new SellersApi($config);

$fbaApi = $apiInstance->fbaInventoryV1();
and
$fbaApi = $apiInstance->FBAInventoryV1();
and
$fbaApi = new SellingPartnerApi\Api\FbaInventoryV1Api($config);

They all report:

PHP Fatal error: Uncaught Error: Call to undefined method SellingPartnerApi\Api\SellersV1Api::fbaInventoryV1()

I must me missing something terribly obvious, because all my other calls work fine to other api like the reports api and getInventorySummaries.