SDK for Serpstat API v3

1.1.0 2018-07-26 12:17 UTC

This package is auto-updated.

Last update: 2024-10-29 03:38:08 UTC


README

Serpstat

This is the official SDK library for the Serpstat API v3

Getting Started

Step 1: Create authentication token

API Serpstat uses the User Token to authenticate requests. You can create a token on your profile page.

Step 2: Install the Package

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require serpstat/sdk

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 3: Use in application

<?php
require_once __DIR__ . '/../vendor/autoload.php';

// configure your application
$config = [
    'token' => '19666fc1ae1724da1d5ea2f3a99d5f5a',
];

$domain = 'example.com';
$keywords = 'keywords';
$url = 'http://example.com/page1/';

// init client with your serpstat api token
$apiClient = new \Serpstat\Sdk\Core\ApiGuzzleHttpClient($config['token']);

// create instance of any api method class
// e.g. DomainKeywordsMethod
// list of methods classes in folder src\Methods
$apiMethod = new \Serpstat\Sdk\Methods\DomainKeywordsMethod(
    $keywords, 
    \Serpstat\Sdk\Interfaces\IApiClient::SE_GOOGLE_RU
);

try {
    // try call api method
    $response = $apiClient->call($apiMethod);
} catch (\Exception $e) {
    // catch api error 
    $response = $e->getMessage();
}

List of SDK API methods

SDK Exceptions