{"id":51867280,"url":"https://github.com/apify/apify-client-php","last_synced_at":"2026-07-24T18:00:58.186Z","repository":{"id":370894381,"uuid":"1287964818","full_name":"apify/apify-client-php","owner":"apify","description":"Apify API client for PHP—Programmatically run Actors, manage and stream data from storages (datasets, key-value stores, request queues), schedule and monitor runs, and access the full Apify platform API. Sync and async interfaces with automatic retries and pagination. ","archived":false,"fork":false,"pushed_at":"2026-07-11T19:34:33.000Z","size":139,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-07-11T20:06:48.806Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/apify/apify-client","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apify.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-07-03T06:44:27.000Z","updated_at":"2026-07-10T10:55:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/apify/apify-client-php","commit_stats":null,"previous_names":["apify/apify-client-php"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/apify/apify-client-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fapify-client-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fapify-client-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fapify-client-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fapify-client-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apify","download_url":"https://codeload.github.com/apify/apify-client-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apify%2Fapify-client-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35850518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-24T02:00:07.870Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-24T18:00:56.901Z","updated_at":"2026-07-24T18:00:58.174Z","avatar_url":"https://github.com/apify.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apify API client for PHP\n\n\u003e **Official, but experimental — AI-generated and AI-maintained.** This is an official Apify client,\n\u003e but it is experimental: it is generated and maintained by AI. Review the code before relying on it\n\u003e in production and report issues on the repository.\n\nA resource-oriented PHP client for the [Apify API](https://docs.apify.com/api/v2), mirroring the\nofficial [JavaScript](https://github.com/apify/apify-client-js) reference client: start from an\n`ApifyClient`, then drill down into resources (Actors, runs, datasets, key-value stores, request\nqueues, tasks, schedules, webhooks, the store, users and logs).\n\n## Requirements\n\n- PHP 8.1 or newer, with the `json`, `mbstring` and `hash` extensions.\n\n## Installation\n\n```bash\ncomposer require apify/apify-client\n```\n\n## Quick start\n\nAll snippets assume the client types are imported from their namespaces, e.g.\n`use Apify\\Client\\ApifyClient;`.\n\n```php\n$client = new ApifyClient('my-api-token');\n\n// Start an Actor and wait for it to finish. The last argument is the wait budget in seconds;\n// pass a value (e.g. 120) to bound the wait, or null to wait indefinitely (as here).\n$run = $client-\u003eactor('apify/hello-world')-\u003ecall(null, null, null);\n\n// Read items from the run's default dataset. getDefaultDatasetId() is ?string, so cast it\n// to satisfy dataset(string $id).\n$items = $client-\u003edataset((string) $run-\u003egetDefaultDatasetId())-\u003elistItems();\necho 'Item count: ' . $items-\u003egetCount() . PHP_EOL;\n```\n\n`new ApifyClient('my-api-token')` takes the token as an explicit argument — it does **not** read\n`APIFY_TOKEN` (or any other environment variable) automatically. Read it yourself if you want that,\ne.g. `new ApifyClient(getenv('APIFY_TOKEN'))`.\n\nGet your API token from the\n[Apify Console → Settings → API \u0026 Integrations](https://console.apify.com/settings/integrations).\n\n## Configuration\n\nThe constructor accepts named arguments for non-default settings:\n\n```php\n$configured = new ApifyClient(\n    token: 'my-api-token',\n    baseUrl: 'https://api.apify.com',\n    maxRetries: 5,\n    minDelayBetweenRetriesMillis: 1000,\n    timeoutSecs: 120,\n    userAgentSuffix: 'my-app/1.2.3',\n);\n```\n\n| Argument | Default | Meaning |\n|---|---|---|\n| `token` | `null` | API token, sent as a Bearer token. |\n| `baseUrl` | `https://api.apify.com` | API base URL; the `/v2` suffix is appended automatically. |\n| `publicBaseUrl` | `baseUrl` | Base URL used when building public, shareable resource URLs. |\n| `maxRetries` | `8` | Maximum retries for failed requests. |\n| `minDelayBetweenRetriesMillis` | `500` | Minimum delay between retries (exponential backoff). |\n| `maxDelayBetweenRetriesMillis` | `timeoutSecs × 1000` (360000) | Upper bound (milliseconds) on the growing inter-retry delay; defaults to the request timeout expressed in milliseconds. |\n| `timeoutSecs` | `360` | Overall per-request timeout. |\n| `userAgentSuffix` | `null` | Custom suffix appended to the `User-Agent` header. |\n| `httpClient` | Guzzle | The replaceable transport (`Apify\\Client\\Http\\HttpClientInterface`). |\n\nRequests are retried on network errors, HTTP 429 (rate limit) and 5xx responses, with exponential\nbackoff and jitter. Other 4xx responses are thrown immediately as `ApifyApiException`, with one\nexception: a resource-not-found 404 (the API's `record-not-found` / `record-or-token-not-found`\nerror type) on a single-resource fetch is not thrown — `get()` returns `null` and `delete()` is\ntreated as a successful no-op (see [Error handling](#error-handling)).\n\n### Replaceable HTTP transport\n\nThe transport is the `Apify\\Client\\Http\\HttpClientInterface`. The default is `GuzzleHttpClient`; you\ncan wrap any [PSR-18](https://www.php-fig.org/psr/psr-18/) client with `Psr18HttpClient`, or provide\nyour own implementation:\n\n```php\n// Use the default Guzzle transport explicitly.\n$client = new ApifyClient(token: 'my-api-token', httpClient: new GuzzleHttpClient());\n\n// Or wrap any PSR-18 client (configure its proxy/TLS/timeout on the wrapped client, since\n// PSR-18 has no per-request timeout and Psr18HttpClient ignores the client's timeoutSecs).\n$psr18 = new \\GuzzleHttp\\Client(['timeout' =\u003e 120]); // any Psr\\Http\\Message ClientInterface\n$client = new ApifyClient(token: 'my-api-token', httpClient: new Psr18HttpClient($psr18));\n```\n\n## Error handling\n\nMethods that fetch a single resource return `null` when the resource does not exist (rather than\nthrowing). Other API failures are thrown as `Apify\\Client\\Exception\\ApifyApiException`:\n\n```php\ntry {\n    $client-\u003eactor('does/not-exist')-\u003eupdate(['title' =\u003e 'x']);\n} catch (ApifyApiException $e) {\n    echo $e-\u003egetStatusCode() . ' ' . $e-\u003egetType() . ': ' . $e-\u003egetApiMessage() . PHP_EOL;\n}\n```\n\n`ApifyApiException` extends `RuntimeException` and exposes:\n\n| Accessor | Returns |\n|---|---|\n| `getStatusCode(): int` | HTTP status code of the error response. |\n| `getType(): ?string` | Machine-readable API error type (e.g. `\"record-not-found\"`). |\n| `getApiMessage(): string` | Raw API error message, without the status/type prefix. |\n| `getMessage(): string` | Formatted message (`apify API error (status …, type …): …`), from `Throwable`. |\n| `getAttempt(): int` | 1-based number of the request attempt that produced the error. |\n| `getHttpMethod(): string` | HTTP method of the failed call (e.g. `\"GET\"`). |\n| `getPath(): string` | Path of the API endpoint (URL excluding origin). |\n| `getData(): ?array` | Additional structured error data provided by the API, if any. |\n\nTransport-level failures (network errors, timeouts) are retried internally; only if every retry is\nexhausted does the underlying error surface, as an `Apify\\Client\\Exception\\TransportException`\n(a `RuntimeException`; `isTimeout()` reports whether a request timed out). In short:\n`ApifyApiException` means the server returned an error response (a 4xx/5xx with a body), whereas\n`TransportException` means the request never produced a usable response (network failure or timeout)\nafter all retries. Requests are retried on network errors, HTTP 429 and 5xx.\n\n## Versioning\n\n- `Apify\\Client\\Version::CLIENT_VERSION` — the semantic version of this library.\n- `Apify\\Client\\Version::API_SPEC_VERSION` — the Apify OpenAPI spec version this client was built\n  against.\n\n```php\necho Version::CLIENT_VERSION . ' / ' . Version::API_SPEC_VERSION . PHP_EOL;\n```\n\n## Documentation\n\nFull documentation lives in [`docs/`](docs/README.md), organized by resource, with runnable\n[examples](docs/examples.md).\n\n## License\n\n[Apache-2.0](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapify%2Fapify-client-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapify%2Fapify-client-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapify%2Fapify-client-php/lists"}