anakin / sdk
Official PHP SDK for the Anakin web-scraping API. Scrape, crawl, search, and run Wire actions with internal job polling.
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.5
Requires (Dev)
- guzzlehttp/psr7: ^2.6
- phpunit/phpunit: ^10.5
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
@anakin-io/sdk— Node.js / TypeScript SDKanakin-sdk— Python SDKgithub.com/Anakin-Inc/anakin-go— Go SDKio.anakin:anakin-sdk— Java SDKanakin-sdk(rubygems) — Ruby SDKAnakin(NuGet) — .NET SDKanakin-sdk(crates.io) — Rust SDK@anakin-io/mcp— Model Context Protocol server for AI agents