Retrieving data from multiple customers in one query for account budget

38 views
Skip to first unread message

Yao Da

unread,
Mar 27, 2024, 11:33:26 AM3/27/24
to Google Ads API and AdWords API Forum
Hi, 

In my current code we retrieve account budget per customer in a single query.
However because one mcc manager many customers, if we get account budget per customer, this will cause error with "code = ResourceExhausted desc = Resource has been exhausted (e.g. check quota)", so we want to retrieve account budget for multiple customers in one call. 
Is this possible?

Current example code:
public static function runExample(GoogleAdsClient $googleAdsClient, int $customerId)
{
    $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
    // Creates a query that retrieves keyword statistics.
    $query =
        
"SELECT account_budget.adjusted_spending_limit_micros, account_budget.amount_served_micros FROM account_budget";

    // Issues a search stream request.
    /** @var GoogleAdsServerStreamDecorator $stream */
    $stream = $googleAdsServiceClient->searchStream($customerId, $query);



In the example above we have to send a customerId for each customer and a request is made per customer. We would like to send an array of customer ids and make a query that requests this metrics in one call.

Thanks in advance!

Google Ads API Forum Advisor

unread,
Mar 27, 2024, 11:06:21 PM3/27/24
to adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

Kindly note that RESOURCE_EXHAUSTED error generally occurs when you are sending too many requests in a short period of time. The server throws this error once it detects that your request has exceeded the system frequency limit. I would recommend setting up short delays between requests or combining more operations in fewer requests. Also, kindly check this sample code for how to Handle a Rate Exceeded Error for more information.

Additionally, we also have daily API operation limits where requests that violate these limits are rejected with the RESOURCE_EXHAUSTED error. You may check out the API Limits and Quotas guide for more information. Kindly note that retrieving data for multiple customers in a single API call is not possible in the Google Ads API. You must provide the individual customer ID for each API request to fetch the data for all the accounts.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02s0HZZ:ref" (ADR-00228943)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages