PHPackages                             x-fran/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. x-fran/g-trends

ActiveLibrary[API Development](/categories/api)

x-fran/g-trends
===============

Google Trends API for PHP

4.0.0(1y ago)11756.9k↑71.4%46[12 issues](https://github.com/x-fran/g-trends/issues)MITPHPPHP ~8.3.0CI failing

Since Sep 3Pushed 1y ago8 watchersCompare

[ Source](https://github.com/x-fran/g-trends)[ Packagist](https://packagist.org/packages/x-fran/g-trends)[ Docs](https://tarlabs.es/)[ RSS](/packages/x-fran-g-trends/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (9)Versions (19)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": "^3.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' => 0,
    'geo' => 'US',
    'time' => 'all',
    'category' => 0,
];
$gt = new GTrends($options);

```

Set proxy to avoid google recaptcha
-----------------------------------

[](#set-proxy-to-avoid-google-recaptcha)

```
$gt = new GTrends($options);

$gt->setProxyConfigs([
    'proxy_host' => 'your_proxy_host',
    'proxy_port' => 8000,
    'proxy_user' => 'your_proxy_user',
    'proxy_pass' => 'your_proxy_pass',
]);

$gt->setProxyConfigs(null); // clear proxy if you want

```

### Interest Over Time

[](#interest-over-time)

```
$gt->getInterestOverTime('Dublin');

```

### Related Queries

[](#related-queries)

```
$gt->getRelatedSearchQueries(['Donald Trump', 'Barack Obama']);

```

### Realtime Search Trends

[](#realtime-search-trends)

```
# Categories for Realtime Search Trends are a single char str:
$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)

```
$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

```

### Suggestions Autocomplete

[](#suggestions-autocomplete)

```
$gt->suggestionsAutocomplete('Milwaukee');

```

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

[](#common-api-parameters)

$keyWords (Array)

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

$options\['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)

$options\['tz'\] (Integer)

> Timezone Offset For example US CST is `360`

$options\['time'\] (String)

> Timezone Offset

> **`'now 1-H'`** would get data from last hour
> **`'now 1-d'`** would get data from last day
> **`'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

51

—

FairBetter than 95% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 54.5% 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 ~147 days

Recently: every ~235 days

Total

18

Last Release

714d ago

Major Versions

1.3.0 → 2.0.02018-11-16

2.2.7 → 3.0.02021-12-21

3.1.2 → 4.0.02024-07-20

PHP version history (4 changes)v1.0.0PHP ^7.0

2.2.7PHP ^7.0|^8.0

3.0.0PHP ^7.4|^8.0

4.0.0PHP ~8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a9792e4a4cc896050abc3a338fa3ff65177b33163c5b085024e6501b491ce86a?d=identicon)[x-fran](/maintainers/x-fran)

---

Top Contributors

[![x-fran](https://avatars.githubusercontent.com/u/3188361?v=4)](https://github.com/x-fran "x-fran (42 commits)")[![maxlamontagne](https://avatars.githubusercontent.com/u/5266296?v=4)](https://github.com/maxlamontagne "maxlamontagne (17 commits)")[![warna720](https://avatars.githubusercontent.com/u/2817390?v=4)](https://github.com/warna720 "warna720 (6 commits)")[![pressreset](https://avatars.githubusercontent.com/u/22809021?v=4)](https://github.com/pressreset "pressreset (4 commits)")[![wetfire2k](https://avatars.githubusercontent.com/u/1525536?v=4)](https://github.com/wetfire2k "wetfire2k (2 commits)")[![lukasleitsch](https://avatars.githubusercontent.com/u/3009245?v=4)](https://github.com/lukasleitsch "lukasleitsch (2 commits)")[![bondarenkoid](https://avatars.githubusercontent.com/u/15730984?v=4)](https://github.com/bondarenkoid "bondarenkoid (1 commits)")[![kurorido](https://avatars.githubusercontent.com/u/300858?v=4)](https://github.com/kurorido "kurorido (1 commits)")[![astinaam](https://avatars.githubusercontent.com/u/16185029?v=4)](https://github.com/astinaam "astinaam (1 commits)")[![hazaveh](https://avatars.githubusercontent.com/u/12988865?v=4)](https://github.com/hazaveh "hazaveh (1 commits)")

---

Tags

exploregooglegoogle-apigoogle-trendsrelated-queriestrendingtrending-searchtrendsphpgooglegoogle apiPHP Librarytrendsexploregoogle-trendstrendingrelated-queriestrending-search

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[skagarwal/google-places-api

Google Places Api

1903.3M10](/packages/skagarwal-google-places-api)[aurawindsurfing/google-translate

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

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

PHPackages © 2026

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