google-ads-api icon indicating copy to clipboard operation
google-ads-api copied to clipboard

GenerateKeywordIdeaResponse responses directly results array

Open davidmrindus opened this issue 3 years ago • 4 comments

Hi guys,

I'm running this code:

(async () => {
    const client = new GoogleAdsApi({
        client_id: process.env.GOOGLE_ADS_CLIENT_ID,
        client_secret: process.env.GOOGLE_ADS_CLIENT_SECRET,
        developer_token: process.env.GOOGLE_ADS_DEVELOPER_TOKEN,
    });

    const customer = client.Customer({
        customer_id: process.env.GOOGLE_ADS_CLIENT_CUSTOMER_ID,
        refresh_token: process.env.GOOGLE_ADS_REFRESH_TOKEN,
    });


    const keywordSeed = new KeywordSeed({ keywords: ["garten"] });

    const generateKeywordIdeaResponse = await customer.keywordPlanIdeas.generateKeywordIdeas({
        customer_id: customer.credentials.customer_id,
        page_size: 10,
        keyword_seed: keywordSeed,
    }).catch((e) => console.error(e));

    console.log(JSON.stringify(generateKeywordIdeaResponse, null, 2));
    debugger;
})();

and response is:

[
  {
    "keyword_idea_metrics": { ... },
    "keyword_annotations": { ... },
    "text": "...", 
    "_text": "text"
  }
]

According to GenerateKeywordIdeaResponse, shouldn't has response a following structure?

{
 results: [],
 aggregate_metric_results: {},
 next_page_token: "",
 total_size: ""
}

Results seems correct, but I would need total_size value for internal purpose and it seems that response returns directly a content of results array. Am I missing some property here?

Thank you in advance!

davidmrindus avatar May 26 '22 09:05 davidmrindus

Hi @davidmrindus, you are correct. The response should be of the GenerateKeywordIdeaResponse type, however the response appears to be returning differently from the API. However, this library is simply a wrapper around the API. Google are responsible for the data you receive. Therefore I don't think we can be of any help here. It's either a bug in Google's code, or they haven't updated their docs. We don't parse the responses from service methods, so the data is returned exactly as it would have been sent by Google. Therefore I'd recommend directing your query to the official Google Ads API forum.

wcoots avatar Jun 17 '22 11:06 wcoots

Hi @WillCooter, Thank you for your response. I've checked response from Google's Java example https://github.com/googleads/google-ads-java/blob/0d48bd874019f2616306e56eee35d2a4a90a7b2c/google-ads-examples/src/main/java/com/google/ads/googleads/examples/planning/GenerateKeywordIdeas.java#L180

and is looks like response returns properties according to docs (see screenshot). Screenshot 2022-06-17 at 13 22 12

davidmrindus avatar Jun 17 '22 11:06 davidmrindus

Same problem. Any news? Is Google Docs deprecated?

lsw1164 avatar Sep 24 '23 18:09 lsw1164

@davidmrindus @lsw1164 did either of you figure it out? It's impossible to iterate over the results if you don't have the nextPageToken and the typing is wrong

amosbastian avatar Oct 11 '23 20:10 amosbastian