Skip to content

Commit 6f2c200

Browse files
committed
chore: sync PHP client with Apify OpenAPI spec v2-2026-07-07T132551Z
- Bump API_SPEC_VERSION to v2-2026-07-07T132551Z and CLIENT_VERSION to 0.1.1. - Correct LastRunOptions origin doc comment: origin is now a spec-declared query parameter on the last-run endpoints. - Documentation improvements (StreamInterface/exception/transport notes, PSR-18 usage, runs.md list() defaults, config units).
1 parent 1e45317 commit 6f2c200

6 files changed

Lines changed: 53 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 0.1.1
4+
5+
- Synced to Apify OpenAPI spec `v2-2026-07-07T132551Z`. No public interface changes.
6+
- `origin` is now a spec-declared query parameter on the last-run endpoints; corrected the
7+
`LastRunOptions` doc comment accordingly (behavior unchanged). Kept parity with the reference
8+
client, which does not expose `waitForFinish` on `lastRun`.
9+
310
## 0.1.0
411

512
- Initial PHP client for the Apify API (spec `v2-2026-07-02T131926Z`).

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ $configured = new ApifyClient(
6464
| `publicBaseUrl` | `baseUrl` | Base URL used when building public, shareable resource URLs. |
6565
| `maxRetries` | `8` | Maximum retries for failed requests. |
6666
| `minDelayBetweenRetriesMillis` | `500` | Minimum delay between retries (exponential backoff). |
67-
| `maxDelayBetweenRetriesMillis` | request timeout | Upper bound on the growing inter-retry delay. |
67+
| `maxDelayBetweenRetriesMillis` | `timeoutSecs × 1000` (360000) | Upper bound (milliseconds) on the growing inter-retry delay; defaults to the request timeout expressed in milliseconds. |
6868
| `timeoutSecs` | `360` | Overall per-request timeout. |
6969
| `userAgentSuffix` | `null` | Custom suffix appended to the `User-Agent` header. |
7070
| `httpClient` | Guzzle | The replaceable transport (`Apify\Client\Http\HttpClientInterface`). |
@@ -79,14 +79,19 @@ can wrap any [PSR-18](https://www.php-fig.org/psr/psr-18/) client with `Psr18Htt
7979
your own implementation:
8080

8181
```php
82+
// Use the default Guzzle transport explicitly.
8283
$client = new ApifyClient(token: 'my-api-token', httpClient: new GuzzleHttpClient());
84+
85+
// Or wrap any PSR-18 client (configure its proxy/TLS/timeout on the wrapped client, since
86+
// PSR-18 has no per-request timeout and Psr18HttpClient ignores the client's timeoutSecs).
87+
$psr18 = new \GuzzleHttp\Client(['timeout' => 120]); // any Psr\Http\Message ClientInterface
88+
$client = new ApifyClient(token: 'my-api-token', httpClient: new Psr18HttpClient($psr18));
8389
```
8490

8591
## Error handling
8692

8793
Methods that fetch a single resource return `null` when the resource does not exist (rather than
88-
throwing). Other API failures are thrown as `Apify\Client\Exception\ApifyApiException`, which exposes
89-
the HTTP status, API error `type`, message, attempt count, and request method/path:
94+
throwing). Other API failures are thrown as `Apify\Client\Exception\ApifyApiException`:
9095

9196
```php
9297
try {
@@ -96,6 +101,22 @@ try {
96101
}
97102
```
98103

104+
`ApifyApiException` extends `RuntimeException` and exposes:
105+
106+
| Accessor | Returns |
107+
|---|---|
108+
| `getStatusCode(): int` | HTTP status code of the error response. |
109+
| `getType(): ?string` | Machine-readable API error type (e.g. `"record-not-found"`). |
110+
| `getApiMessage(): string` | Raw API error message, without the status/type prefix. |
111+
| `getMessage(): string` | Formatted message (`apify API error (status …, type …): …`), from `Throwable`. |
112+
| `getAttempt(): int` | 1-based number of the request attempt that produced the error. |
113+
| `getHttpMethod(): string` | HTTP method of the failed call (e.g. `"GET"`). |
114+
| `getPath(): string` | Path of the API endpoint (URL excluding origin). |
115+
| `getData(): ?array` | Additional structured error data provided by the API, if any. |
116+
117+
Transport-level failures (network errors, timeouts) are retried internally; only if every retry is
118+
exhausted does the underlying error surface. Requests are retried on network errors, HTTP 429 and 5xx.
119+
99120
## Versioning
100121

101122
- `Apify\Client\Version::CLIENT_VERSION` — the semantic version of this library.

docs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ use Apify\Client\Model\RequestQueueRequest;
3535
use Apify\Client\Options\BatchAddRequestsOptions;
3636
```
3737

38+
The streaming-log accessors (`LogClient::stream()` and `RunClient::getStreamedLog()`) return the
39+
PSR-7 `Psr\Http\Message\StreamInterface` (from the `psr/http-message` package), not an
40+
`Apify\Client\` type — import it as `use Psr\Http\Message\StreamInterface;`.
41+
3842
Methods that fetch a single resource return `null` when the resource does not exist, rather than
3943
throwing. API failures are thrown as `ApifyApiException` (see [error handling](../README.md#error-handling)).
4044

docs/runs.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Snippets assume `$client = new ApifyClient('my-api-token');` and imported types.
44

55
## Run collection — `$client->runs()`
66

7-
- `list(?ListOptions $options, ?RunListOptions $filter): PaginationList` — list runs.
7+
- `list(?ListOptions $options = null, ?RunListOptions $filter = null): PaginationList` — list runs.
88

99
```php
1010
$page = $client->runs()->list(new ListOptions(limit: 10), new RunListOptions(status: ['SUCCEEDED']));
@@ -31,3 +31,15 @@ $run = $client->run('RUN_ID')->waitForFinish(120);
3131
$client->run('RUN_ID')->charge(new RunChargeOptions(eventName: 'result', count: 3));
3232
$items = $client->run('RUN_ID')->dataset()->listItems();
3333
```
34+
35+
### `waitForFinish` — two distinct meanings
36+
37+
`waitForFinish` appears in two different roles; do not confuse them:
38+
39+
- **`waitForFinish(?int $waitSecs = null)`** — the client-side helper method (on runs and builds). It
40+
polls until the run/build reaches a terminal state, transparently issuing repeated server-side
41+
waits. `$waitSecs` is the total budget in seconds and is **not** capped; `null` waits indefinitely.
42+
For instance, `waitForFinish(300)` waits up to five minutes.
43+
- **The server-side `waitForFinish` parameter**`get(?int $waitForFinishSecs = null)` (and
44+
`defaultBuild()`) and the `waitForFinish` field on `*Options` (e.g. `ActorStartOptions`). This is a
45+
single API-side wait and the server caps it at 60 seconds, so the client clamps larger values.

src/Options/LastRunOptions.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* Filters which "last" run the last-run accessors resolve to. Leave a field {@code null} to leave
99
* that filter unset.
1010
*
11-
* {@code origin} is an Apify-platform convenience exposed by the reference client but not documented
12-
* as a query parameter in the OpenAPI spec; it is included for parity, threaded to the same
13-
* {@code runs/last} endpoint.
11+
* {@code origin} is a query parameter declared on the {@code runs/last} endpoints in the OpenAPI
12+
* spec (alongside {@code status}); it is threaded to that endpoint, matching the reference client's
13+
* {@code lastRun({ status, origin })}.
1414
*/
1515
final class LastRunOptions
1616
{

src/Version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ final class Version
1717
* The semantic version of this client library (see https://semver.org/).
1818
* Changes to the public interface other than additive ones are considered breaking changes.
1919
*/
20-
public const CLIENT_VERSION = '0.1.0';
20+
public const CLIENT_VERSION = '0.1.1';
2121

2222
/**
2323
* The version of the Apify OpenAPI specification this client was generated and verified
2424
* against. Corresponds to the {@code info.version} field of the Apify OpenAPI document.
2525
*/
26-
public const API_SPEC_VERSION = 'v2-2026-07-02T131926Z';
26+
public const API_SPEC_VERSION = 'v2-2026-07-07T132551Z';
2727

2828
private function __construct()
2929
{

0 commit comments

Comments
 (0)