K
K
Kosstya2015-09-03 11:59:06
API
Kosstya, 2015-09-03 11:59:06

How can I access my AdWords balance via the API?

Good afternoon!
I want to write a script that will use a variable with the value of the current balance at the time the script is executed.
I did not find such a method in the AdWords API help.
Does Google generally provide the ability to get the balance on the balance through the API?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hell_hauptwerk, 2016-06-15
@hell_hauptwerk

And I'm also very interested...

V
Vladimir Krasnoselskikh, 2017-05-31
@karavaiker

I did it this way, but it doesn’t always work out the right budget, maybe the collective mind can figure it out?

def get_amount():
        def get_budget_for_client():
            service = config.adwords_client.GetService('BudgetOrderService', version='v201702')
            selector = {
                'fields': ['BudgetOrderName', 'SpendingLimit', 'TotalAdjustments'],

            }
            budgets = []

            page = service.get(selector)

            if 'entries' in page and page['entries']:
                for payer in page['entries']:
                    budgets.append(round(int(payer['spendingLimit']['microAmount']) / 1000000, 2))

            all_budgets = sum(budgets)
            return all_budgets

        def get_spend_for_client():

            report_downloader = config.adwords_client.GetReportDownloader(version='v201702')
            report_query = "SELECT Cost FROM ACCOUNT_PERFORMANCE_REPORT "

            report = report_downloader.DownloadReportAsStringWithAwql(report_query, 'CSV', skip_report_header=True,
                                                                      skip_column_header=False,
                                                                      skip_report_summary=True,
                                                                      client_customer_id=customer_id)
            file = io.StringIO(report)
            reader = csv.DictReader(file, delimiter=',')
            
            for row in reader:
                return round(float(row['Cost']) / 1000000, 2)

        all_moneys = get_budget_for_client()
        spend = get_spend_for_client()

        return round(all_moneys - spend)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question