pat310 / google-trends-api

An API layer on top of google trends
https://www.npmjs.com/package/google-trends-api
MIT License
874 stars 174 forks source link

Multiple items in array for related topics throws an error #146

Open emettely opened 3 years ago

emettely commented 3 years ago

relatedTopics seems to only accet one parameter at a time. e.g. If I have a keyword "Apple", this would work. Also this ["Apple"] would work too. However, if I have multiple keywords like so: `["Apple", "Oranges"] this would fail (see error below).

I'm using v 4.9 of google-trends-api. The relatedQueries work fine with multiple items in array as the keyword.

Here is an example error I see:

{
  message: 'Available widgets does not contain selected api type',
  requestBody: ")]}'\n" +
    '{"widgets":[{"request":{"time":"2020-10-26 2020-11-16","resolution":"DAY","locale":"en-US","comparisonItem":[{"geo":{"country":"GB"},"complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Lewis Hamilton"}]}},{"geo":{"country":"GB"},"complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Rachel Riley"}]}},{"geo":{"country":"GB"},"complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Hollie Arnold"}]}},{"geo":{"country":"GB"},"complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Beverley Callard"}]}},{"geo":{"country":"GB"},"complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Victoria Derbyshire"}]}}],"requestOptions":{"property":"","backend":"IZG","category":0}},"lineAnnotationText":"Search interest","bullets":[{"text":"Lewis Hamilton"},{"text":"Rachel Riley"},{"text":"Hollie Arnold"},{"text":"Beverley Callard"},{"text":"Victoria Derbyshire"}],"showLegend":false,"showAverages":true,"helpDialog":{"title":"Interest over time","content":"Numbers represent search interest relative to the highest point on the chart for the given region and time. A value of 100 is the peak popularity for the term. A value of 50 means that the term is half as popular. A score of 0 means there was not enough data for this term."},"token":"APP6_UEAAAAAX7P0mnjVdxpashV32x3gDKTAVG50y-ck","id":"TIMESERIES","type":"fe_line_chart","title":"Interest over time","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":true,"isCurated":false},{"request":{"geo":{"country":"GB"},"comparisonItem":[{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Lewis Hamilton"}]}},{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Rachel Riley"}]}},{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Hollie Arnold"}]}},{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Beverley Callard"}]}},{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Victoria Derbyshire"}]}}],"resolution":"REGION","locale":"en-US","requestOptions":{"property":"","backend":"IZG","category":0},"dataMode":"PERCENTAGES"},"geo":"GB","resolution":"provinces","searchInterestLabel":"Search interest","displayMode":"regions","showLegend":false,"helpDialog":{"title":"Compared breakdown by subregion","content":"See which term ranked highest in each region during the specified time frame. Values are scaled from 0 to 100, where 100 is the region with peak popularity, a value of 50 is the region where the term is half as popular, and a value of 0 means that term was less than 1% as popular as the peak."},"bullets":[{"value":"Lewis Hamilton","color":"PALETTE_COLOR_1"},{"value":"Rachel Riley","color":"PALETTE_COLOR_2"},{"value":"Hollie Arnold","color":"PALETTE_COLOR_3"},{"value":"Beverley Callard","color":"PALETTE_COLOR_4"},{"value":"Victoria Derbyshire","color":"PALETTE_COLOR_5"}],"token":"APP6_UEAAAAAX7P0mohX6ZbgHL87qSHXRVniWJYzeoek","id":"GEO_MAP","type":"fe_multi_heat_map","title":"Compared breakdown by subregion","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":true,"isCurated":false},{"text":{"text":"Lewis Hamilton"},"id":"TITLE_0","type":"fe_text","title":"","template":"fe_explore","embedTemplate":"fe_embed","version":"1","isLong":true,"isCurated":false},{"request":{"geo":{"country":"GB"},"comparisonItem":[{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Lewis Hamilton"}]}}],"resolution":"REGION","locale":"en-US","requestOptions":{"property":"","backend":"IZG","category":0}},"geo":"GB","resolution":"provinces","searchInterestLabel":"Search interest","displayMode":"regions","helpDialog":{"title":"Interest by subregion","content":"See in which location your term was most popular during the specified time frame. Values are calculated on a scale from 0 to 100, where 100 is the location with the most popularity as a fraction of total searches in that location, a value of 50 indicates a location which is half as popular. A value of 0 indicates a location where there was not enough data for this term. \\u003cp\\u003e\\u003cp\\u003e \\u003cb\\u003eNote:\\u003c/b\\u003e A higher value means a higher proportion of all queries, not a higher absolute query count. So a tiny country where 80% of the queries are for \\"bananas\\" will get twice the score of a giant country where only 40% of the queries are for \\"bananas\\".","url":"https://support.google.com/trends/answer/4355212"},"color":"PALETTE_COLOR_1","index":0,"bullet":"Lewis Hamilton","token":"APP6_UEAAAAAX7P0mgtujgF5LGvEL7qFf2jP1zLqMNnF","id":"GEO_MAP_0","type":"fe_geo_chart_explore","title":"Interest by subregion","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false},{"request":{"restriction":{"geo":{"country":"GB"},"time":"2020-10-26 2020-11-16","originalTimeRangeForExploreUrl":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Lewis Hamilton"}]}},"keywordType":"QUERY","metric":["TOP","RISING"],"trendinessSettings":{"compareTime":"2020-10-04 2020-10-25"},"requestOptions":{"property":"","backend":"IZG","category":0},"language":"en","userCountryCode":"US"},"helpDialog":{"title":"Related queries","content":"Users searching for your term also searched for these queries. You can sort by the following metrics: \\u003cp\\u003e* \\u003cb\\u003eTop\\u003c/b\\u003e - The most popular search queries. Scoring is on a relative scale where a value of 100 is the most commonly searched query, 50 is a query searched half as often as the most popular query, and so on. \\u003cp\\u003e* \\u003cb\\u003eRising\\u003c/b\\u003e - Queries with the biggest increase in search frequency since the last time period. Results marked \\"Breakout\\" had a tremendous increase, probably because these queries are new and had few (if any) prior searches.","url":"https://support.google.com/trends/answer/4355000"},"color":"PALETTE_COLOR_1","keywordName":"Lewis Hamilton","token":"APP6_UEAAAAAX7P0mrxl357ByuEloroyBDOxuqlnEsnM","id":"RELATED_QUERIES_0","type":"fe_related_searches","title":"Related queries","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false},{"text":{"text":"Rachel Riley"},"id":"TITLE_1","type":"fe_text","title":"","template":"fe_explore","embedTemplate":"fe_embed","version":"1","isLong":true,"isCurated":false},{"request":{"geo":{"country":"GB"},"comparisonItem":[{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Rachel Riley"}]}}],"resolution":"REGION","locale":"en-US","requestOptions":{"property":"","backend":"IZG","category":0}},"geo":"GB","resolution":"provinces","searchInterestLabel":"Search interest","displayMode":"regions","helpDialog":{"title":"Interest by subregion","content":"See in which location your term was most popular during the specified time frame. Values are calculated on a scale from 0 to 100, where 100 is the location with the most popularity as a fraction of total searches in that location, a value of 50 indicates a location which is half as popular. A value of 0 indicates a location where there was not enough data for this term. \\u003cp\\u003e\\u003cp\\u003e \\u003cb\\u003eNote:\\u003c/b\\u003e A higher value means a higher proportion of all queries, not a higher absolute query count. So a tiny country where 80% of the queries are for \\"bananas\\" will get twice the score of a giant country where only 40% of the queries are for \\"bananas\\".","url":"https://support.google.com/trends/answer/4355212"},"color":"PALETTE_COLOR_2","index":1,"bullet":"Rachel Riley","token":"APP6_UEAAAAAX7P0muFhMsaO0h531Hrn12jLZVy-DmGE","id":"GEO_MAP_1","type":"fe_geo_chart_explore","title":"Interest by subregion","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false},{"request":{"restriction":{"geo":{"country":"GB"},"time":"2020-10-26 2020-11-16","originalTimeRangeForExploreUrl":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Rachel Riley"}]}},"keywordType":"QUERY","metric":["TOP","RISING"],"trendinessSettings":{"compareTime":"2020-10-04 2020-10-25"},"requestOptions":{"property":"","backend":"IZG","category":0},"language":"en","userCountryCode":"US"},"helpDialog":{"title":"Related queries","content":"Users searching for your term also searched for these queries. You can sort by the following metrics: \\u003cp\\u003e* \\u003cb\\u003eTop\\u003c/b\\u003e - The most popular search queries. Scoring is on a relative scale where a value of 100 is the most commonly searched query, 50 is a query searched half as often as the most popular query, and so on. \\u003cp\\u003e* \\u003cb\\u003eRising\\u003c/b\\u003e - Queries with the biggest increase in search frequency since the last time period. Results marked \\"Breakout\\" had a tremendous increase, probably because these queries are new and had few (if any) prior searches.","url":"https://support.google.com/trends/answer/4355000"},"color":"PALETTE_COLOR_2","keywordName":"Rachel Riley","token":"APP6_UEAAAAAX7P0mpxyy09-uD_Vj86at1UEzxX8YQ-5","id":"RELATED_QUERIES_1","type":"fe_related_searches","title":"Related queries","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false},{"text":{"text":"Hollie Arnold"},"id":"TITLE_2","type":"fe_text","title":"","template":"fe_explore","embedTemplate":"fe_embed","version":"1","isLong":true,"isCurated":false},{"request":{"geo":{"country":"GB"},"comparisonItem":[{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Hollie Arnold"}]}}],"resolution":"REGION","locale":"en-US","requestOptions":{"property":"","backend":"IZG","category":0}},"geo":"GB","resolution":"provinces","searchInterestLabel":"Search interest","displayMode":"regions","helpDialog":{"title":"Interest by subregion","content":"See in which location your term was most popular during the specified time frame. Values are calculated on a scale from 0 to 100, where 100 is the location with the most popularity as a fraction of total searches in that location, a value of 50 indicates a location which is half as popular. A value of 0 indicates a location where there was not enough data for this term. \\u003cp\\u003e\\u003cp\\u003e \\u003cb\\u003eNote:\\u003c/b\\u003e A higher value means a higher proportion of all queries, not a higher absolute query count. So a tiny country where 80% of the queries are for \\"bananas\\" will get twice the score of a giant country where only 40% of the queries are for \\"bananas\\".","url":"https://support.google.com/trends/answer/4355212"},"color":"PALETTE_COLOR_3","index":2,"bullet":"Hollie Arnold","token":"APP6_UEAAAAAX7P0mgIPW_VYvwB3p9ulEJkgbl1S_CCU","id":"GEO_MAP_2","type":"fe_geo_chart_explore","title":"Interest by subregion","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false},{"request":{"restriction":{"geo":{"country":"GB"},"time":"2020-10-26 2020-11-16","originalTimeRangeForExploreUrl":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Hollie Arnold"}]}},"keywordType":"QUERY","metric":["TOP","RISING"],"trendinessSettings":{"compareTime":"2020-10-04 2020-10-25"},"requestOptions":{"property":"","backend":"IZG","category":0},"language":"en","userCountryCode":"US"},"helpDialog":{"title":"Related queries","content":"Users searching for your term also searched for these queries. You can sort by the following metrics: \\u003cp\\u003e* \\u003cb\\u003eTop\\u003c/b\\u003e - The most popular search queries. Scoring is on a relative scale where a value of 100 is the most commonly searched query, 50 is a query searched half as often as the most popular query, and so on. \\u003cp\\u003e* \\u003cb\\u003eRising\\u003c/b\\u003e - Queries with the biggest increase in search frequency since the last time period. Results marked \\"Breakout\\" had a tremendous increase, probably because these queries are new and had few (if any) prior searches.","url":"https://support.google.com/trends/answer/4355000"},"color":"PALETTE_COLOR_3","keywordName":"Hollie Arnold","token":"APP6_UEAAAAAX7P0muf_b6l1938ZLF5oowex-Eztf37U","id":"RELATED_QUERIES_2","type":"fe_related_searches","title":"Related queries","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false},{"text":{"text":"Beverley Callard"},"id":"TITLE_3","type":"fe_text","title":"","template":"fe_explore","embedTemplate":"fe_embed","version":"1","isLong":true,"isCurated":false},{"request":{"geo":{"country":"GB"},"comparisonItem":[{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Beverley Callard"}]}}],"resolution":"REGION","locale":"en-US","requestOptions":{"property":"","backend":"IZG","category":0}},"geo":"GB","resolution":"provinces","searchInterestLabel":"Search interest","displayMode":"regions","helpDialog":{"title":"Interest by subregion","content":"See in which location your term was most popular during the specified time frame. Values are calculated on a scale from 0 to 100, where 100 is the location with the most popularity as a fraction of total searches in that location, a value of 50 indicates a location which is half as popular. A value of 0 indicates a location where there was not enough data for this term. \\u003cp\\u003e\\u003cp\\u003e \\u003cb\\u003eNote:\\u003c/b\\u003e A higher value means a higher proportion of all queries, not a higher absolute query count. So a tiny country where 80% of the queries are for \\"bananas\\" will get twice the score of a giant country where only 40% of the queries are for \\"bananas\\".","url":"https://support.google.com/trends/answer/4355212"},"color":"PALETTE_COLOR_4","index":3,"bullet":"Beverley Callard","token":"APP6_UEAAAAAX7P0mpexIuIJsNEPPTn7gGp_2V8YPE_x","id":"GEO_MAP_3","type":"fe_geo_chart_explore","title":"Interest by subregion","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false},{"request":{"restriction":{"geo":{"country":"GB"},"time":"2020-10-26 2020-11-16","originalTimeRangeForExploreUrl":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Beverley Callard"}]}},"keywordType":"QUERY","metric":["TOP","RISING"],"trendinessSettings":{"compareTime":"2020-10-04 2020-10-25"},"requestOptions":{"property":"","backend":"IZG","category":0},"language":"en","userCountryCode":"US"},"helpDialog":{"title":"Related queries","content":"Users searching for your term also searched for these queries. You can sort by the following metrics: \\u003cp\\u003e* \\u003cb\\u003eTop\\u003c/b\\u003e - The most popular search queries. Scoring is on a relative scale where a value of 100 is the most commonly searched query, 50 is a query searched half as often as the most popular query, and so on. \\u003cp\\u003e* \\u003cb\\u003eRising\\u003c/b\\u003e - Queries with the biggest increase in search frequency since the last time period. Results marked \\"Breakout\\" had a tremendous increase, probably because these queries are new and had few (if any) prior searches.","url":"https://support.google.com/trends/answer/4355000"},"color":"PALETTE_COLOR_4","keywordName":"Beverley Callard","token":"APP6_UEAAAAAX7P0mjVFDXQZ2QYjnRhx3Lp3K4OF7EpZ","id":"RELATED_QUERIES_3","type":"fe_related_searches","title":"Related queries","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false},{"text":{"text":"Victoria Derbyshire"},"id":"TITLE_4","type":"fe_text","title":"","template":"fe_explore","embedTemplate":"fe_embed","version":"1","isLong":true,"isCurated":false},{"request":{"geo":{"country":"GB"},"comparisonItem":[{"time":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Victoria Derbyshire"}]}}],"resolution":"REGION","locale":"en-US","requestOptions":{"property":"","backend":"IZG","category":0}},"geo":"GB","resolution":"provinces","searchInterestLabel":"Search interest","displayMode":"regions","helpDialog":{"title":"Interest by subregion","content":"See in which location your term was most popular during the specified time frame. Values are calculated on a scale from 0 to 100, where 100 is the location with the most popularity as a fraction of total searches in that location, a value of 50 indicates a location which is half as popular. A value of 0 indicates a location where there was not enough data for this term. \\u003cp\\u003e\\u003cp\\u003e \\u003cb\\u003eNote:\\u003c/b\\u003e A higher value means a higher proportion of all queries, not a higher absolute query count. So a tiny country where 80% of the queries are for \\"bananas\\" will get twice the score of a giant country where only 40% of the queries are for \\"bananas\\".","url":"https://support.google.com/trends/answer/4355212"},"color":"PALETTE_COLOR_5","index":4,"bullet":"Victoria Derbyshire","token":"APP6_UEAAAAAX7P0miYKlMtnF_wReCNoJ3SfWj7txB46","id":"GEO_MAP_4","type":"fe_geo_chart_explore","title":"Interest by subregion","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false},{"request":{"restriction":{"geo":{"country":"GB"},"time":"2020-10-26 2020-11-16","originalTimeRangeForExploreUrl":"2020-10-26 2020-11-16","complexKeywordsRestriction":{"keyword":[{"type":"BROAD","value":"Victoria Derbyshire"}]}},"keywordType":"QUERY","metric":["TOP","RISING"],"trendinessSettings":{"compareTime":"2020-10-04 2020-10-25"},"requestOptions":{"property":"","backend":"IZG","category":0},"language":"en","userCountryCode":"US"},"helpDialog":{"title":"Related queries","content":"Users searching for your term also searched for these queries. You can sort by the following metrics: \\u003cp\\u003e* \\u003cb\\u003eTop\\u003c/b\\u003e - The most popular search queries. Scoring is on a relative scale where a value of 100 is the most commonly searched query, 50 is a query searched half as often as the most popular query, and so on. \\u003cp\\u003e* \\u003cb\\u003eRising\\u003c/b\\u003e - Queries with the biggest increase in search frequency since the last time period. Results marked \\"Breakout\\" had a tremendous increase, probably because these queries are new and had few (if any) prior searches.","url":"https://support.google.com/trends/answer/4355000"},"color":"PALETTE_COLOR_5","keywordName":"Victoria Derbyshire","token":"APP6_UEAAAAAX7P0mk98CzwJF2IkGMLQOmj7febPkBbS","id":"RELATED_QUERIES_4","type":"fe_related_searches","title":"Related queries","template":"fe","embedTemplate":"fe_embed","version":"1","isLong":false,"isCurated":false}],"keywords":[{"keyword":"Lewis Hamilton","name":"Lewis Hamilton","type":"Search term"},{"keyword":"Rachel Riley","name":"Rachel Riley","type":"Search term"},{"keyword":"Hollie Arnold","name":"Hollie Arnold","type":"Search term"},{"keyword":"Beverley Callard","name":"Beverley Callard","type":"Search term"},{"keyword":"Victoria Derbyshire","name":"Victoria Derbyshire","type":"Search term"}],"timeRanges":["10/26/20 - 11/16/20","10/26/20 - 11/16/20","10/26/20 - 11/16/20","10/26/20 - 11/16/20","10/26/20 - 11/16/20"],"examples":[],"shareText":"Explore search interest for Lewis Hamilton, Rachel Riley, Hollie Arnold, Beverley Callard, Victoria Derbyshire by time, location and popularity on Google Trends","shouldShowMultiHeatMapMessage":false}'
}