amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
609 stars 731 forks source link

[BUG] QuotaExceeded #1176

Closed NoraYan closed 1 year ago

NoraYan commented 3 years ago

we are trying to get orders, each order items, buyer info and address info via Api. There is no single api to get all the info , so we need to call different api by looping orders. Then we got error below: 429 { "errors": [ { "message": "You exceeded your quota for the requested resource.", "code": "QuotaExceeded" } How to solve this issue?

stefnats commented 3 years ago

@NoraYan i assume you don't get this error on the first call, but when you make frequent calls without long waiting times, right?

for that case, you should use the Reports API and request one of the Orders Report Type:

https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reports_2020-09-04.md#createreport https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reportType_string_array_values.md#order-reports

I hope that helps.

randyjiang commented 3 years ago

@NoraYan Hi, I'm creating an ERP for ecommerce sellers on Amazon, shopify, etc. Hope to get touch with you and seek opportunities for cooperation. My email: randyjiang@hotmail.com. WeChat: nz202605.

AmericanY commented 3 years ago

@stefnats am having the same issue actually. is there a chance to see a sample output of the reports mentioned ?

cwm0103 commented 3 years ago

"errors": [ { "message": "You exceeded your quota for the requested resource.", "code": "QuotaExceeded" } ] } I have the same problem, how to solve it

0573xieguojia commented 2 years ago

"errors": [ { "message": "You exceeded your quota for the requested resource.", "code": "QuotaExceeded" } ] } I have the same problem, how to solve it

SPAPI would re-set for the integrate services, error message cause you call the API too often.

rb3606 commented 2 years ago

Hello Anyone solved this ? I am stuck from last 2 days on same.

soniksarungale commented 2 years ago

If facing QuotaExceeded error, Use sleep() for couple of seconds between API calls.

H4ckerman666 commented 2 years ago

If facing QuotaExceeded error, Use sleep() for couple of seconds between API calls.

how many seconds? i need to know the specific quota, do you know it?

breaker05 commented 2 years ago

Has anyone solved this? Reading the docs it does not appear there is a set time limit and it says to be specific to your application. I solved this to a point by analyzing the rate limit header, x-amzn-RateLimit-Limit, however I am able to only make about 20 requests a minute before being throttled from doing bulk order updates.

Usage Plans and Rate Limits in the SP-API

YanivC commented 2 years ago

Ive been using amazons SP-API for about a year now and I can tell you for sure.. this was not a well architected solution. More than 70% of their responses when fatal provide zero help. Their limiters are WAY to limiting. And to top it off you cannot believe how many times I have received response in english that you can just tell..... this person does not speak english. The sandbox is NOT a real life scenario so there is no real way to do real testing. Horrible. Plus they even tell you try to rely on push notifications instead of polling but so many of their reports dont support it.... TRASH!

m-faseeh-qbatch commented 2 years ago

I need to make just 2-3 simultaneous requests to get reports and they are getting throttled every time. And there is no value being returned in the x-amzn-RateLimit-Limit header which could be used to manage the frequency of the requests. Surely excepted a lot better from this architecture. Disappointing! 😑

Landsailor commented 2 years ago

I need to make just 2-3 simultaneous requests to get reports and they are getting throttled every time....Disappointing! 😑

Absolutely. The 9000 Pound Gorilla that is Amazon's documentation and implementation of the only way we can access their store is disappointing, to say the least.

I gave up on basing reactions on useful throttling info being consistently returned, so I'm just going old-school.

At the beginning of my loop, I start with a .2 second pause before every SP-API call, then increment it by .5 or so seconds every time I get throttled. This is a script that runs every ten minutes or so. It may be unsophisticated, but it works.

luckdragon commented 2 years ago

I have 30 seconds of sleep between calls, and it still gives me that error, every 30 seconds

animer3009 commented 2 years ago

We are using Airbyte to pull report data. Airbyte has 60 sec wait time.

022-10-08 16:27:41 source > Backing off _send(...) for 0.0s (airbyte_cdk.sources.streams.http.exceptions.UserDefinedBackoffException: Request URL: XXX, Response Code: 429, Response Text: {
  "errors": [
    {
      "message": "You exceeded your quota for the requested resource.",
     "code": "QuotaExceeded"
    }
  ]
})
2022-10-08 16:27:41 source > Retrying. Sleeping for 60 seconds

After I first faced this error (for some reports), every request ends with the same response.

heysander commented 1 year ago

It really depends on the report type. We are working with the GET_EPR_ANNUAL_REPORTS and get this QuotaExceeded error. Opened a case at Amazon, but received very generic copy paste work from the docs back. They layed of many people and try to solve support with AI or people that are not really skillful. It's a shame so many people sell on Amazon, and we eCom developers need to work with them....

hellfire989 commented 1 year ago

Did anyone solve this issue?

jonathantorralba commented 1 year ago

Hola todos,

Amazon no lo pone nada facil y entre casos la ayuda por SellerCentral, deja mucho que desear. He realizo toda la integración de Amazon SP API a Doc. Espero que esto ayude a alguien que siga teniendo el problema:

he prodado tambien el parametro header: x-amzn-RateLimit-Limit, pero no funciona como tiempo de espera, sino aparece devuelve error, he decido usar el http_code.

Paso 1. Detectar la http_code de la respuesta: ` public function getOrderBuyerInfo($orderId) { $uri = "/orders/v0/orders/{$orderId}/buyerInfo";

    $queryParams = [];
    $queryParams['marketplaceId'] = 'A1RKKUPIHCS9HS';

    $response = $this->send($uri, $queryParams);

    if ($response['http_code'] == 429)
        return false;

    if ($response['http_code'] >= 300)
        throw new RuntimeException("RuntimeException ({$response['http_code']}): {$response['data']}");

    return $response['data']["payload"];

} `

Luego en el método o función que utilicéis la llamada haced esto: ` $orderBuyersInfo = []; $i = 1;

    foreach($orders as $order)
    {            
        $buyerInfo = [];

        do 
        {
            var_dump($i);

            $getOrderBuyerInfo = $ordersApi->getOrderBuyerInfo($order['AmazonOrderId']);
            if($getOrderBuyerInfo)
            {
                $buyerInfo['BuyerName'] = $this->getBuyerName($getOrderBuyerInfo);
                $orderBuyersInfo[$order['AmazonOrderId']] = $buyerInfo;
                unset($buyerInfo);  
            }
            else
                sleep(30);

            $i++;
        } while(isset($buyerInfo));

    }

`

tendréis que jugar con sleep(valor) a ver cual es el que mas se ajusta.

Lo siento por lo del idioma, google trasnlate y listo! ;)

GJ-JG commented 1 year ago

Hi all, For rate limits optimization, please also refer our blog post "Strategies to optimize rate limits for your application workloads" to better design the system and prevent the QuotaExceeded error.

Hope this helps. Best, Jiang

github-actions[bot] commented 1 year ago

This is a very old issue that is probably not getting as much attention as it deserves. We encourage you to check if this is still an issue after the latest release and if you find that this is still a problem, please feel free to open a new issue and make a reference to this one.

github-actions[bot] commented 1 year ago

closed for inactivity

jordantomax commented 7 months ago

@GJ-JG I have limited my request rates (both burst and total time) to half the rates specified by the API docs and I still receive this error. Is it possible that the docs are outdated?

ivanzonware commented 7 months ago

@jordantomax same issues here, using https://github.com/saleweaver/python-amazon-sp-api which is also endowed with the decorator throttle_retry(exception_classes=(), tries=5, delay=200, rate=1.3)

but after downloading a good amount of reports, the calls start to fail with the error {'code': 'QuotaExceeded', 'message': 'You exceeded your quota for the requested resource.', 'details': ''} and do not resume to normal operations unless waiting several hours.

I am using the Create Report operation https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#post-reports2021-06-30reports

which has the following rate limits Rate (requests per second) Burst
0.0167 15

I suspect issues at Amazon SP-API side

I tag @parvathm from SP-API support to have more attention on the issue and to provide a viable workaround

edit

POSSIBLE WORKAROUND

I noticed that the number of reports allowed before running into the QuotaExceeded is very close to the Create Report Burst. This lead me to believe that SP-API is changing the Rate and Burst dynamically without telling us due to overload on their side or similar issue. (example below) Screen Shot 2024-03-25 at 22 09 38 and later we get QuotaExceeded

Strategy: 1) save on the number of calls -> use maximum date range possible for your use case. In this way instead of making 12 calls for 30days report, you can make 1 call for 360days period. Make sure you can handle properly loading data (DB, memory ...) 2) introduce delay/sleep between one call and another, as a safety measure do not rely on Burst and always stay below the Rate for the given operation 3) once you hit QuotaExceeded wait for 12/24 hrs to allow the situation to reset

fret423 commented 3 months ago

Thanks for your thoughts @ivanzonware. While your first 2 suggestions completely make sense, waiting for 12/24 hrs in many scenarios just isn't possible. A whole lot of use-cases of the API require 10s to 100s of API calls/day which definitely can't be deferred by 12/24 hrs.

I hope your tagged @parvathm can lend some more insights to this.

pauljones0 commented 2 weeks ago

Commenting to keep the topic alive. I was planning on building a price tracking based on the SP-API, but now it seems that this is a terrible way to do so reliably