### Install the package with Composer Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Run this command to install the jeffersongoncalves/laravel-dataforseo package via Composer. ```bash composer require jeffersongoncalves/laravel-dataforseo ``` -------------------------------- ### Adding a resource method to a resource class Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Example of a resource method that delegates to the client's post() method, wrapping the body in an outer array per DataForSEO's tasks convention. ```php public function summary(string $target): array { return $this->client->post('/backlinks/summary/live', [[ 'target' => $target, 'backlinks_status_type' => 'live', ]]); } ``` -------------------------------- ### GET /v3/serp/languages Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves the list of supported SERP languages. ```APIDOC ## [GET] /v3/serp/languages ### Description Retrieves the list of supported SERP languages. ### Method GET ### Endpoint /v3/serp/languages ### Response #### Success Response (200) - **tasks** (array) - Array of language data. #### Response Example { "tasks": [] } ``` -------------------------------- ### GET /v3/backlinks/summary/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves backlink summary for a target domain. ```APIDOC ## [GET] /v3/backlinks/summary/live ### Description Retrieves backlink summary for a target domain. ### Method GET ### Endpoint /v3/backlinks/summary/live ### Parameters #### Query Parameters - **target** (string) - Required - The domain or URL. ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### GET /v3/serp/locations Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves the list of supported SERP locations. ```APIDOC ## [GET] /v3/serp/locations ### Description Retrieves the list of supported SERP locations. ### Method GET ### Endpoint /v3/serp/locations ### Response #### Success Response (200) - **tasks** (array) - Array of location data. #### Response Example { "tasks": [] } ``` -------------------------------- ### GET /v3/backlinks/referring_domains/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves referring domains for a target domain. ```APIDOC ## [GET] /v3/backlinks/referring_domains/live ### Description Retrieves referring domains for a target domain. ### Method GET ### Endpoint /v3/backlinks/referring_domains/live ### Parameters #### Query Parameters - **target** (string) - Required - The domain or URL. - **limit** (integer) - Optional - The number of results (e.g., 100). ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### GET /v3/backlinks/index/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves the backlinks index status. ```APIDOC ## [GET] /v3/backlinks/index/live ### Description Retrieves the backlinks index status. ### Method GET ### Endpoint /v3/backlinks/index/live ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### GET /v3/backlinks/anchors/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves anchor texts for a target domain. ```APIDOC ## [GET] /v3/backlinks/anchors/live ### Description Retrieves anchor texts for a target domain. ### Method GET ### Endpoint /v3/backlinks/anchors/live ### Parameters #### Query Parameters - **target** (string) - Required - The domain or URL. - **limit** (integer) - Optional - The number of results (e.g., 100). ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### GET /v3/backlinks/list/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves a list of backlinks for a target domain. ```APIDOC ## [GET] /v3/backlinks/list/live ### Description Retrieves a list of backlinks for a target domain. ### Method GET ### Endpoint /v3/backlinks/list/live ### Parameters #### Query Parameters - **target** (string) - Required - The domain or URL. - **mode** (string) - Optional - The mode (e.g., "as_is"). - **limit** (integer) - Optional - The number of results (e.g., 100). ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### Service provider configuration and binding Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Configures the package name and config file, and registers the DataForSeoClient as a singleton with an alias. ```php public function configurePackage(Package $package): void { $package ->name('dataforseo') ->hasConfigFile(); } public function packageRegistered(): void { $this->app->singleton(DataForSeoClient::class); $this->app->alias(DataForSeoClient::class, 'dataforseo'); } ``` -------------------------------- ### Run static analysis with composer analyse Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Run static analysis. ```bash composer analyse ``` -------------------------------- ### Run development commands for DataForSEO package Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Common development commands: run tests with Pest, static analysis with PHPStan level 5 + Larastan, and code formatting with Pint using the Laravel preset. ```bash # Run tests vendor/bin/pest # Run static analysis (PHPStan level 5 + Larastan) vendor/bin/phpstan analyse # Format code (Pint, Laravel preset) vendor/bin/pint ``` -------------------------------- ### Import DataForSeo facade and exception Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Import the DataForSeo facade and exception class. ```php use JeffersonGoncalves\DataForSeo\Facades\DataForSeo; use JeffersonGoncalves\DataForSeo\Exceptions\DataForSeoException; ``` -------------------------------- ### Configure DataForSEO credentials in .env Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Add your DataForSEO credentials to the .env file. ```env DATAFORSEO_LOGIN=your-login DATAFORSEO_PASSWORD=your-password ``` -------------------------------- ### Run code formatting with composer format Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Run code formatting. ```bash composer format ``` -------------------------------- ### POST /v3/dataforseo_labs/competitors/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves competitors for a target domain. ```APIDOC ## [POST] /v3/dataforseo_labs/competitors/live ### Description Retrieves competitors for a target domain. ### Method POST ### Endpoint /v3/dataforseo_labs/competitors/live ### Parameters #### Request Body - **target** (string) - Required - The domain or URL. - **location_code** (integer) - Required - Location code. - **language_code** (string) - Required - Language code. - **limit** (integer) - Optional - The number of results (e.g., 100). ### Request Example { "target": "example.com", "location_code": 2840, "language_code": "en", "limit": 100 } ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### Configure DataForSEO package Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Configuration file for the DataForSEO package. Sets login, password, and base URL from environment variables, with a default base URL of 'https://api.dataforseo.com/v3'. ```php // config/dataforseo.php return [ 'login' => env('DATAFORSEO_LOGIN'), 'password' => env('DATAFORSEO_PASSWORD'), 'base_url' => env('DATAFORSEO_BASE_URL', 'https://api.dataforseo.com/v3'), ]; ``` -------------------------------- ### POST /v3/serp/google/organic/live/advanced Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Performs a Google SERP search using the DataForSEO API. ```APIDOC ## [POST] /v3/serp/google/organic/live/advanced ### Description Performs a Google SERP search for the given keyword, location, and language. ### Method POST ### Endpoint /v3/serp/google/organic/live/advanced ### Parameters #### Request Body - **keyword** (string) - Required - The search query. - **location_name** (string) - Optional - The location name (e.g., "United States"). - **language_name** (string) - Optional - The language name (e.g., "English"). ### Request Example { "keyword": "laravel", "location_name": "United States", "language_name": "English" } ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### Publish the DataForSEO config file Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Publishes the package configuration file using the dataforseo-config tag. ```bash php artisan vendor:publish --tag=dataforseo-config ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Run the test suite. ```bash composer test ``` -------------------------------- ### Namespace structure of the package Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Shows the directory and namespace layout for the package's main components. ```text JeffersonGoncalves\DataForSeo\ DataForSeoServiceProvider # Registers the config file, binds the client DataForSeoClient # Builds the authenticated HTTP request, decodes JSON, throws on failure Facades\ DataForSeo # Facade accessor: 'dataforseo' Resources\ Serp # /serp/google/* Keywords # /keywords_data/* Backlinks # /backlinks/* OnPage # /on_page/* Labs # /dataforseo_labs/* Exceptions\ DataForSeoException # Thrown on a non-2xx response ``` -------------------------------- ### POST /v3/keywords_data/google_ads/keywords_for_site/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves keywords for a given site. ```APIDOC ## [POST] /v3/keywords_data/google_ads/keywords_for_site/live ### Description Retrieves keywords for a given site. ### Method POST ### Endpoint /v3/keywords_data/google_ads/keywords_for_site/live ### Parameters #### Request Body - **target** (string) - Required - The domain or URL. - **location_code** (integer) - Required - Location code. - **language_code** (string) - Required - Language code. ### Request Example { "target": "example.com", "location_code": 2840, "language_code": "en" } ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### POST /v3/dataforseo_labs/ranked_keywords/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves ranked keywords for a target domain. ```APIDOC ## [POST] /v3/dataforseo_labs/ranked_keywords/live ### Description Retrieves ranked keywords for a target domain. ### Method POST ### Endpoint /v3/dataforseo_labs/ranked_keywords/live ### Parameters #### Request Body - **target** (string) - Required - The domain or URL. - **location_code** (integer) - Required - Location code. - **language_code** (string) - Required - Language code. - **limit** (integer) - Optional - The number of results (e.g., 100). ### Request Example { "target": "example.com", "location_code": 2840, "language_code": "en", "limit": 100 } ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### Environment variables for DataForSEO Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Set these environment variables to configure the DataForSEO client login, password, and base URL. ```env DATAFORSEO_LOGIN=your-login DATAFORSEO_PASSWORD=your-password DATAFORSEO_BASE_URL=https://api.dataforseo.com/v3 ``` -------------------------------- ### DataForSeo facade usage for SERP, keywords, backlinks, on-page, and labs Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Shows the public API methods available through the DataForSeo facade. Each method returns the raw decoded JSON body as array; there are no DTOs. ```php use JeffersonGoncalves\DataForSeo\Facades\DataForSeo; DataForSeo::serp()->google('laravel', 'United States', 'English'); DataForSeo::serp()->locations(); DataForSeo::serp()->languages(); DataForSeo::keywords()->volume(['laravel', 'php'], 2840, 'en'); DataForSeo::keywords()->forSite('example.com', 2840, 'en'); DataForSeo::keywords()->forKeywords(['laravel'], 2840, 'en'); DataForSeo::keywords()->trends(['laravel'], 2840, 'en'); 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(); DataForSeo::onPage()->audit('https://example.com', true); 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); ``` -------------------------------- ### POST /v3/keywords_data/google_ads/search_volume/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves search volume data for a list of keywords. ```APIDOC ## [POST] /v3/keywords_data/google_ads/search_volume/live ### Description Retrieves search volume data for a list of keywords. ### Method POST ### Endpoint /v3/keywords_data/google_ads/search_volume/live ### Parameters #### Request Body - **keywords** (array of strings) - Required - List of keywords. - **location_code** (integer) - Required - Location code (e.g., 2840 for United States). - **language_code** (string) - Required - Language code (e.g., "en"). ### Request Example { "keywords": ["laravel", "php"], "location_code": 2840, "language_code": "en" } ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### POST /v3/dataforseo_labs/domain_intersection/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves domain intersection data for a list of domains. ```APIDOC ## [POST] /v3/dataforseo_labs/domain_intersection/live ### Description Retrieves domain intersection data for a list of domains. ### Method POST ### Endpoint /v3/dataforseo_labs/domain_intersection/live ### Parameters #### Request Body - **targets** (array of strings) - Required - List of domains. - **location_code** (integer) - Required - Location code. - **language_code** (string) - Required - Language code. - **limit** (integer) - Optional - The number of results (e.g., 100). ### Request Example { "targets": ["example.com", "rival.com"], "location_code": 2840, "language_code": "en", "limit": 100 } ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### POST /v3/keywords_data/google_ads/keywords_for_keywords/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves keywords related to a list of keywords. ```APIDOC ## [POST] /v3/keywords_data/google_ads/keywords_for_keywords/live ### Description Retrieves keywords related to a list of keywords. ### Method POST ### Endpoint /v3/keywords_data/google_ads/keywords_for_keywords/live ### Parameters #### Request Body - **keywords** (array of strings) - Required - List of keywords. - **location_code** (integer) - Required - Location code. - **language_code** (string) - Required - Language code. ### Request Example { "keywords": ["laravel", "php"], "location_code": 2840, "language_code": "en" } ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### POST /v3/keywords_data/google_ads/keywords_for_keywords/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Retrieves keyword trends for a list of keywords. ```APIDOC ## [POST] /v3/keywords_data/google_ads/keywords_for_keywords/live ### Description Retrieves keyword trends for a list of keywords. ### Method POST ### Endpoint /v3/keywords_data/google_ads/keywords_for_keywords/live ### Parameters #### Request Body - **keywords** (array of strings) - Required - List of keywords. - **location_code** (integer) - Required - Location code. - **language_code** (string) - Required - Language code. ### Request Example { "keywords": ["laravel", "php"], "location_code": 2840, "language_code": "en" } ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### POST /v3/on_page/audit/live Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Performs an on-page audit for a given URL. ```APIDOC ## [POST] /v3/on_page/audit/live ### Description Performs an on-page audit for a given URL. ### Method POST ### Endpoint /v3/on_page/audit/live ### Parameters #### Request Body - **target** (string) - Required - The URL to audit. - **enable_javascript** (boolean) - Optional - Whether to enable JavaScript rendering. ### Request Example { "target": "https://example.com", "enable_javascript": true } ### Response #### Success Response (200) - **tasks** (array) - Array of task results. #### Response Example { "tasks": [] } ``` -------------------------------- ### Assert the request payload sent to DataForSEO Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Uses Http::assertSent to verify that the request payload contains a keyword 'laravel' in the first element of the data array. Note that every POST body is wrapped in an outer array. ```php use Illuminate\Http\Client\Request; Http::assertSent(fn (Request $request) => $request->data()[0]['keyword'] === 'laravel'); ``` -------------------------------- ### SERP endpoints usage Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Access SERP endpoints: google search, locations, and languages. ```php DataForSeo::serp()->google('laravel', 'United States', 'English'); DataForSeo::serp()->locations(); DataForSeo::serp()->languages(); ``` -------------------------------- ### DataForSeoClient::handle() error handling with DataForSeoException Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Shows the internal handle() method that throws DataForSeoException when the response fails. The exception message prefers status_message, then message, then the raw body. DataForSeoException::$statusCode carries the HTTP status. ```php private function handle(Response $response): array { if ($response->failed()) { throw new DataForSeoException($this->errorMessage($response), $response->status()); } $data = $response->json(); return is_array($data) ? $data : []; } ``` -------------------------------- ### Assert a DataForSEO exception is thrown Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Pest test that fakes a 401 response for the SERP endpoint and asserts that a DataForSeoException is thrown with the message 'Invalid Login/Password.'. ```php use JeffersonGoncalves\DataForSeo\Exceptions\DataForSeoException; it('throws on a non-2xx response', function () { Http::fake([ 'api.dataforseo.com/v3/serp/google/organic/live/regular' => Http::response(['status_message' => 'Invalid Login/Password.'], 401), ]); expect(fn () => DataForSeo::serp()->google('laravel')) ->toThrow(DataForSeoException::class, 'Invalid Login/Password.'); }); ``` -------------------------------- ### Keywords Data endpoints usage Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Access Keywords Data endpoints: volume, forSite, forKeywords, and trends. ```php 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'); ``` -------------------------------- ### Mock a DataForSEO backlinks summary response Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/resources/boost/skills/dataforseo-development/SKILL.md Pest test that fakes the HTTP response for the backlinks summary endpoint and asserts the returned data. Uses Laravel's Http facade to fake the request. ```php use Illuminate\Support\Facades\Http; use JeffersonGoncalves\DataForSeo\Facades\DataForSeo; it('fetches a backlinks summary', function () { Http::fake([ 'api.dataforseo.com/v3/backlinks/summary/live' => Http::response(['status_code' => 20000], 200), ]); expect(DataForSeo::backlinks()->summary('example.com'))->toBe(['status_code' => 20000]); }); ``` -------------------------------- ### Backlinks endpoints usage Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Access Backlinks endpoints: summary, list, referringDomains, anchors, and index. ```php 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 audit usage Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Run an OnPage audit with JavaScript enabled. ```php DataForSeo::onPage()->audit('https://example.com', enableJavascript: true); ``` -------------------------------- ### Handle DataForSeoException Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Handle DataForSeoException thrown on non-2xx responses. Access the API error message via getMessage() and the HTTP status code via statusCode. ```php 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 } ``` -------------------------------- ### DataForSEO Labs endpoints usage Source: https://github.com/jeffersongoncalves/laravel-dataforseo/blob/main/README.md Access DataForSEO Labs endpoints: competitors, rankedKeywords, and domainIntersection. ```php 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); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.