{"id":16761760,"url":"https://github.com/schulzefelix/laravel-search-console","last_synced_at":"2025-07-12T03:07:21.712Z","repository":{"id":22931283,"uuid":"97710032","full_name":"schulzefelix/laravel-search-console","owner":"schulzefelix","description":"A Laravel package to retrieve data from Google Search Console","archived":false,"fork":false,"pushed_at":"2023-10-05T14:43:01.000Z","size":72,"stargazers_count":47,"open_issues_count":1,"forks_count":27,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T09:02:43.319Z","etag":null,"topics":["analytics","google","laravel","php","retrieve-data","search-analytics","search-console","webmaster-tools"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schulzefelix.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-19T11:45:06.000Z","updated_at":"2024-10-17T06:35:42.000Z","dependencies_parsed_at":"2024-06-18T20:10:02.312Z","dependency_job_id":"e7c8863e-5942-4e50-b14c-066be5c9ca9f","html_url":"https://github.com/schulzefelix/laravel-search-console","commit_stats":{"total_commits":63,"total_committers":12,"mean_commits":5.25,"dds":0.5714285714285714,"last_synced_commit":"830513a64ec9edfee1b205029b6be840282c8777"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schulzefelix%2Flaravel-search-console","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schulzefelix%2Flaravel-search-console/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schulzefelix%2Flaravel-search-console/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schulzefelix%2Flaravel-search-console/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schulzefelix","download_url":"https://codeload.github.com/schulzefelix/laravel-search-console/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773726,"owners_count":20993639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","google","laravel","php","retrieve-data","search-analytics","search-console","webmaster-tools"],"created_at":"2024-10-13T04:43:24.945Z","updated_at":"2025-04-08T04:19:14.993Z","avatar_url":"https://github.com/schulzefelix.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Search Console\n\n[![Latest Version](https://img.shields.io/github/release/schulzefelix/laravel-search-console.svg?style=flat-square)](https://github.com/schulzefelix/laravel-search-console/releases)\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![StyleCI](https://styleci.io/repos/97710032/shield)](https://styleci.io/repos/97710032)\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nUsing this package you can easily retrieve data from Google Search Console API.\n\nHere are a few examples of the provided methods:\n\n```php\nuse SearchConsole;\n\n//list all available sites for that token\nSearchConsole::setAccessToken($token)-\u003elistSites();\n\n//get site details (permissionLevel) for specific site\nSearchConsole::setAccessToken($token)-\u003egetSite('http://blog.example.com/');\n```\n\n\n## Install\n\nThis package can be installed through Composer.\n\n``` bash\n$ composer require schulzefelix/laravel-search-console\n```\n\nOptionally, you can publish the config file of this package with this command:\n\n``` bash\nphp artisan vendor:publish --provider=\"SchulzeFelix\\SearchConsole\\SearchConsoleServiceProvider\"\n```\n\nThe following config file will be published in `config/search-console.php`\n\n```php\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Authentication\n    |--------------------------------------------------------------------------\n    | Google offers access via OAuth client IDs or service accounts.\n    | For more information see: https://developers.google.com/identity/protocols/OAuth2\n    |\n    | Supported: \"oauth\", \"oauth_json\", \"service_account\",\n    */\n \n    'auth_type' =\u003e env('GOOGLE_AUTH_TYPE', 'oauth'),\n \n    /*\n    |--------------------------------------------------------------------------\n    | Application Credentials\n    |--------------------------------------------------------------------------\n    |\n    | https://developers.google.com/api-client-library/php/auth/service-accounts#creatinganaccount\n    */\n \n    'connections' =\u003e [\n \n        'oauth' =\u003e [\n            'client_id' =\u003e env('GOOGLE_CLIENT_ID'),\n            'client_secret' =\u003e env('GOOGLE_CLIENT_SECRET'),\n        ],\n \n        'oauth_json' =\u003e [\n            'auth_config' =\u003e storage_path('app/searchconsole/oauth-account-credentials.json'),\n        ],\n \n        'service_account' =\u003e [\n            'application_credentials' =\u003e storage_path('app/searchconsole/service-account-credentials.json'),\n        ],\n \n    ],\n \n    /*\n     |--------------------------------------------------------------------------\n     | Cache Settings\n     |--------------------------------------------------------------------------\n     | Here you may configure the \"store\" that the underlying Google_Client will\n     | use to store it's data.  You may also add extra parameters that will\n     | be passed on setCacheConfig (see docs for google-api-php-client).\n     |\n     | Optional parameters: \"lifetime\", \"prefix\"\n     */\n \n    'cache' =\u003e [\n        'store' =\u003e 'file',\n    ],\n \n    /*\n    |--------------------------------------------------------------------------\n    | Application Name\n    |--------------------------------------------------------------------------\n    */\n \n    'application_name' =\u003e env('SEARCH_CONSOLE_APPLICATION_NAME', 'GSC Agent'),\n];\n```\n\n## Usage\n\nHere are two basic example to retrieve all sites and an export for search analytics data.\n### List Sites\n\n```php\n$sites = SearchConsole::setAccessToken($token)-\u003elistSites();\n```\n\n### Search Analytics\n\n```php\nuse SearchConsole;\nuse SchulzeFelix\\SearchConsole\\Period;\n\n    $data = SearchConsole::setAccessToken($token)-\u003esetQuotaUser('uniqueQuotaUserString')\n        -\u003esearchAnalyticsQuery(\n            'https://www.example.com/',\n            Period::create(Carbon::now()-\u003esubDays(30), Carbon::now()-\u003esubDays(2)),\n            ['query', 'page', 'country', 'device', 'date'],\n            [['dimension' =\u003e 'query', 'operator' =\u003e 'notContains', 'expression' =\u003e 'cheesecake']],\n            1000,\n            'web',\n            'all',\n            'auto'\n        );\n```\n\n## Provided methos\n### Retrieve One Site\n```php\npublic function public function getSite(string $siteUrl): array\n```\n\n### Retrieve All Sites\n```php\npublic function public function listSites(): Collection\n```\n\n### Retrieve Search Analytics Data\n```php\npublic function searchAnalyticsQuery(string $siteUrl, Period $period, array $dimensions = [], array $filters = [], int $rows = 1000, string $searchType = 'web', string $dataState = 'final', string $aggregationType = 'auto'): Collection\n```\n\n### Check Access Token\n```php\npublic function public function isAccessTokenExpired(): Bool\n```\n\n## Provided fluent configuration\n\n### Set Access Token (Required)\n\n```php\n$sites = SearchConsole::setAccessToken($token)-\u003elistSites();\n```\n\n### Set Quota User\nTo avoid to the API limits, you can provide a unique string for the authenticated account.\n\nMore information: https://developers.google.com/webmaster-tools/search-console-api-original/v3/limits\n```php\n$sites = SearchConsole::setAccessToken($token)-\u003esetQuotaUser('uniqueQuotaUserString')-\u003elistSites();\n```\n\n## Get Underlying Service\nYou can get access to the underlying `Google_Service_Webmasters` object:\n\n```php\nSearchConsole::getWebmastersService();\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ vendor/bin/phpunit\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email github@schulze.co instead of using the issue tracker.\n\n## Credits\n\n- [Felix Schulze][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/schulzefelix/laravel-search-console.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/schulzefelix/laravel-search-console/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/schulzefelix/laravel-search-console.svg?style=flat-square\n[ico-code-quality]: https://scrutinizer-ci.com/g/schulzefelix/laravel-search-console/badges/quality-score.png?b=master\n[ico-downloads]: https://img.shields.io/packagist/dt/schulzefelix/laravel-search-console.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/schulzefelix/laravel-search-console\n[link-travis]: https://travis-ci.org/schulzefelix/laravel-search-console\n[link-scrutinizer]: https://scrutinizer-ci.com/g/schulzefelix/laravel-search-console/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/schulzefelix/laravel-search-console\n[link-downloads]: https://packagist.org/packages/schulzefelix/laravel-search-console\n[link-author]: https://github.com/schulzefelix\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschulzefelix%2Flaravel-search-console","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschulzefelix%2Flaravel-search-console","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschulzefelix%2Flaravel-search-console/lists"}