anakin/sdk

Official PHP SDK for the Anakin web-scraping API. Scrape, crawl, search, and run Wire actions with internal job polling.

Maintainers

Package info

github.com/Anakin-Inc/anakin-php

Homepage

Documentation

pkg:composer/anakin/sdk

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-04-28 11:02 UTC

This package is not auto-updated.

Last update: 2026-04-28 21:53:08 UTC


README

Official PHP SDK for Anakin — web scraping, crawling, search, and Wire actions.

Status: alpha (v0.1.x). Public API may change between minor versions until v1.0.

Install

composer require anakin/sdk

Requires PHP 8.1+ with ext-curl and ext-json.

Quickstart

<?php
require 'vendor/autoload.php';

use Anakin\Client;

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

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

The SDK polls long-running jobs internally — you get the final result back from a single synchronous method call. No job IDs to manage, no polling loops to write.

Method overview

Method Endpoint Sync?
$client->scrape($url, $opts = []) POST /url-scraper → poll async
$client->map($url, $opts = []) POST /map → poll async
$client->crawl($url, $opts = []) POST /crawl → poll async
$client->search($query, $opts = []) POST /search sync
$client->agenticSearch($prompt, $opts = []) POST /agentic-search → poll async
$client->wire($actionId, $params = []) POST /holocron/task → poll async
$client->sessions()->list/create/save/update/delete /browser-sessions/* various
Anakin\Countries::supported() offline (bundled) sync

Configuration

$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
]);

You can also inject a pre-built Guzzle / PSR-18 client via 'http_client' => $myClient.

Errors

Every error thrown by the SDK is a typed subclass of Anakin\Exception\AnakinException:

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->required}\n";
} catch (AuthenticationException $e) {
    echo "invalid API key — get a fresh one at anakin.io/dashboard\n";
} catch (RateLimitException $e) {
    echo "rate limited; retry after {$e->retryAfter}s\n";
} catch (JobFailedException $e) {
    echo "job failed: {$e->reason}\n";
} catch (AnakinException $e) {
    echo "unknown error: {$e->getMessage()}\n";
}

The exception hierarchy:

Class When
AuthenticationException 401 — invalid or missing API key
InsufficientCreditsException 402 — out of credits ($balance, $required)
InvalidRequestException 400 — validation failure
RateLimitException 429 — after retry budget exhausted ($retryAfter)
JobFailedException Polled job came back with status="failed" ($reason)
JobTimeoutException Polling budget exhausted before terminal status
ServerException 5xx — after retries exhausted
NetworkException DNS / connect / read-timeout
AnakinException Base class; everything above extends it

Develop

git clone https://github.com/Anakin-Inc/anakin-php
cd anakin-php
composer install
composer test

Related packages

License

Apache 2.0