If you want to minimize the number of API calls - because you have basic API access and pushing its bounderies, or because performance is critical - then you should consider to combine it in one call. The period for the API call stretches over both date ranges. Make sure you add 'date' as a segment field. Write code to handle the result, meaning, check the rows in the result, and its date field, then determine whether results should be included for the first or second period. Fields like cost, impressions, conversions etc. are just the sum of the days included in the respective periods. Fields like CPC and Click rate should be recalculated, it's not too hard to determine how to recalculate these.
Note this doesn't work for certain metrics, especially ImpressionShare and ClickShare. In that case you're stuck to two API calls. On Wednesday, November 30, 2022 at 9:56:33 AM UTC+1 delval...@gmail.com wrote: > Hi, I want to compare data between 2 date ranges. > > For example, I want to show in a table how many clicks certain campaigns > had in the last 30 days VS the previous 30 days (I'm interested also in > other date ranges, not just this example). > > What is the best way to do this using the API? > > I guess I could do that with 2 different API queries (for each date range) > and then trying to compare them with my code (Python in my case). > > But I want to show the data from both queries in the same table and I'm > facing some complexities (sometimes the queries don't show the same > campaigns -because of the query filters-, they are not in the same order > -unless I force it-, etc.). I guess I can deal with these complexities, but > maybe there is an easier and/or more reliable solution? > > Maybe a "native" solution in the API to compare data from different date > ranges? > > Thanks! > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/d4389ca5-38a1-4549-b02f-0a229ee501bcn%40googlegroups.com.