Example report python

86 views
Skip to first unread message

Raphael Benedeti

unread,
Sep 8, 2021, 2:23:38 PM9/8/21
to Google Ad Manager API Forum
from google.ads.googleads.client import GoogleAdsClient

credentials = {
"developer_token": "xxx",
"refresh_token": "xxxx",
"client_secret": "xxxx"
}

customer_id = 'xxx'
client = GoogleAdsClient.load_from_dict(credentials)
ga_service = client.get_service("GoogleAdsService")



query = """
SELECT
campaign.id,
campaign.name
FROM keyword_view
WHERE segments.date DURING LAST_30_DAYS"""

search_request = client.get_type("SearchGoogleAdsStreamRequest")
search_request.customer_id = customer_id
search_request.query = query
response = ga_service.search_stream(customer_id=customer_id, query=query)

# Issues a search request using streaming.


for batch in response:
for row in batch.results:
print(f"{row.campaign.id}, {row.campaign.name}"
)

Could someone help me understand why it doesn't return anything in my print?, 
I'm trying to find some example that more how to execute a query getting my report.

Ad Manager API Forum Advisor

unread,
Sep 9, 2021, 4:11:51 AM9/9/21
to benedeti...@gmail.com, google-doubleclick...@googlegroups.com

Hello Raphael,

Thank you for reaching out to us.

If you want to run a report using python with the Ad Manager API, you can use our client library for python on that. There are many samples on that library that you can use to get, create, update and many other query requests for your data in the Ad Manager API. Before you can start to use the Google Ad Manager API, you must be authorized through OAuth2, an open standard that allows users to grant permissions to third-party applications, so the application can interact with web services. You can check this authentication document for the steps needed.

Regards,

Google Logo
Princess Pamela Pineda
Ad Manager API Team
 

 



ref:_00D1U1174p._5004Q2NSV5f:ref

erika.w...@rdbrck.com

unread,
Jan 13, 2022, 6:14:09 PM1/13/22
to Google Ad Manager API Forum
Hello,

Isn't the API backing that python library being deprecated April 27, 2022? I've received a couple notices about it. Any up-to-date examples?

Thanks,

Erika

Ad Manager API Forum Advisor

unread,
Jan 13, 2022, 11:57:44 PM1/13/22
to erika.w...@rdbrck.com, google-doubleclick...@googlegroups.com

Hi Erika,

 

You can check our deprecation schedule for information on when a certain API version will deprecate or sunset. If you're getting notified that you're using a deprecated version of the API, I would highly suggest for you to update to the latest version to avoid the risk of losing access to the API as well as having more features and information as the previous ones. One of the ways to check the API version that an application is using is through an API request's SOAP logs.

 

That said, you can navigate through this link for you to download the latest version of the client library you're using. Lastly, you can always look for up-to-date examples of the Python client library in its respective GitHub repository.

 

Regards,

 

Google Logo
Yasmin Gabrielle Padua
Ad Manager API Team
 


ref:_00D1U1174p._5004Q2NSV5f:ref
Reply all
Reply to author
Forward
0 new messages