-
Notifications
You must be signed in to change notification settings - Fork 0
refactor!: package split + issue #8 review fixes; sync spec to v2-2026-07-20T094852Z #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a809034
2a1c031
a95c3e8
c786760
344736b
f705ae6
35c02cc
d74cd92
83b41a5
e2beffa
67e1a33
643b9b4
b423f6b
27c99bf
6399194
bbab39c
e3a0701
dd5675f
c46278b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,10 @@ | ||
| # Apify Java client documentation | ||
|
|
||
| > **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. | ||
|
|
||
|
Comment on lines
-3
to
-6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This info is important. The repeated parts should be deduplicated but not fully removed.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The agent did this because of the requirement to have this warning just once and in the top-level README: |
||
| This directory documents the public API of the Apify Java client, organized by resource. Each page | ||
| lists the available methods with their parameters and short snippets. The snippets are code | ||
| fragments that assume a configured `client` and the imports listed below, not standalone `main` | ||
| programs; for complete, runnable programs see [examples.md](examples.md) and | ||
| programs; [examples.md](examples.md) has more fragments in the same style, and the complete, | ||
| runnable programs live under | ||
| [`src/test/java/com/apify/client/examples/`](https://github.com/apify/apify-client-java/tree/master/src/test/java/com/apify/client/examples). For an | ||
| overview, configuration, error handling and the full resource table, see the | ||
| [top-level README](../README.md). | ||
|
|
@@ -20,7 +17,7 @@ ApifyClient client = ApifyClient.create("my-api-token"); | |
|
|
||
| `ApifyClient.create` takes the token as an explicit argument — it does not read `APIFY_TOKEN` | ||
| automatically. Use `ApifyClient.builder()` for non-default settings (base URL, retries, timeout, | ||
| user-agent suffix, custom HTTP backend). | ||
| user-agent suffix, custom HTTP transport). | ||
|
|
||
| Get your API token from the | ||
| [Apify Console → Settings → API & Integrations](https://console.apify.com/settings/integrations). | ||
|
|
@@ -31,10 +28,39 @@ empty `Optional` rather than an exception. API failures are thrown as `ApifyApiE | |
|
|
||
| ## Imports and dependencies | ||
|
|
||
| Snippets in these docs assume the client types are imported from `com.apify.client` (e.g. | ||
| `import com.apify.client.*;`) plus standard-library types (`java.util.List`, `java.util.ArrayList`, | ||
| `java.util.Map`, `java.util.Optional`, `java.util.Iterator`, `java.util.function.Consumer`, | ||
| `java.time.Duration`, `java.io.InputStream`). | ||
| Client types are **not** all in one package: `import com.apify.client.*;` only resolves | ||
| `ApifyClient`, its builder, and the shared kernel types below — a wildcard import does not reach | ||
| into sub-packages in Java. Every resource has its own sub-package for its client(s), model(s) and | ||
| option types, so import each resource you use from its own package: | ||
|
|
||
| | Package | Contains | | ||
| |---|---| | ||
| | `com.apify.client` (root) | `ApifyClient`, `ApifyClientBuilder`, `Version`, `PaginationList<T>`, `ListOptions`, `StorageListOptions`, `ApifyResource` | | ||
| | `com.apify.client.http` | `ApifyClientException`, `ApifyApiException`, `ApifyTransportException`, `HttpTransport`, `DefaultHttpTransport`, `HttpTimeoutException` | | ||
| | `com.apify.client.actor` | `Actor`, `ActorClient`, `ActorCollectionClient`, `ActorListOptions`, `ActorStartOptions`, `ActorCallOptions`, `ActorBuildOptions`, `ActorStandby`, `ActorVersion`, `ActorVersionClient`, `ActorVersionCollectionClient`, `ActorEnvVar`, `ActorEnvVarClient`, `ActorEnvVarCollectionClient`, `ValidateInputOptions`, `ActorStats`, `ActorDefaultRunOptions` | | ||
| | `com.apify.client.build` | `Build`, `BuildClient`, `BuildCollectionClient`, `BuildMeta`, `BuildStats`, `BuildOptions`, `BuildUsage` | | ||
| | `com.apify.client.run` | `ActorRun`, `ActorRunStats`, `ActorRunOptions`, `ActorRunMeta`, `ActorRunUsage`, `RunClient`, `RunCollectionClient`, `RunListOptions`, `LastRunOptions`, `MetamorphOptions`, `RunChargeOptions`, `RunResurrectOptions`, `SetStatusMessageOptions` | | ||
| | `com.apify.client.dataset` | `Dataset`, `DatasetClient`, `DatasetCollectionClient`, `DatasetListItemsOptions`, `DatasetDownloadOptions`, `DownloadItemsFormat` | | ||
| | `com.apify.client.keyvalue` | `KeyValueStore`, `KeyValueStoreClient`, `KeyValueStoreCollectionClient`, `KeyValueStoreRecord`, `KeyValueStoreKeysPage`, `KeyValueStoreKey`, `GetRecordOptions`, `SetRecordOptions`, `ListKeysOptions` | | ||
| | `com.apify.client.requestqueue` | `RequestQueue`, `RequestQueueClient`, `RequestQueueCollectionClient`, `RequestQueueRequest`, `RequestQueueHead`, `LockedRequestQueueHead`, `RequestQueueOperationInfo`, `RequestLockInfo`, `UnlockRequestsResult`, `RequestsList`, `BatchAddResult`, `BatchDeleteResult`, `DeletedRequestInfo`, `ListRequestsOptions`, `BatchAddRequestsOptions` | | ||
| | `com.apify.client.task` | `Task`, `TaskStats`, `TaskOptions`, `TaskClient`, `TaskCollectionClient`, `TaskStartOptions`, `TaskCallOptions` | | ||
| | `com.apify.client.schedule` | `Schedule`, `ScheduleNotifications`, `ScheduleClient`, `ScheduleCollectionClient` | | ||
| | `com.apify.client.webhook` | `Webhook`, `WebhookStats`, `WebhookLastDispatch`, `WebhookClient`, `WebhookCollectionClient`, `WebhookDispatchCollectionClient`, `NestedWebhookCollectionClient`, `WebhookDispatch`, `WebhookDispatchClient`, `WebhookDispatchCall`, `WebhookDispatchWebhookInfo`, `WebhookDispatchEventData` | | ||
| | `com.apify.client.user` | `User`, `UserClient`, `UserProfile`, `UserProxy`, `UserPlan`, `ProxyGroup` | | ||
| | `com.apify.client.store` | `ActorStoreListItem`, `StoreCollectionClient`, `StoreListOptions`, `PricingInfo` | | ||
| | `com.apify.client.log` | `LogClient`, `LogOptions`, `StreamedLog`, `StreamedLogOptions` | | ||
|
|
||
| For example, the [top-level README's dataset snippet](../README.md#quick-start) needs | ||
| `com.apify.client.ApifyClient`, `com.apify.client.PaginationList`, | ||
| `com.apify.client.dataset.DatasetListItemsOptions`, `com.apify.client.run.ActorRun`, | ||
| `com.apify.client.actor.ActorStartOptions` and `com.fasterxml.jackson.databind.JsonNode` — five | ||
| different packages for one four-line snippet. | ||
|
|
||
| Snippets in these docs also assume the standard-library types they use are imported | ||
| (`java.util.List`, `java.util.ArrayList`, `java.util.Map`, `java.util.Optional`, | ||
| `java.util.Iterator`, `java.util.UUID`, `java.util.function.Consumer`, `java.time.Duration`, | ||
| `java.time.Instant`, `java.io.InputStream`). `java.time.Instant` is returned by many model getters | ||
| (e.g. `createdAt`, `modifiedAt`, `nextRunAt`, `lockExpiresAt`). | ||
|
|
||
| Raw-JSON return values use Jackson's `com.fasterxml.jackson.databind.JsonNode`. Jackson is a | ||
| transitive dependency of this client, so it is already on your classpath. | ||
|
|
@@ -44,34 +70,61 @@ transitive dependency of this client, so it is already on your classpath. | |
| A few methods return data whose shape is not modelled by this client and is instead exposed as a | ||
| Jackson `JsonNode` (or accept an arbitrary `Object` serialized to JSON): | ||
|
|
||
| - Read: `me().monthlyUsage(...)`, `me().limits()`, `task(id).getInput()`, | ||
| `build(id).getOpenApiDefinition()`, `dataset(id).getStatistics()` (returned as | ||
| `Optional<JsonNode>`), and the raw request-queue operations (`listRequests`, `listAndLockHead`, | ||
| `prolongRequestLock`, `unlockRequests`, `batchDeleteRequests`). | ||
| - Write: `task(id).updateInput(...)` and `me().updateLimits(...)` accept an arbitrary | ||
| JSON-serializable value, as do definition/`update`/`create` arguments generally — a `Map`, a | ||
| `JsonNode`, or your own POJO. | ||
| - Read, returning a required `JsonNode` (never absent): `me().monthlyUsage(...)`, `me().limits()`. | ||
| - Read, returning `Optional<JsonNode>` (empty when the underlying resource has none): `dataset(id).getStatistics()`, | ||
| `task(id).getInput()`, `build(id).getOpenApiDefinition()`. | ||
| - Write: `task(id).updateInput(...)` (itself returning a required `JsonNode`, the updated input) | ||
| and `me().updateLimits(...)` accept an arbitrary JSON-serializable value, as do | ||
| definition/`update`/`create` arguments generally — a `Map`, a `JsonNode`, or your own POJO. | ||
| - A few typed models still carry one or more raw-JSON fields where the shape is a discriminated | ||
| union (or otherwise not worth fully modelling): `RequestQueueRequest.getUserData()`, | ||
| `Webhook.getCondition()`, `Schedule.getActions()` (a `List<JsonNode>`), `Task.getInput()` (the | ||
| task's stored input, on the `Task` model itself — distinct from the live-fetching | ||
| `task(id).getInput()` client call listed above), and `ActorRun`, which carries two: | ||
| `getPricingInfo()` and `getStorageIds()`. | ||
|
|
||
| Navigate a `JsonNode` with `node.get("field")`, `node.path("a").asText()`, etc. | ||
|
|
||
| The request-queue lock/list operations (`listRequests`, `listAndLockHead`, `prolongRequestLock`, | ||
| `unlockRequests`, `batchDeleteRequests`) return typed models (`RequestsList`, | ||
| `LockedRequestQueueHead`, `RequestLockInfo`, `UnlockRequestsResult`, `BatchDeleteResult`) rather | ||
| than raw `JsonNode` — see [Storages](storages.md#request-queues). | ||
|
|
||
| ## What `ApifyResource` is | ||
|
|
||
| `ApifyResource` (root package) is the base class every response model extends — both the top-level | ||
| resources (`Actor`, `Dataset`, `Schedule`, `ActorRun`, and so on) and the nested value DTOs embedded | ||
| in them (`ActorRunStats`, `ActorRunMeta`, `BuildStats`, `WebhookStats`, `UserProfile`, `PricingInfo`, | ||
| and every other nested model in this client). It has no fields of its own beyond the `extra` map | ||
| described below; it exists purely so every model shares one place to capture unmodelled API fields, | ||
| and so code that only needs the common capability (rare — most call sites use a concrete model type | ||
| directly) can accept `ApifyResource` rather than a specific model. | ||
|
|
||
| ## Model fields and unmodeled data (`getExtra`) | ||
|
|
||
| Response models expose the commonly-used fields as typed getters. The API returns more fields than | ||
| are modelled; every model also carries a `getExtra()` map (`Map<String, Object>`) holding any field | ||
| not mapped to a typed getter, so nothing the API returns is lost. For example a `Schedule`'s | ||
| `actions`/`isExclusive`, or a `me()` `User`'s private account details (email, plan, proxy settings, | ||
| …), are available via `getExtra()`. | ||
| are modelled; every model — including nested value DTOs, not only the top-level resources — also | ||
| carries a `getExtra()` map (`Map<String, Object>`, inherited from `ApifyResource` above) holding any | ||
| field not mapped to a typed getter, so nothing the API returns is lost, now or as the API grows new | ||
| fields later. For example a `me()` `User`'s private account details (email, plan, proxy settings, | ||
| …) are available via `getExtra()`, since `User` models only its most commonly used fields. | ||
|
|
||
| ```java | ||
| Schedule schedule = client.schedule("SCHEDULE_ID").get().orElseThrow(); | ||
| Object actions = schedule.getExtra().get("actions"); | ||
| User me = client.me().get().orElseThrow(); | ||
| Object plan = me.getExtra().get("plan"); | ||
| ``` | ||
|
|
||
| ## Setting single-resource status | ||
| ## Setting the current run's status message | ||
|
|
||
| `client.setStatusMessage(String message, boolean isTerminal)` updates the status message of the | ||
| current Actor run (identified by the `ACTOR_RUN_ID` environment variable); it only works from inside | ||
| a run and throws `IllegalStateException` otherwise. Returns the updated `ActorRun`. | ||
| `client.setStatusMessage(String message, SetStatusMessageOptions)` (import from | ||
| `com.apify.client.run`) sets the status message of the current Actor run (identified by the | ||
| `ACTOR_RUN_ID` environment variable); it only works from inside a run and throws | ||
| `IllegalStateException` otherwise. `SetStatusMessageOptions.isStatusMessageTerminal(boolean)` marks | ||
| the message as final. | ||
|
|
||
| ```java | ||
| client.setStatusMessage("half way there", new SetStatusMessageOptions().isStatusMessageTerminal(false)); | ||
| ``` | ||
|
Comment on lines
+117
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That method doesn't make sense and should be removed. It shouldn't have several long paragraphs in the README.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function is very strange, but the agent can't help it. It is mandated by requirements to implement all public convenience functions that the JS reference implementation has (this will also copy the weird ones...): So the correct flow would be to deprecate and later remove it in the reference JS client and let it propagate this way to generated clients. But I agree that it should have at least a minimal footprint in the docs.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed on all points. The method stays (mandated parity with the reference JS client), and the clean removal path is deprecating it upstream in the reference client and letting that propagate to the generated clients. Trimmed its docs footprint to a minimal mention in Generated by Claude Code |
||
|
|
||
| ## Optional option fields | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SLOP