pat310 / google-trends-api

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

Using array for multiple keywords doesn't process beyond first keyword. #152

Open Dramier opened 3 years ago

Dramier commented 3 years ago

Using relatedQueries and passing in any form of array for keyword field returns results that only process the first keyword. The remaining keywords in the array have no results returned.

Tried this with the following types of array:
var someArray = ['keyword1', 'keyword2'];
using keyword: ['keyword1', 'keyword2'] directly building the array programmatically using push

Example query, notice that it returns the results for the first keyword in the array twice rather than results for each keyword.

googleTrends.relatedQueries({ keyword: ['tips', 'bread'], geo: 'US' }) .then((res) => { console.log(res); }) .catch((err) => { console.log(err); })

Returned result:

{ "default": { "rankedList": [ { "rankedKeyword": [ { "query": "tips and tricks", "value": 100, "formattedValue": "100", "hasData": true, "link": "/trends/explore?q=tips+and+tricks&date=2021-01-20+2021-02-10&geo=US" }, { "query": "beef tips", "value": 66, "formattedValue": "66", "hasData": true, "link": "/trends/explore?q=beef+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "exhaust tips", "value": 34, "formattedValue": "34", "hasData": true, "link": "/trends/explore?q=exhaust+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "nail tips", "value": 34, "formattedValue": "34", "hasData": true, "link": "/trends/explore?q=nail+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "word tips", "value": 33, "formattedValue": "33", "hasData": true, "link": "/trends/explore?q=word+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "steak tips", "value": 32, "formattedValue": "32", "hasData": true, "link": "/trends/explore?q=steak+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "interview tips", "value": 25, "formattedValue": "25", "hasData": true, "link": "/trends/explore?q=interview+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "french tips", "value": 21, "formattedValue": "21", "hasData": true, "link": "/trends/explore?q=french+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "linus tech tips", "value": 18, "formattedValue": "18", "hasData": true, "link": "/trends/explore?q=linus+tech+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "beef tips recipe", "value": 15, "formattedValue": "15", "hasData": true, "link": "/trends/explore?q=beef+tips+recipe&date=2021-01-20+2021-02-10&geo=US" }, { "query": "beef tips and noodles", "value": 13, "formattedValue": "13", "hasData": true, "link": "/trends/explore?q=beef+tips+and+noodles&date=2021-01-20+2021-02-10&geo=US" }, { "query": "tips and toes", "value": 11, "formattedValue": "11", "hasData": true, "link": "/trends/explore?q=tips+and+toes&date=2021-01-20+2021-02-10&geo=US" }, { "query": "rib tips", "value": 10, "formattedValue": "10", "hasData": true, "link": "/trends/explore?q=rib+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "weight loss tips", "value": 8, "formattedValue": "8", "hasData": true, "link": "/trends/explore?q=weight+loss+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "tips procedure", "value": 8, "formattedValue": "8", "hasData": true, "link": "/trends/explore?q=tips+procedure&date=2021-01-20+2021-02-10&geo=US" }, { "query": "beef tips and rice", "value": 6, "formattedValue": "6", "hasData": true, "link": "/trends/explore?q=beef+tips+and+rice&date=2021-01-20+2021-02-10&geo=US" }, { "query": "french tips nails", "value": 6, "formattedValue": "6", "hasData": true, "link": "/trends/explore?q=french+tips+nails&date=2021-01-20+2021-02-10&geo=US" }, { "query": "coronavirus tips", "value": 6, "formattedValue": "6", "hasData": true, "link": "/trends/explore?q=coronavirus+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "beef tips instant pot", "value": 6, "formattedValue": "6", "hasData": true, "link": "/trends/explore?q=beef+tips+instant+pot&date=2021-01-20+2021-02-10&geo=US" }, { "query": "sudoku tips", "value": 5, "formattedValue": "5", "hasData": true, "link": "/trends/explore?q=sudoku+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "potty training tips", "value": 5, "formattedValue": "5", "hasData": true, "link": "/trends/explore?q=potty+training+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "beef tips and gravy", "value": 5, "formattedValue": "5", "hasData": true, "link": "/trends/explore?q=beef+tips+and+gravy&date=2021-01-20+2021-02-10&geo=US" }, { "query": "breastfeeding tips", "value": 4, "formattedValue": "4", "hasData": true, "link": "/trends/explore?q=breastfeeding+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "frosted tips", "value": 4, "formattedValue": "4", "hasData": true, "link": "/trends/explore?q=frosted+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "apple pencil tips", "value": 3, "formattedValue": "3", "hasData": true, "link": "/trends/explore?q=apple+pencil+tips&date=2021-01-20+2021-02-10&geo=US" } ] }, { "rankedKeyword": [ { "query": "virtual interview tips", "value": 7000, "formattedValue": "Breakout", "link": "/trends/explore?q=virtual+interview+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "energy saving tips", "value": 6900, "formattedValue": "Breakout", "link": "/trends/explore?q=energy+saving+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "amazon stealing tips", "value": 6850, "formattedValue": "Breakout", "link": "/trends/explore?q=amazon+stealing+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "beef tips and noodles", "value": 110, "formattedValue": "+110%", "link": "/trends/explore?q=beef+tips+and+noodles&date=2021-01-20+2021-02-10&geo=US" }, { "query": "sudoku tips", "value": 100, "formattedValue": "+100%", "link": "/trends/explore?q=sudoku+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "french tips", "value": 50, "formattedValue": "+50%", "link": "/trends/explore?q=french+tips&date=2021-01-20+2021-02-10&geo=US" }, { "query": "beef tips recipe", "value": 40, "formattedValue": "+40%", "link": "/trends/explore?q=beef+tips+recipe&date=2021-01-20+2021-02-10&geo=US" } ] } ] } }

cbaucom commented 2 years ago

I am also finding that multiple keywords do not seem to work past the first item in the array.