This library provides an unofficial API layer for programmatically accessing Google Trends data, primarily designed for server-side (Node.js) environments to bypass client-side CORS restrictions. It enables developers to query various Google Trends endpoints such as interest over time, daily trends, related queries, and autocomplete suggestions. The current stable version is 4.9.2, and the project is actively maintained with ongoing expansions and improvements. A key differentiator is its ability to access Google Trends data without requiring an official Google API key, by mimicking web requests to the public Google Trends interface. It supports both traditional callback functions and modern Promise-based patterns for asynchronous operations, returning parsed data in a structured JavaScript object format.
npm install google-trends-apiVerified import paths — ran on the pinned version, not inferred.
Demonstrates fetching interest over time, daily trends, and autocomplete suggestions using the library's Promise-based API methods.
Upgrade to `google-trends-api@^4.0.0` or later. Review the updated API methods and parameter structures outlined in the library's documentation, as direct replacements for older calls may not exist or function identically.
Implement a Node.js backend or serverless function to make calls to `google-trends-api`. Expose the necessary Google Trends data through your own API endpoints for consumption by frontend applications.
Implement client-side caching for frequently requested data, introduce delays or throttling between API calls, or consider using a proxy server rotation strategy for high-volume data collection.
Move the `google-trends-api` calls to a Node.js server or serverless function. Your frontend application should then call your custom backend API to retrieve the data.
Ensure the `keyword` property in the options object is set to a string (for a single keyword) or an array of strings (for multiple keywords) before making the API call.
No dependency data recorded yet.