jeffersongoncalves / laravel-dataforseo
A Laravel client for the DataForSEO API — SERP, Keywords Data, Backlinks, OnPage, and DataForSEO Labs endpoints.
Package info
github.com/jeffersongoncalves/laravel-dataforseo
pkg:composer/jeffersongoncalves/laravel-dataforseo
Fund package maintenance!
Requires
- php: ^8.2
- illuminate/support: ^12.0|^13.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.21
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel DataForSEO
A Laravel client for the DataForSEO API. A fluent DataForSeo facade groups the SERP, Keywords Data, Backlinks, OnPage, and DataForSEO Labs endpoints behind resource accessors, authenticates every request with HTTP Basic Auth, and throws a DataForSeoException on a non-2xx response instead of returning a silent error array.
Features
- SERP —
serp()->google(),locations(),languages() - Keywords Data —
keywords()->volume(),forSite(),forKeywords(),trends() - Backlinks —
backlinks()->summary(),list(),referringDomains(),anchors(),index() - OnPage —
onPage()->audit() - DataForSEO Labs —
labs()->competitors(),rankedKeywords(),domainIntersection() - Thin by design — every method returns the raw decoded JSON response as an array, no DTOs
- Fails loud — a non-2xx response throws
DataForSeoExceptioncarrying the API's error message and HTTP status code
Installation
composer require jeffersongoncalves/laravel-dataforseo
Optionally publish the config file:
php artisan vendor:publish --tag="dataforseo-config"
Configuration
Add to your .env:
DATAFORSEO_LOGIN=your-login DATAFORSEO_PASSWORD=your-password
Create an account at https://app.dataforseo.com/register to get your login and password.
Config Options
// config/dataforseo.php return [ 'login' => env('DATAFORSEO_LOGIN'), 'password' => env('DATAFORSEO_PASSWORD'), 'base_url' => env('DATAFORSEO_BASE_URL', 'https://api.dataforseo.com/v3'), ];
Usage
use JeffersonGoncalves\DataForSeo\Facades\DataForSeo; use JeffersonGoncalves\DataForSeo\Exceptions\DataForSeoException;
SERP
DataForSeo::serp()->google('laravel', 'United States', 'English'); DataForSeo::serp()->locations(); DataForSeo::serp()->languages();
Keywords Data
DataForSeo::keywords()->volume(['laravel', 'php'], 2840, 'en'); DataForSeo::keywords()->forSite('example.com', 2840, 'en'); DataForSeo::keywords()->forKeywords(['laravel', 'php'], 2840, 'en'); DataForSeo::keywords()->trends(['laravel', 'php'], 2840, 'en');
Backlinks
DataForSeo::backlinks()->summary('example.com'); DataForSeo::backlinks()->list('example.com', 'as_is', 100); DataForSeo::backlinks()->referringDomains('example.com', 100); DataForSeo::backlinks()->anchors('example.com', 100); DataForSeo::backlinks()->index();
OnPage
DataForSeo::onPage()->audit('https://example.com', enableJavascript: true);
DataForSEO Labs
DataForSeo::labs()->competitors('example.com', 2840, 'en', 100); DataForSeo::labs()->rankedKeywords('example.com', 2840, 'en', 100); DataForSeo::labs()->domainIntersection(['example.com', 'rival.com'], 2840, 'en', 100);
Handling errors
try { $result = DataForSeo::serp()->google('laravel'); } catch (DataForSeoException $e) { // $e->getMessage() — the API's status_message/message, or the raw response body // $e->statusCode — the HTTP status code returned by DataForSEO }
Testing
composer test
Static Analysis
composer analyse
Code Formatting
composer format
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
