PHPackages                             apify/apify-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. apify/apify-client

ActiveLibrary[API Development](/categories/api)

apify/apify-client
==================

Official, experimental (AI-generated and AI-maintained) Apify API client for PHP: run Actors, manage storages (datasets, key-value stores, request queues), schedules, webhooks and more.

v0.1.0(5d ago)03Apache-2.0PHP &gt;=8.1

Since Jul 5Compare

[ Source](https://github.com/apify/apify-client-php)[ Packagist](https://packagist.org/packages/apify/apify-client)[ Docs](https://github.com/apify/apify-client-php)[ RSS](/packages/apify-apify-client/feed)WikiDiscussions Synced today

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Apify API client for PHP
========================

[](#apify-api-client-for-php)

> **Official, but experimental — AI-generated and AI-maintained.** This is an official Apify client, but it is experimental: it is generated and maintained by AI. Review the code before relying on it in production and report issues on the repository.

A resource-oriented PHP client for the [Apify API](https://docs.apify.com/api/v2), mirroring the official [JavaScript](https://github.com/apify/apify-client-js) reference client: start from an `ApifyClient`, then drill down into resources (Actors, runs, datasets, key-value stores, request queues, tasks, schedules, webhooks, the store, users and logs).

Requirements
------------

[](#requirements)

- PHP 8.1 or newer, with the `json`, `mbstring` and `hash` extensions.

Installation
------------

[](#installation)

```
composer require apify/apify-client
```

Quick start
-----------

[](#quick-start)

All snippets assume the client types are imported from their namespaces, e.g. `use Apify\Client\ApifyClient;`.

```
$client = new ApifyClient('my-api-token');

// Start an Actor and wait for it to finish. The last argument is the wait budget in seconds;
// pass a value (e.g. 120) to bound the wait, or null to wait indefinitely (as here).
$run = $client->actor('apify/hello-world')->call(null, null, null);

// Read items from the run's default dataset.
$items = $client->dataset($run->getDefaultDatasetId())->listItems();
echo 'Item count: ' . $items->getCount() . PHP_EOL;
```

`new ApifyClient('my-api-token')` takes the token as an explicit argument — it does **not** read `APIFY_TOKEN` (or any other environment variable) automatically. Read it yourself if you want that, e.g. `new ApifyClient(getenv('APIFY_TOKEN'))`.

Get your API token from the [Apify Console → Settings → API &amp; Integrations](https://console.apify.com/settings/integrations).

Configuration
-------------

[](#configuration)

The constructor accepts named arguments for non-default settings:

```
$configured = new ApifyClient(
    token: 'my-api-token',
    maxRetries: 5,
    minDelayBetweenRetriesMillis: 1000,
    timeoutSecs: 120,
    userAgentSuffix: 'my-app/1.2.3',
);
```

ArgumentDefaultMeaning`token``null`API token, sent as a Bearer token.`baseUrl``https://api.apify.com`API base URL; the `/v2` suffix is appended automatically.`publicBaseUrl``baseUrl`Base URL used when building public, shareable resource URLs.`maxRetries``8`Maximum retries for failed requests.`minDelayBetweenRetriesMillis``500`Minimum delay between retries (exponential backoff).`maxDelayBetweenRetriesMillis``timeoutSecs × 1000` (360000)Upper bound (milliseconds) on the growing inter-retry delay; defaults to the request timeout expressed in milliseconds.`timeoutSecs``360`Overall per-request timeout.`userAgentSuffix``null`Custom suffix appended to the `User-Agent` header.`httpClient`GuzzleThe replaceable transport (`Apify\Client\Http\HttpClientInterface`).Requests are retried on network errors, HTTP 429 (rate limit) and 5xx responses, with exponential backoff and jitter. 4xx responses (other than 429) are thrown immediately as `ApifyApiException`.

### Replaceable HTTP transport

[](#replaceable-http-transport)

The transport is the `Apify\Client\Http\HttpClientInterface`. The default is `GuzzleHttpClient`; you can wrap any [PSR-18](https://www.php-fig.org/psr/psr-18/) client with `Psr18HttpClient`, or provide your own implementation:

```
// Use the default Guzzle transport explicitly.
$client = new ApifyClient(token: 'my-api-token', httpClient: new GuzzleHttpClient());

// Or wrap any PSR-18 client (configure its proxy/TLS/timeout on the wrapped client, since
// PSR-18 has no per-request timeout and Psr18HttpClient ignores the client's timeoutSecs).
$psr18 = new \GuzzleHttp\Client(['timeout' => 120]); // any Psr\Http\Message ClientInterface
$client = new ApifyClient(token: 'my-api-token', httpClient: new Psr18HttpClient($psr18));
```

Error handling
--------------

[](#error-handling)

Methods that fetch a single resource return `null` when the resource does not exist (rather than throwing). Other API failures are thrown as `Apify\Client\Exception\ApifyApiException`:

```
try {
    $client->actor('does/not-exist')->update(['title' => 'x']);
} catch (ApifyApiException $e) {
    echo $e->getStatusCode() . ' ' . $e->getType() . ': ' . $e->getApiMessage() . PHP_EOL;
}
```

`ApifyApiException` extends `RuntimeException` and exposes:

AccessorReturns`getStatusCode(): int`HTTP status code of the error response.`getType(): ?string`Machine-readable API error type (e.g. `"record-not-found"`).`getApiMessage(): string`Raw API error message, without the status/type prefix.`getMessage(): string`Formatted message (`apify API error (status …, type …): …`), from `Throwable`.`getAttempt(): int`1-based number of the request attempt that produced the error.`getHttpMethod(): string`HTTP method of the failed call (e.g. `"GET"`).`getPath(): string`Path of the API endpoint (URL excluding origin).`getData(): ?array`Additional structured error data provided by the API, if any.Transport-level failures (network errors, timeouts) are retried internally; only if every retry is exhausted does the underlying error surface. Requests are retried on network errors, HTTP 429 and 5xx.

Versioning
----------

[](#versioning)

- `Apify\Client\Version::CLIENT_VERSION` — the semantic version of this library.
- `Apify\Client\Version::API_SPEC_VERSION` — the Apify OpenAPI spec version this client was built against.

```
echo Version::CLIENT_VERSION . ' / ' . Version::API_SPEC_VERSION . PHP_EOL;
```

Documentation
-------------

[](#documentation)

Full documentation lives in [`docs/`](docs/README.md), organized by resource, with runnable [examples](docs/examples.md).

License
-------

[](#license)

[Apache-2.0](LICENSE).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance99

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

5d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebdcfca55fe9fe551b5f550bae6af58ecb0bcb913ddd40c36d2d07c543f7f474?d=identicon)[Pijukatel](/maintainers/Pijukatel)

---

Tags

apiclientautomationcrawlerscrapingactorapify

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/apify-apify-client/health.svg)

```
[![Health](https://phpackages.com/badges/apify-apify-client/health.svg)](https://phpackages.com/packages/apify-apify-client)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.7k](/packages/aws-aws-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M750](/packages/sylius-sylius)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
