Skip to content

Commit f21aa3e

Browse files
committed
docs: align nullable-id casts, add ApifyClient methods table, clarify runnable guarantee
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019rkZYoebybdnv7MFH9Ua6E
1 parent 08b0709 commit f21aa3e

3 files changed

Lines changed: 51 additions & 8 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ $client = new ApifyClient('my-api-token');
3131
// pass a value (e.g. 120) to bound the wait, or null to wait indefinitely (as here).
3232
$run = $client->actor('apify/hello-world')->call(null, null, null);
3333

34-
// Read items from the run's default dataset.
35-
$items = $client->dataset($run->getDefaultDatasetId())->listItems();
34+
// Read items from the run's default dataset. getDefaultDatasetId() is ?string, so cast it
35+
// to satisfy dataset(string $id).
36+
$items = $client->dataset((string) $run->getDefaultDatasetId())->listItems();
3637
echo 'Item count: ' . $items->getCount() . PHP_EOL;
3738
```
3839

docs/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,44 @@ PSR-7 `Psr\Http\Message\StreamInterface` (from the `psr/http-message` package),
4242
Methods that fetch a single resource return `null` when the resource does not exist, rather than
4343
throwing. API failures are thrown as `ApifyApiException` (see [error handling](../README.md#error-handling)).
4444

45+
## ApifyClient methods
46+
47+
`ApifyClient` is the entry point: construct one, then call an accessor to get a sub-client for a
48+
specific resource or collection. Single-resource accessors take an ID (or, where the API allows it,
49+
a name) and return that resource's client; collection accessors take no arguments and return a
50+
collection client for listing and creating. Method detail lives on the linked [resource
51+
pages](#resource-pages); the signatures below are the entry points.
52+
53+
| Method | Returns | Notes |
54+
|---|---|---|
55+
| `actor(string $id): ActorClient` | Actor client | Single Actor, by ID or `username/name`. |
56+
| `actors(): ActorCollectionClient` | Actor collection | List and create Actors. |
57+
| `build(string $id): BuildClient` | Build client | Single Actor build. |
58+
| `builds(): BuildCollectionClient` | Build collection | List builds across Actors. |
59+
| `run(string $id): RunClient` | Run client | Single Actor run. |
60+
| `runs(): RunCollectionClient` | Run collection | List runs across Actors. |
61+
| `dataset(string $id): DatasetClient` | Dataset client | Single dataset, by ID or name. |
62+
| `datasets(): DatasetCollectionClient` | Dataset collection | List and create datasets. |
63+
| `keyValueStore(string $id): KeyValueStoreClient` | Key-value store client | Single store, by ID or name. |
64+
| `keyValueStores(): KeyValueStoreCollectionClient` | Key-value store collection | List and create stores. |
65+
| `requestQueue(string $id, ?RequestQueueClientOptions $options = null): RequestQueueClient` | Request queue client | Single queue, by ID or name; optional client options (`clientKey`, per-request `timeoutSecs`). |
66+
| `requestQueues(): RequestQueueCollectionClient` | Request queue collection | List and create queues. |
67+
| `task(string $id): TaskClient` | Task client | Single task. |
68+
| `tasks(): TaskCollectionClient` | Task collection | List and create tasks. |
69+
| `schedule(string $id): ScheduleClient` | Schedule client | Single schedule. |
70+
| `schedules(): ScheduleCollectionClient` | Schedule collection | List and create schedules. |
71+
| `webhook(string $id): WebhookClient` | Webhook client | Single webhook. |
72+
| `webhooks(): WebhookCollectionClient` | Webhook collection | List and create webhooks. |
73+
| `webhookDispatch(string $id): WebhookDispatchClient` | Webhook dispatch client | Single webhook dispatch. |
74+
| `webhookDispatches(): WebhookDispatchCollectionClient` | Webhook dispatch collection | List webhook dispatches. |
75+
| `store(): StoreCollectionClient` | Store collection | Browse the public Apify Store. |
76+
| `log(string $buildOrRunId): LogClient` | Log client | Log for a build or run, by ID. |
77+
| `me(): UserClient` | User client | The authenticated user (`users/me`). |
78+
| `user(string $id): UserClient` | User client | A public user profile, by ID. |
79+
| `setStatusMessage(string $message, bool $isTerminal = false): ActorRun` | Updated run | Set the current run's status message; see [Setting single-resource status](#setting-single-resource-status). |
80+
| `getUserAgent(): string` | User-Agent string | The `User-Agent` the client sends. |
81+
| `getApiBaseUrl(): string` | Base URL | The resolved API base URL (with `/v2`). |
82+
4583
## Models and unmodeled data (`toArray`)
4684

4785
Response models expose the commonly-used fields as typed getters (e.g. `$actor->getId()`). The

docs/examples.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
Each snippet below assumes a configured `$client` and that the types it uses are imported with the
44
appropriate `use` statements (see [Namespaces](README.md#namespaces)); the first
55
[complete program](#a-complete-standalone-program) shows the full scaffolding the shorter snippets
6-
omit for brevity. The same programs live under [`tests/Examples/`](../tests/Examples) and are executed
7-
end-to-end against the live API by the `Test examples` CI step (see `ExamplesTest`), so they are
8-
guaranteed to stay runnable.
6+
omit for brevity. The complete programs on this page live under
7+
[`tests/Examples/`](../tests/Examples) and are executed end-to-end against the live API by the
8+
`Test examples` CI step (see `ExamplesTest`), so those programs are guaranteed to stay runnable.
9+
Inline snippets on the other documentation pages are not executed: they are only syntax-checked with
10+
`php -l` by `DocSnippetsTest`, which catches parse errors but does not resolve classes or check types.
911

1012
## A complete, standalone program
1113

@@ -30,8 +32,9 @@ try {
3032
// Run a public store Actor and wait up to 120s for it to finish.
3133
$run = $client->actor('apify/hello-world')->call(null, null, 120);
3234

33-
// Read the items the run produced into its default dataset.
34-
$items = $client->dataset($run->getDefaultDatasetId())->listItems();
35+
// Read the items the run produced into its default dataset. getDefaultDatasetId() is
36+
// ?string, so cast it to satisfy dataset(string $id).
37+
$items = $client->dataset((string) $run->getDefaultDatasetId())->listItems();
3538
echo 'Item count: ' . $items->getCount() . PHP_EOL;
3639
} catch (ApifyApiException $e) {
3740
echo 'API error ' . $e->getStatusCode() . ': ' . $e->getApiMessage() . PHP_EOL;
@@ -42,7 +45,8 @@ try {
4245

4346
```php
4447
$run = $client->actor('apify/hello-world')->call(null, null, 120);
45-
$items = $client->dataset($run->getDefaultDatasetId())->listItems();
48+
// getDefaultDatasetId() is ?string, so cast it to satisfy dataset(string $id).
49+
$items = $client->dataset((string) $run->getDefaultDatasetId())->listItems();
4650
echo 'Item count: ' . $items->getCount() . PHP_EOL;
4751
```
4852

0 commit comments

Comments
 (0)