npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-google-search-trends

v1.1.0

Published

API to retrieve JSON data from Google Search Trends with localization

Downloads

14

Readme

node-google-search-trends

Node.js module to grab Google's trending searches from the official Atom feed. It returns data more or less identical to this page, using any localized version of this feed, without all the clutter that comes with XML feeds.

This module was written to pull interesting discussion topics into Quibbler. It is intended for use in similar use cases, like in an application that can benefit from having a list of trending topics (that only needs to change occasionally). But feel free to try out innovative things with it.

Contact me @Antrikshy with any questions, feedback or bugs.

Note: This module does not let you analyze Google Trends data for specific keywords, and nor does it provide you their search trends over time. This is just a simple tool to get keywords from Google's "Trending Searches" (which may get rebranded over time, and I will try to keep this notice up to date to avoid confusion) so you don't have to parse the feed yourself.

Usage

As always, install using:

npm install node-google-search-trends [--save]

The module comes with one exposed function. It takes three parameters - localization, count and callback. Example usage:

var trends = require('node-google-search-trends');
trends('Singapore', 10, function(err, data) {
    if (err) return console.err(err);
    console.log(JSON.stringify(data, null, 2));  // Pretty prints JSON 'data'
});

Google only seems to store a maximum of 20 recent trends, so count is capped at 20. Also, the serial order of search trends on the website may differ from returned data, because that's how Google's feed is.

Here's an example of the data object:

{
  '0': {
    title: [
      'Comcast'
    ],
    description: [
      ''
    ],
    link: [
      'http://www.google.com/trends/hottrends?pn=p1#a=20150327-Comcast'
    ],
    pubDate: [
      'Fri, 27 Mar 2015 00:00:00 -0700'
    ],
    'ht:picture': [
      '//t2.gstatic.com/images?q=tbn:ANd9GcQ336KOFcezbrMJXlGqQ0wko4C1RjXwhLCS-zYLh0SJB_i_qdiYej-mNPKG4pv-SipOZK8K7daS'
    ],
    'ht:picture_source': [
      'Gawker'
    ],
    'ht:approx_traffic': [
      '50,000+'
    ],
    'ht:news_item': [
      [Object],
      [Object]
    ]
  }
}

Potentially useful items are title (the actual trending keyword), link (to the Trends page), pubDate (when the trending item was added to the feed). ht:picture is an image automatically assigned to the trend, displayed on the Trends site linked above.

Contribute

It's a pretty simple module to contribute to, if you know Node.js basics. Just clone the repo and make a script inside the folder to test responses using require('./trends.js'). Any fixes, cleanup or new features are always appreciated.