
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
@shaivpidadi/trends-js
Advanced tools
A TypeScript library for interacting with the Google Trends API. This package provides a simple and type-safe way to access Google Trends data programmatically.
@shaivpidadi/trends-jsURL: https://elitetimesnews.com
What it uses: dailyTrends() (US, en) to power the home page “Daily Trending” rail, refreshed on a schedule.
npm install @shaivpidadi/trends-js
import GoogleTrendsApi from '@shaivpidadi/trends-js';
Get daily trending topics for a specific region:
const result = await GoogleTrendsApi.dailyTrends({
geo: 'US', // Default: 'US'
lang: 'en', // Default: 'en'
});
// Result structure:
// {
// allTrendingStories: Array<{
// title: string,
// traffic: string,
// image?: {
// newsUrl: string,
// source: string,
// imageUrl: string
// },
// articles: Array<{
// title: string,
// url: string,
// source: string,
// time: string,
// snippet: string
// }>,
// shareUrl: string,
// startTime: number, // Unix timestamp
// endTime?: number // Unix timestamp (optional)
// }>,
// summary: Array<...>
// }
Get real-time trending topics:
const result = await GoogleTrendsApi.realTimeTrends({
geo: 'US', // Default: 'US'
trendingHours: 4, // Default: 4
});
// Result structure:
// {
// allTrendingStories: Array<{
// title: string,
// traffic: string,
// image?: {
// newsUrl: string,
// source: string,
// imageUrl: string
// },
// articles: Array<{
// title: string,
// url: string,
// source: string,
// time: string,
// snippet: string
// }>,
// shareUrl: string,
// startTime: number, // Unix timestamp
// endTime?: number // Unix timestamp (optional)
// }>,
// summary: Array<...>
// }
Get search suggestions for a keyword:
const suggestions = await GoogleTrendsApi.autocomplete(
'bitcoin', // Keyword to get suggestions for
'en-US', // Language (default: 'en-US')
);
Get widget data for a keyword:
const result = await GoogleTrendsApi.explore({
keyword: 'bitcoin',
geo: 'US' // Default: 'US',
time: 'today 12-m',
category: 0, // Default: 0
property: '', // Default: ''
hl: 'en-US', // Default: 'en-US'
});
// Result structure:
// {
// widgets: Array<{
// id: string,
// request: {...},
// token: string
// }>
// }
Note: For all methods below, it is recommended to set
enableBackoff: truein the options to automatically handle and bypass Google's rate limiting.
Get interest data by region:
const result = await GoogleTrendsApi.interestByRegion({
keyword: 'Stock Market', // Required - string
startTime: new Date('2024-01-01'), // Optional - defaults to 2004-01-01
endTime: new Date(), // Optional - defaults to current date
geo: 'US', // Optional - 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
enableBackoff: true // Optional - defaults to false
});
// Result structure:
// {
// default: {
// geoMapData: Array<{
// geoCode: string,
// geoName: string,
// value: number[],
// formattedValue: string[],
// maxValueIndex: number,
// hasData: boolean[],
// coordinates?: {
// lat: number,
// lng: number
// }
// }>
// }
// }
Get related topics for any keyword:
const result = await GoogleTrendsApi.relatedTopics({
keyword: 'artificial intelligence',
startTime: new Date('2024-01-01'),
endTime: new Date(),
category: 0, // Optional - defaults to 0
geo: 'US', // Optional - defaults to 'US'
property: '', // Optional - defaults to ''
hl: 'en-US', // Optional - defaults to 'en-US'
enableBackoff: true // Optional - defaults to false
});
// Result structure:
// {
// data: {
// default: {
// rankedList: Array<{
// rankedKeyword: Array<{
// topic: {
// mid: string,
// title: string,
// type: string
// },
// value: number,
// formattedValue: string,
// hasData: boolean,
// link: string
// }>
// }>
// }
// }
// }
Get related queries for any keyword:
const result = await GoogleTrendsApi.relatedQueries({
keyword: 'machine learning',
geo: 'US',
startTime: new Date('2024-01-01'),
endTime: new Date(),
category: 0,
hl: 'en-US',
enableBackoff: true // Optional - defaults to false
});
// Result structure:
// {
// data: {
// default: {
// rankedList: Array<{
// rankedKeyword: Array<{
// query: string,
// value: number,
// formattedValue: string,
// hasData: boolean,
// link: string
// }>
// }>
// }
// }
// }
interface DailyTrendsOptions {
geo?: string;
lang?: string;
}
interface RealTimeTrendsOptions {
geo: string;
trendingHours?: number;
}
interface ExploreOptions {
keyword: string;
geo?: string;
time?: string;
category?: number;
property?: string;
hl?: string;
}
interface InterestByRegionOptions {
keyword: string;
startTime?: Date;
endTime?: Date;
geo?: string;
resolution?: 'COUNTRY' | 'REGION' | 'CITY' | 'DMA';
hl?: string;
timezone?: number;
category?: number;
enableBackoff?: boolean;
}
interface RelatedTopicsOptions {
keyword: string;
geo?: string;
startTime?: Date;
endTime?: Date;
category?: number;
property?: string;
hl?: string;
enableBackoff?: boolean;
}
interface RelatedQueriesOptions {
keyword: string;
geo?: string;
startTime?: Date;
endTime?: Date;
category?: number;
property?: string;
hl?: string;
enableBackoff?: boolean;
}
npm run build
npm test
MIT
FAQs
Google Trends API for Node.js
We found that @shaivpidadi/trends-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.