Opteo / google-ads-node

Google Ads API client library for Node.js
https://opteo.com
67 stars 35 forks source link

keywordPlanIdeas.generateKeywordIdeas() is returning dumb fileds #88

Closed rohitnishad613 closed 2 years ago

rohitnishad613 commented 2 years ago

I am runing this code

const {
    GoogleAdsApi,
    services: { KeywordSeed },
} = require('google-ads-api'); // package v5.2.0 = Google Ads API to v7

(async () => {
    const client = new GoogleAdsApi({
        client_id: "107229fasdfasdf.apps.googleusercontent.com",
        client_secret: "GOCSPX-fasdfasdfasdfasdfa",
        developer_token: "fasdfadfasdfasdf",
    });
    const customer = client.Customer({
        customer_id: "1fasfasdfasdf9446",
        refresh_token: "1//0g-fasdfasdfaasdf-LfasdfasdfjbuMWel-fo",
    });

    const keywordSeed = new KeywordSeed({ keywords: ['content marketing'] });

    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));
})();

This console logs

[  
  {
    "keyword_idea_metrics": {
      "monthly_search_volumes": [
        {
          "month": "JANUARY",
          "year": "2021",
          "_year": "year",a
          "monthly_searches": "880",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "FEBRUARY",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1000",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "MARCH",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1000",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "APRIL",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1000",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "MAY",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1000",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "JUNE",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1600",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "JULY",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1600",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "AUGUST",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1900",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "SEPTEMBER",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "3600",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "OCTOBER",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "1600",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "NOVEMBER",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "880",
          "_monthly_searches": "monthly_searches"
        },
        {
          "month": "DECEMBER",
          "year": "2021",
          "_year": "year",
          "monthly_searches": "880",
          "_monthly_searches": "monthly_searches"
        }
      ],
      "competition": "LOW",
      "avg_monthly_searches": "1600",
      "_avg_monthly_searches": "avg_monthly_searches",
      "competition_index": "10",
      "_competition_index": "competition_index",
      "low_top_of_page_bid_micros": "207450549",
      "_low_top_of_page_bid_micros": "low_top_of_page_bid_micros",
      "high_top_of_page_bid_micros": "1022202884",
      "_high_top_of_page_bid_micros": "high_top_of_page_bid_micros"
    },
    "keyword_annotations": {
      "concepts": []
    },
    "text": "content marketing world",
    "_text": "text"
  }
]

But if you notice there are lots of dumb fileds, look at the last two properties.

"text": "content marketing world",
 "_text": "text"

Why i am warry about this? Because this behavior increases the size of data which increases the time to response from the server which leads us to slow APIs.