Socket
Book a DemoInstallSign in
Socket

@alkalisummer/google-trends-js

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alkalisummer/google-trends-js

Google Trends API for Node.js

latest
Source
npmnpm
Version
0.2.9
Version published
Weekly downloads
10
-75.61%
Maintainers
1
Weekly downloads
 
Created
Source

This is a TypeScript library that has been updated to incorporate the latest changes to the Google Trends API endpoints. This package provides a simple and type-safe way to access Google Trends data programmatically.

This API was developed based on @shaivpidadi/trends-js with some added and modified features.

Installation

npm install @alkalisummer/google-trends-js

Features

  • Get daily trending topics
  • Get real-time trending topics
  • Get articles releated trening topics
  • Get autocomplete suggestions
  • Explore trends data
  • Get interest by region data
  • Get interest change timeline by trending topics
  • TypeScript support
  • Promise-based API

Usage

Importing

import GoogleTrendsApi from '@alkalisummer/google-trends-js';

Get daily trending topics for a specific region:

const result = await GoogleTrendsApi.dailyTrends({
  geo: 'US', // Default: 'US'
  hl: 'en', // Default: 'en'
});

// Result structure:
// {
//   data?: Array<{
//     keyword: string;
//     traffic: string;
//     trafficGrowthRate: string;
//     activeTime: string;
//     relatedKeywords: string[];
//     articleKeys: ArticleKey[];
//   }>,
//   error?: GoogleTrendsError
// }
//

Get trending articles for specific article keys

You can retrieve articleKeys from the articleKeys field in the response returned by the dailyTrends method.

const result = await GoogleTrendsApi.trendingArticles({
  articleKeys: [[1, hl, geo]], // Array of article keys
  articleCount: 5, // Number of articles to get
});

// Result structure:
// {
//   data?: Array<{
//     title: string;
//     link: string;
//     mediaCompany: string;
//     pressDate: number[];
//     image: string;
//   }>,
//   error?: GoogleTrendsError
// }

Interest Over Time

Get interest over time data for a specific keyword:

const result = await GoogleTrendsApi.interestOverTime({
  keyword: 'bitcoin',
  geo: 'US', // Default: 'US'
});

// Result structure:
// {
//   data?: {
//     keyword: string;
//     dates: string[];
//     values: number[];
//   },
//   error?: GoogleTrendsError
// }

Get real-time trending topics:

const result = await GoogleTrendsApi.realTimeTrends({
  geo: 'US', // Default: 'US'
  trendingHours: 4, // Default: 4
});

// Result structure:
// {
//   allTrendingStories: Array<...>,
//   summary: string[]
// }

Autocomplete

Get search suggestions for a keyword:

const suggestions = await GoogleTrendsApi.autocomplete(
  'bitcoin', // Keyword to get suggestions for
  'en-US', // Language (default: 'en-US')
);

// Returns: string[]

Explore

Get widget data for a keyword:

const result = await GoogleTrendsApi.explore({
  keyword: 'bitcoin',
  geo: 'US', // Default: 'US'
  time: '2025-06-30 2025-07-01', // Default: 'now 1-d'
  category: 0, // Default: 0
  property: '', // Default: ''
  hl: 'en-US', // Default: 'en-US'
});

// Result structure:
// {
//   widgets: Array<{
//     id: string,
//     request: {...},
//     token: string
//   }>
// }

Interest by Region

Get interest data by region:

const result = await GoogleTrendsApi.interestByRegion({
  keyword: 'Stock Market', // Required - string or string[]
  startTime: new Date('2024-01-01'), // Optional - defaults: yesterday
  endTime: new Date(), // Optional - defaults to current date
  geo: 'US', // Optional - string or string[] - defaults to 'US'
  resolution: 'REGION', // Optional - 'COUNTRY' | 'REGION' | 'CITY' | 'DMA'
  hl: 'en-US', // Optional - defaults to 'en-US'
  timezone: -240, // Optional - defaults to local timezone
  category: 0, // Optional - defaults to 0
});

// Result structure:
// {
//   default: {
//     geoMapData: Array<{
//       geoCode: string,
//       geoName: string,
//       value: number[],
//       formattedValue: string[],
//       maxValueIndex: number,
//       hasData: boolean[],
//       coordinates?: {
//         lat: number,
//         lng: number
//       }
//     }>
//   }
// }

Example with multiple keywords and regions:

const result = await GoogleTrendsApi.interestByRegion({
  keyword: ['wine', 'peanuts'],
  geo: ['US-CA', 'US-VA'],
  startTime: new Date('2024-01-01'),
  endTime: new Date(),
  resolution: 'CITY',
});

API Reference

DailyTrendsOptions

interface DailyTrendsOptions {
  geo?: string; // Default: 'US'
  hl?: string; // Default: 'en'
}

RealTimeTrendsOptions

interface RealTimeTrendsOptions {
  geo: string;
  trendingHours?: number; // Default: 4
}

ExploreOptions

interface ExploreOptions {
  keyword: string;
  geo?: string; // Default: 'US'
  time?: string; // Default: 'now 1-d'
  category?: number; // Default: 0
  property?: string; // Default: ''
  hl?: string; // Default: 'en-US'
}

InterestByRegionOptions

interface InterestByRegionOptions {
  keyword: string | string[]; // Required - search term(s)
  startTime?: Date; // Optional - start date
  endTime?: Date; // Optional - end date
  geo?: string | string[]; // Optional - geocode(s)
  resolution?: 'COUNTRY' | 'REGION' | 'CITY' | 'DMA'; // Optional
  hl?: string; // Optional - language code
  timezone?: number; // Optional - timezone offset
  category?: number; // Optional - category number
}

TrendingArticlesOptions

interface TrendingArticlesOptions {
  articleKeys: ArticleKey[]; // Required - array of article keys
  articleCount: number; // Required - number of articles to get
}

type ArticleKey = [number, string, string]; // [index, lang, geo]

InterestOverTimeOptions

interface InterestOverTimeOptions {
  keyword: string; // Required - search term
  geo?: string; // Optional - geocode (default: 'US')
}

Development

Building

Keywords

google trends

FAQs

Package last updated on 13 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts