PHPackages                             sansebi/g-trends - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sansebi/g-trends

ActiveLibrary[API Development](/categories/api)

sansebi/g-trends
================

Google Trends API for PHP

2.3.0(6y ago)04MITPHPPHP ^7.0

Since Sep 3Pushed 6y agoCompare

[ Source](https://github.com/sansebi/g-trends)[ Packagist](https://packagist.org/packages/sansebi/g-trends)[ RSS](/packages/sansebi-g-trends/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (5)Versions (13)Used By (0)

g-trends
========

[](#g-trends)

Google Trends API for PHP
=========================

[](#google-trends-api-for-php)

Introduction
------------

[](#introduction)

This is an unofficial Google Trends API for PHP.

Please notice that the good functionality of this API depends on Google's willing to keep the backward compatibility and/or the parameters, naming and/or required values.
If this happens, feel free to contribute or open an issue.

Requirements
------------

[](#requirements)

Please see the [composer.json](composer.json) file.

Installation
------------

[](#installation)

### Via Composer (require)

[](#via-composer-require)

If you have composer installed globally

```
$ composer require x-fran/g-trends
```

If you use composer.phar local

```
# Get your own copy of composer.phar
$ curl -s https://getcomposer.org/installer | php -- --filename=composer
$ composer require "x-fran/g-trends": "^2.0"
```

### Via Composer (create-project)

[](#via-composer-create-project)

You can use the `create-project` command from [Composer](http://getcomposer.org/)to create the project in one go (you need to install [composer](https://getcomposer.org/doc/00-intro.md#downloading-the-composer-executable)):

```
$ curl -s https://getcomposer.org/installer | php -- --filename=composer
$ composer --no-dev create-project x-fran/g-trends path/to/install
```

### Via Git (clone)

[](#via-git-clone)

First, clone the repository:

```
$ git clone https://github.com/x-fran/g-trends.git # optionally, specify the directory in which to clone
$ cd path/to/install
$ curl -s https://getcomposer.org/installer | php -- --filename=composer
```

At this point, you need to use [Composer](https://getcomposer.org/) to install dependencies. Assuming you already have Composer:

```
$ composer --no-dev install
```

Demo
----

[](#demo)

To see a demo output from all methods (okay, functions) please open in your favorite browser the index.php

Usage
-----

[](#usage)

### New instance of the class GTrends

[](#new-instance-of-the-class-gtrends)

```
# This options are by default if none provided
$options = [
        'hl'  => 'en-US',
        'tz'  => -60, # last hour
        'geo' => 'IE',
    ];
$gt = new GTrends($options);

```

### Interest Over Time

[](#interest-over-time)

```
print_r($gt->interestOverTime('Dublin'));

```

### Related Queries

[](#related-queries)

```
# You can add up to 5 keywords
print_r( $gt->relatedQueries(['Dublin', 'Madrid', 'Paris']));

```

### Trending Searches

[](#trending-searches)

```
# p54 is Google's tricky and wired code for Ireland
print_r($gt->trendingSearches('p54', date('Ymd')));

```

### Interest by Subregion

[](#interest-by-subregion)

```
# You can add up to 5 keywords
# Parameter $resolution (optional) for United States 'Subregion', 'Metro', 'City'
# Parameter $resolution (optional) for the rest of the countries 'Subregion', 'City' only
print_r($gt->relatedQueries(['Dublin'], 'City'));

```

### Suggestions Autocomplete

[](#suggestions-autocomplete)

```
print_r($gt->suggestionsAutocomplete('toys'));

```

Common API parameters
---------------------

[](#common-api-parameters)

$keyWordList (Array)

> Array of keywords (up to 5) to get data for

$category (Integer)

> Search by category Please view this [wiki page containing all available categories](https://github.com/pat310/google-trends-api/wiki/Google-Trends-Categories)

$tz (Integer)

> Timezone Offset For example US CST is `360`

$time (String)

> Timezone Offset

> **`'now 1-H'`** would get data from last hour (default)
> **`'today 2-d'`** would get data from today to 2 days ago
> **`'today 3-m'`** would get data from today to 3 months ago
> **`'today 4-y'`** would get data from today to 4 years ago

Caveats
-------

[](#caveats)

```
- This is not an official or supported API
- Rate Limit is not publicly known, let me know if you have a consistent estimate.

```

Credits
-------

[](#credits)

- Some ideas pulled from General Mills's Google Trends API for Python
    -

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~93 days

Recently: every ~39 days

Total

11

Last Release

2235d ago

Major Versions

1.3.0 → 2.0.02018-11-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/acf0092f4f164cd3930e2695047159b8852026b13d9d7ae7f14ce42edb7a71f8?d=identicon)[sansebi](/maintainers/sansebi)

---

Top Contributors

[![x-fran](https://avatars.githubusercontent.com/u/3188361?v=4)](https://github.com/x-fran "x-fran (24 commits)")[![maxlamontagne](https://avatars.githubusercontent.com/u/5266296?v=4)](https://github.com/maxlamontagne "maxlamontagne (17 commits)")[![qonrat](https://avatars.githubusercontent.com/u/113827360?v=4)](https://github.com/qonrat "qonrat (3 commits)")[![lukasleitsch](https://avatars.githubusercontent.com/u/3009245?v=4)](https://github.com/lukasleitsch "lukasleitsch (2 commits)")[![wetfire2k](https://avatars.githubusercontent.com/u/1525536?v=4)](https://github.com/wetfire2k "wetfire2k (2 commits)")[![bondarenkoid](https://avatars.githubusercontent.com/u/15730984?v=4)](https://github.com/bondarenkoid "bondarenkoid (1 commits)")[![sansebi](https://avatars.githubusercontent.com/u/8580735?v=4)](https://github.com/sansebi "sansebi (1 commits)")[![hazaveh](https://avatars.githubusercontent.com/u/12988865?v=4)](https://github.com/hazaveh "hazaveh (1 commits)")

---

Tags

phpgooglegoogle apiPHP Librarytrendsexploregoogle-trendstrendingrelated-queriestrending-search

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/sansebi-g-trends/health.svg)

```
[![Health](https://phpackages.com/badges/sansebi-g-trends/health.svg)](https://phpackages.com/packages/sansebi-g-trends)
```

###  Alternatives

[x-fran/g-trends

Google Trends API for PHP

11955.6k](/packages/x-fran-g-trends)[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[jeroendesloovere/geolocation-php-api

This Geolocation PHP class connects to Google Maps API to find latitude/longitude or address.

75316.8k4](/packages/jeroendesloovere-geolocation-php-api)[aurawindsurfing/google-translate

Free Laravel package for Paid Google Translate REST API with your own API key

1119.5k1](/packages/aurawindsurfing-google-translate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
