Selector selector = builder.fields("Id", "AdGroupId", "KeywordMatchType", "KeywordText").orderAscBy("AdGroupId").offset(offset).limit(PAGE_SIZE).in("CampaignId", campaignID.toString()).equals("CriteriaType", "KEYWORD").build();
Note that I've passed in a Long campaignID. Then you have an adGroupCriterionService get the selector, and then use AdGroupCriterionPage to go through all the AdGroupCriterion results. My question is whether there is an efficient way to retrieve the campaign name and ad group name for each keyword (I want to build a large json object that looks like {"keyword":"text" , "adGroupName" : "name" , "campaignName":"name" } , { keyword ... } etc.)
I current make one API call as shown above that gets all the keywords in a campaign. But then it seems that I have to make individual get requests for each keyword to get its adgroup name and its campaign name (this part is accomplished with an AdGroupService, that returns an AdGroup object when looking up an AdGroupId.) The problem is that doing the AdGroup lookup for each keyword (since the criterion result only lets you get an adgroupID, not an adGroupName), means that we'll be making an API call for each keyword. Obviously this is very expensive and it's causing us to hit our API usage limit (basic access).
Please let me know if I've missed something. Essentially I want to retrieve campaign name, ad group name, and keyword text for all keywords in a campaign. It seems relatively easy to get the IDs for some of these, but my understanding is that it'll take thousands of API calls to get the names from IDs if the client has thousands of keywords.