PHPackages                             jonasva/laravel-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. [API Development](/categories/api)
4. /
5. jonasva/laravel-google-trends

ActiveLibrary[API Development](/categories/api)

jonasva/laravel-google-trends
=============================

Google trends unofficial api for laravel

8156[1 issues](https://github.com/jonasva/laravel-google-trends/issues)PHP

Since Apr 13Pushed 11y ago3 watchersCompare

[ Source](https://github.com/jonasva/laravel-google-trends)[ Packagist](https://packagist.org/packages/jonasva/laravel-google-trends)[ RSS](/packages/jonasva-laravel-google-trends/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Google Trends unofficial API
====================================

[](#laravel-google-trends-unofficial-api)

Laravel google trends provides an easy way to make queries to Google Trends. It is based on this package: .

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

[](#installation)

To get the latest version of LaravelGoogleTrends require it in your `composer.json` file.

```
"jonasva/laravel-google-trends": "dev-master"

```

Run `composer update jonasva/laravel-google-trends` to install it.

Once LaravelGoogleTrends is installed you need to register its service provider with your application. Open `app/config/app.php` and find the `providers` key.

```
'providers' => array(

    'Jonasva\LaravelGoogleTrends\LaravelGoogleTrendsServiceProvider',

)
```

A Facade for easy access is also included. You can register the facade in the `aliases` key of your `app/config/app.php` file.

```
'aliases' => array(

    'LaravelGoogleTrends' => 'Jonasva\LaravelGoogleTrends\Facades\LaravelGoogleTrends',

)
```

### Publish the configurations

[](#publish-the-configurations)

Run this on the command line from the root of your project:

```
$ php artisan config:publish jonasva/laravel-google-trends

```

A configuration file will be published to `app/config/packages/jonasva/laravel-google-trends/config.php`

### Config

[](#config)

#### Google account credentials

[](#google-account-credentials)

To make Google trends queries, you need to be logged into a google account. If you are not, you will hit the request quota after just a couple of requests. Your account credentials need to filled out in the config file. You also need to have a recovery email setup, as Google sometimes requires it to verify your log in.

#### Cache

[](#cache)

Google trends responses get cached for 1 day by default. You can change this by altering the `api-call-cache-lifetime`.

The Google session you receive after authenticating can be cached as well (which is useful to speed things up). Its cache expiration time can be changed by altering the `session-cache-lifetime`.

Usage
-----

[](#usage)

You can perform any kind of trends query by using this function:

```
    /*
     * Perform a google trends request
     *
     * @param array $parameters
     * @return \Jonasva\GoogleTrends\GoogleTrendsResponse
     */
    public function performRequest(array $parameters)
```

The `$parameters` parameter contains the query conditions.

Example:

```
    // add search terms (optional for topQueries cid)
    $parameters['terms'] = ['term1', 'term2', 'term3'];

    // set a date range (optional)
    $parameters['dateRange']['start'] = (new \DateTime('2015-01-01'))->format('Y-m-d');
    $parameters['dateRange']['end'] = (new \DateTime())->format('Y-m-d');

    // set a location (optional)
    $parameters['location'] = 'BE';

    // set a category id (optional)
    $parameters['category'] = '0-3';

    // set a cid, there are 3 options:
    $parameters['cid'] = 'graph'; // to return time graph data points and labels
    $parameters['cid'] = 'topQueries'; // to return the top queries
    $parameters['cid'] = 'risingQueries'; // to return rising queries

    $response = LaravelGoogleTrends::performRequest($parameters);
```

You can then format the response to a more usable data format:

```
    // to get an array of GoogleTrendsTerm objects
    $response->getTermsObjects();

    // to get formatted data suitable for creating a line chart
    // can only be used with $parameters['cid'] = 'graph'
    $response->getFormattedData();
```

Methods
-------

[](#methods)

Get labels and data points for a graph of 1 or more terms for a given period

```
    /*
     * Get labels and data points for a graph of 1 or more terms for a given period
     *
     * @param \DateTime $startDate
     * @param \DateTime $endDate
     * @param array $terms
     * @param string $location (optional)
     * @param bool $fillEmpties (optional - if true, an array of zeros will be added for terms with no results)
     * @return array
     */
    public function getTermsGraphForPeriod(\DateTime $startDate, \DateTime $endDate, array $terms, $location = null, $fillEmpties = true)
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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