pat310 / google-trends-api

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

Support for keyword comparison: averages? #79

Closed geraldhiller closed 7 years ago

geraldhiller commented 7 years ago

Just a quick question. Does this api allow me to get the average values for the comparison of two keywords for a given time period? I couldn't find it in the readme. Thanks!

pat310 commented 7 years ago

I think so. When you use the interestOverTime method, there should be two keys in the JSON, timelineData and averages. Example output for comparing dog, cat, and fish (I cut out a lot of data points for brevity):

{
  "default": {
    "timelineData": [
      {
        "time": "1473552000",
        "formattedTime": "Sep 11 - Sep 17 2016",
        "formattedAxisTime": "Sep 11, 2016",
        "value": [
          85,
          53,
          39
        ],
        "formattedValue": [
          "85",
          "53",
          "39"
        ]
      },
      {
        "time": "1504396800",
        "formattedTime": "Sep 3 - Sep 9 2017",
        "formattedAxisTime": "Sep 3, 2017",
        "value": [
          94,
          54,
          42
        ],
        "formattedValue": [
          "94",
          "54",
          "42"
        ],
        "isPartial": true
      }
    ],
    "averages": [
      90,
      53,
      41
    ]
  }
}

I'll make a comment about this in the README