Perform authentication & query campaigns data using curl (Google Ads REST API)

52 views
Skip to first unread message

Nick Arman

unread,
Jun 3, 2019, 6:34:14 AM6/3/19
to AdWords API and Google Ads API Forum
I want to get a list of all campaigns under an account along with some metrics such as cost, impressions, clicks for each campaign during a certain time period. I have managed to do this through the PHP client library BUT due to certain constraints, I am unable to deploy it to the production server. Therefore, I want to accomplish the same using the REST API..

1. I am trying to follow the instructions given here (https://developers.google.com/google-ads/api/docs/oauth/overview) to generate an access token. I have performed the steps inside the Google Cloud Console so I have access to the client id and client secret, but don't know where to go from there using the REST APIs. The instructions for the PHP client library are pretty clear, but I can't seem to find any documentation which describes how to perform OAuth2 authentication using the REST APIs.

2. After I manage to do the authentication, I will also need help with the API call to fetch campaign name & date as dimensions and cost, impressions, clicks as metrics for a given time period. Again, instructions to do this through the client library are pretty clear (and I already successfully followed them) but the REST API end-points and which service to use etc. are not super clear.

Would be grateful if someone can provide input (preferably code samples as I am not an expert) to the two problems described above. I have already gone through a bunch of documentation but that hasn't helped much.

Thanks.


Google Ads API Forum Advisor Prod

unread,
Jun 3, 2019, 3:23:16 PM6/3/19
to adwor...@googlegroups.com
Hello Nick,

Please find my response below on your concerns:
  1. For AdWords API(SOAP) and Google Ads API(REST API) you can use the same credentials. You don't have to create new credentials again. Although, if you want to create new credentials in the OAuth2 guide follow OAuth Playground to get the refresh token for the client Id and secret you got already. Then use the point 2 in that guide to configure the libraries.
  2. We also have the client libraries available in 5 different language. Follow the Readme file to install them. Also the basic code examples are available, for example here is the code to fetch campaign with metrics. In Google Ads API to fetch data we use GAQL(like SQL structure). Also, you can modify the campaign fields in that example query based on the available fields, segments and metrics fields available here for campaign resource.  
Please give it a try and let me know if you have any further questions.

Regards,
Sai Teja, Google Ads API Team

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