PHP code example of anakin / sdk

1. Go to this page and download the library: Download anakin/sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anakin / sdk example snippets



Anakin\Client;

$client = new Client(['api_key' => 'ak-...']);  // or set ANAKIN_API_KEY

$doc = $client->scrape('https://example.com');
echo $doc['markdown'];

$client = new Anakin\Client([
    'api_key' => 'ak-...',                       // or ANAKIN_API_KEY env var
    'base_url' => 'https://api.anakin.io/v1',
    'timeout' => 60,                             // per-request seconds
    'max_retries' => 4,                          // on 429 / 5xx / transient
    'poll_interval' => 1.0,                      // initial polling delay
    'poll_max_interval' => 10.0,                 // capped backoff
    'poll_timeout' => 300,                       // total poll budget
]);

use Anakin\Exception\{
    AuthenticationException,
    InsufficientCreditsException,
    RateLimitException,
    JobFailedException,
    AnakinException
};

try {
    $doc = $client->scrape('https://example.com');
} catch (InsufficientCreditsException $e) {
    echo "out of credits: balance={$e->balance}, needed={$e->nknown error: {$e->getMessage()}\n";
}
bash
git clone https://github.com/Anakin-Inc/anakin-php
cd anakin-php
composer install
composer test