PHPackages                             trends/google-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. trends/google-trends

ActiveLibrary

trends/google-trends
====================

Google Trends API for PHP

1.0.1(4y ago)058MITPHPPHP ^7.0

Since Nov 23Pushed 4y ago1 watchersCompare

[ Source](https://github.com/17771777094/google-trends-api-update)[ Packagist](https://packagist.org/packages/trends/google-trends)[ RSS](/packages/trends-google-trends/feed)WikiDiscussions main Synced 6d ago

READMEChangelog (1)Dependencies (5)Versions (3)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)

```
use Google\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->getRelatedSearchQueries(['Dublin', 'Madrid', 'Paris']));

```

### Realtime Search Trends

[](#realtime-search-trends)

```
# Categories for Realtime Search Trends are a single char str:
print_r($gt->getRealTimeSearchTrends('all'));
#
# Categories
# all : default
# b : business
# e : entertainment
# m : health/medical
# t : sci/tech
# s : sports
# h : top stories

```

### Daily Search Trends

[](#daily-search-trends)

```
# print_r($gt->getDailySearchTrends());

```

### Trending Searches

[](#trending-searches)

```
# p54 is Google's tricky and wired code for Ireland
print_r($gt->trendingSearches('p54', date('Ymd')));
#
# National Region Codes:
# IRELAND=p54
# UNITED_STATES=p1
# ARGENTINA=p30
# AUSTRALIA=p8
# AUSTRIA=p44
# BELGIUM=p41
# BRAZIL=p18
# CANADA=p13
# CHILE=p38
# COLOMBIA=p32
# CZECHIA=p43
# DENMARK=p49
# EGYPT=p29
# FINLAND=p50
# FRANCE=p16
# GERMANY=p15
# GREECE=p48
# HONG_KONG=p10
# HUNGARY=p45
# INDIA=p3
# INDONESIA=p19
# ISRAEL=p6
# ITALY=p27
# JAPAN=p4
# KENYA=p37
# MALAYSIA=p34
# MEXICO=p21
# NETHERLANDS=p17
# NEW_ZEALAND=p53
# NIGERIA=p52
# NORWAY=p51
# PHILIPPINES=p25
# POLAND=p31
# PORTUGAL=p47
# ROMANIA=p39
# RUSSIA=p14
# SAUDI_ARABIA=p36
# SINGAPORE=p5
# SOUTH_AFRICA=p40
# SOUTH_KOREA=p23
# SPAIN=p26
# SWEDEN=p42
# SWITZERLAND=p46
# TAIWAN=p12
# THAILAND=p33
# TURKEY=p24
# UKRAINE=p35
# UNITED_KINGDOM=p9
# VIETNAM=p28

```

### 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

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~0 days

Total

2

Last Release

1636d ago

Major Versions

0.0.1 → 1.0.12021-11-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/93b18db8e75c982fffa0f3fce72c84b1cf547332e300bd77f04c72048bd00ca3?d=identicon)[17771777094](/maintainers/17771777094)

---

Top Contributors

[![17771777094](https://avatars.githubusercontent.com/u/31822126?v=4)](https://github.com/17771777094 "17771777094 (2 commits)")

---

Tags

phpgooglegoogle apiPHP Librarytrendsexploregoogle-trendstrendingrelated-queriestrending-search

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[x-fran/g-trends

Google Trends API for PHP

11955.6k](/packages/x-fran-g-trends)[gdg-tangier/cloud-pubsub

Google Cloud pub-sub for laravel

5054.9k](/packages/gdg-tangier-cloud-pubsub)

PHPackages © 2026

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