diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2e0c02..326e37e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,31 @@ All notable changes to the Apify Java client are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.15.0] - 2026-11-27
+
+### Added
+
+- `StoreActorStats`, the statistics of a Store Actor: `totalUsers`, `totalRuns`, `totalUsers7Days`, `totalUsers30Days`, `totalUsers90Days`, `actorReviewRating`, and `actorReviewCount`.
+- `ActorStoreListItem` getters for `userFullName`, `categories`, `notice`, `isWhiteListedForAgenticPayments`, `isVerified`, and `badge`.
+- `KeyValueStoreClient.setRecord` overloads that take an `InputStream`. The stream is sent without being held in memory, and the upload is not retried or compressed. Like a request to an Actor's server, it needs an `HttpTransport` that can disable redirects.
+- `KeyValueStoreClient.getRecordStream` and `KeyValueStoreRecordStream`, which read a record as an `InputStream`. The request is retried like any other.
+- `InputStream` as the input of `ActorClient.start`, `ActorClient.call`, `TaskClient.start`, and `TaskClient.call`, and as the body of `ActorServerClient.request` and `requestStream`. A stream is sent once, with no retry, and needs an `HttpTransport` that can disable redirects.
+- `APIFY_AI` run origin.
+
+### Changed
+
+- **Breaking:** `ActorStoreListItem.getStats()` returns `StoreActorStats` instead of `ActorStats`. The Store no longer returns `totalBuilds`, `totalMetamorphs`, and `lastRunStartedAt`.
+- **Breaking:** `StoreCollectionClient.iterate` sends one request when `search` is set, since the Store returns a single page of at most 100 Actors for a search and ignores `offset`. `chunkSize` and `offset` have no effect for a search.
+- `StoreListOptions.category` takes comma-separated category IDs.
+- `LogClient.stream` and `DatasetClient.streamItems` retry the request like any other, until the response headers arrive.
+- `ActorVersionCollectionClient.create` and `ActorVersionClient.update` use the long timeout tier, since a version can carry its source files.
+- Documented that creating an Actor with a name you already use fails with a `ConflictError` (`actor-name-not-unique`).
+- `ActorClient.validateInput` and `RunClient.metamorph` throw `IllegalArgumentException` for an `InputStream` input, instead of serializing it to JSON.
+
+### Deprecated
+
+- `StoreListOptions.sortBy`: the API ignores it.
+
## [0.14.1] - 2026-11-20
### Changed
diff --git a/README.md b/README.md
index 5b0f45f..ecc53e6 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ Maven (Maven Central is a default repository, so no extra configuration is neede
com.apifyapify-client
- 0.14.1
+ 0.15.0
```
@@ -35,7 +35,7 @@ repositories {
}
dependencies {
- implementation 'com.apify:apify-client:0.14.1'
+ implementation 'com.apify:apify-client:0.15.0'
}
```
@@ -308,15 +308,16 @@ both non-blocking. `HttpRequest` and `HttpResponse` below are the JDK's `java
| Method | Signature | Contract |
|---|---|---|
-| `sendAsync` | `CompletableFuture> sendAsync(HttpRequest request)` | Sends the single, fully-prepared request (auth, `User-Agent` and any other headers are already set by the client) and completes the future with the response with its body fully buffered as `byte[]`. Used for every non-streaming call. |
-| `sendStreamingAsync` | `CompletableFuture> sendStreamingAsync(HttpRequest request)` | Sends the request and completes the future with the response body as a live `InputStream` for incremental consumption, used by log streaming (`LogClient.stream(...)`) and dataset export streaming (`DatasetClient.streamItems(...)`). The *caller* (the client) is responsible for closing the returned stream; an implementation must not close it itself before completing the future. |
+| `sendAsync` | `CompletableFuture> sendAsync(HttpRequest request)` | Sends the single, fully-prepared request (auth, `User-Agent` and any other headers are already set by the client) and completes the future with the response with its body fully buffered as `byte[]`. Used for every non-streaming call that follows redirects. |
+| `sendStreamingAsync` | `CompletableFuture> sendStreamingAsync(HttpRequest request)` | Sends the request and completes the future with the response body as a live `InputStream` for incremental consumption, used by log streaming (`LogClient.stream(...)`), dataset export streaming (`DatasetClient.streamItems(...)`), and record streaming (`KeyValueStoreClient.getRecordStream(...)`). The *caller* (the client) is responsible for closing the returned stream; an implementation must not close it itself before completing the future. |
Two further methods, `sendAsync(HttpRequest, boolean followRedirects)` and
`sendStreamingAsync(HttpRequest, boolean followRedirects)`, have default implementations that send
the request through the methods above when `followRedirects` is `true` and **fail** the future with an
`UnsupportedOperationException` when it is `false`. A request to an Actor's server (see
-[Server Actors](docs/actors.md#server-actors)) is sent with `followRedirects` set to `false`, so
-that the API token never follows a redirect to another host. Override both to support it: with
+[Server Actors](docs/actors.md#server-actors)) and a request whose body is an `InputStream` are sent
+with `followRedirects` set to `false`, so that the API token never follows a redirect to another
+host and a stream is never sent twice. Override both to support it: with
`false`, return a redirect response as it is. `DefaultHttpTransport` does, also when it wraps your own
JDK `HttpClient` (it then copies the client's settings into one that does not follow redirects).
@@ -437,7 +438,7 @@ try {
The public `com.apify.client.Version` class (`import com.apify.client.Version;`) exposes two
constants:
-- `Version.CLIENT_VERSION`: the semantic version of this client (`0.14.1`).
+- `Version.CLIENT_VERSION`: the semantic version of this client (`0.15.0`).
- `Version.API_SPEC_VERSION`: the version of the [Apify OpenAPI specification](https://docs.apify.com/api/openapi.json)
(its `info.version` field) that this client's endpoints, parameters, and models were last generated
and checked against (`v2-2026-11-18T151559Z`). It is a snapshot, not a live compatibility
diff --git a/docs/README.md b/docs/README.md
index 703a7fb..f3e08ed 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -48,13 +48,13 @@ option types, so import each resource you use from its own package:
| `com.apify.client.build` | `Build`, `BuildClient`, `BuildCollectionClient`, `BuildActVersion`, `ActorDefinition`, `ActorDefinitionMeta`, `ActorDefinitionStorages`, `BuildMeta`, `BuildStats`, `BuildOptions`, `BuildUsage` |
| `com.apify.client.run` | `ActorRun`, `ActorRunStats`, `ActorRunOptions`, `ActorRunMeta`, `ActorRunStandby`, `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.keyvalue` | `KeyValueStore`, `KeyValueStoreClient`, `KeyValueStoreCollectionClient`, `KeyValueStoreRecord`, `KeyValueStoreRecordStream`, `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.store` | `ActorStoreListItem`, `StoreActorStats`, `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
diff --git a/docs/actors.md b/docs/actors.md
index f98c38e..938e4e0 100644
--- a/docs/actors.md
+++ b/docs/actors.md
@@ -9,7 +9,7 @@ where `id` is an Actor ID or `username~name` (a `/` in the id is accepted and no
|---|---|
| `list(ActorListOptions)` | List the account's Actors. Completes with `PaginationList`. |
| `iterate(ActorListOptions, Long chunkSize)` | Lazy `Flow.Publisher` over all matches; the options' `limit` caps the total yielded (`null`/unset or non-positive = all), `chunkSize` sets the page size (`null` = server default). |
-| `create(Object)` | Create a new Actor from a JSON-serializable definition. Completes with `Actor`. |
+| `create(Object)` | Create a new Actor from a JSON-serializable definition. Completes with `Actor`. Fails with a `ConflictError` (409, `actor-name-not-unique`) if you already have an Actor with that name. |
`ActorListOptions` adds `my(Boolean)` (only Actors owned by the current user) and
`sortBy(String)` (e.g. `createdAt`, `stats.lastRunStartedAt`) on top of the standard offset/limit/desc.
@@ -46,7 +46,7 @@ Actor created = client.actors().create(Map.of(
| `get()` | Fetch the Actor. Completes with `Optional`. |
| `update(Object)` | Update the Actor with the given fields. Completes with `Actor`. |
| `delete()` | Delete the Actor. |
-| `start(Object input, ActorStartOptions)` | Start a run, returning immediately. Completes with `ActorRun`. The `input` is any JSON-serializable value, or a `byte[]`/`String` that is sent as it is (set the matching `ActorStartOptions.contentType(...)`), or `null`. |
+| `start(Object input, ActorStartOptions)` | Start a run, returning immediately. Completes with `ActorRun`. The `input` is any JSON-serializable value, or a `byte[]`, `String`, or `InputStream` that is sent as it is (set the matching `ActorStartOptions.contentType(...)`), or `null`. A stream is read once, so its start is sent once: it is not retried, even with `waitForResources`. |
| `call(Object input, ActorStartOptions, Long waitSecs)` | Start a run and poll until it finishes (`null` waits indefinitely); does **not** stream the run's log. Completes with `ActorRun`. |
| `call(Object input, ActorCallOptions, Long waitSecs)` | As above, additionally streaming the run's log for the duration of the wait by default. Use `ActorCallOptions.disableLogStreaming()` to opt out, or `logOptions(StreamedLogOptions)` for a custom destination. |
| `validateInput(Object input)` / `validateInput(Object input, ValidateInputOptions)` | Validate an input against the Actor's input schema. Completes with `boolean`. `ValidateInputOptions` fields (optional): `build` (`String`), `contentType` (`String`). |
@@ -131,8 +131,9 @@ Actor's `standbyUrl` and `actorStandby` fields.
`ActorServerRequestOptions` fields (all optional): `method(String)` (`GET` by default; also `HEAD`,
`POST`, `PUT`, `DELETE`, `OPTIONS`, `TRACE`, `PATCH`), `param(String, Object)`/`params(Map)` (query
parameters, converted as for API calls: `null` is left out, a boolean is sent as `1`/`0`, a
-collection comma-joined), `header(String, String)`/`headers(Map)`, `body(Object)` (a `byte[]` or
-`String` is sent as it is; anything else is serialized to JSON and sent as `application/json`
+collection comma-joined), `header(String, String)`/`headers(Map)`, `body(Object)` (a `byte[]`,
+`String`, or `InputStream` is sent as it is, and a stream is sent once, with no retry, no
+compression, and no redirect followed; anything else is serialized to JSON and sent as `application/json`
unless you set a `Content-Type` header), `parentRequestId(String)` (see
[Calling a Server Actor from a Server Actor](#calling-a-server-actor-from-a-server-actor)),
`compression(HttpCompressor)` and `timeout(Timeout)`
@@ -232,14 +233,14 @@ and deletes a single version and exposes its environment variables.
|---|---|
| `list(ListOptions)` | List the Actor's versions. Completes with `PaginationList`. The endpoint takes no query parameters; `options` (`offset`/`limit`/`desc`) is accepted only for signature consistency with every other `list(ListOptions)` and has no effect; pass `null`. |
| `iterate(ListOptions)` | Lazy `Flow.Publisher` over all versions; `limit` caps the total (`null`/unset or non-positive = all), applied client-side after the single fetch. `offset` has no effect and there is no page size to tune. |
-| `create(Object version)` | Create a version. Completes with `ActorVersion`. |
+| `create(Object version)` | Create a version. Completes with `ActorVersion`. Uses the long timeout tier, since the version can carry its source files. |
### `ActorVersionClient`: `client.actor(id).version(v)`
| Method | Description |
|---|---|
| `get()` | Fetch the version. Completes with `Optional`. |
-| `update(Object)` | Update the version. Completes with `ActorVersion`. |
+| `update(Object)` | Update the version. Completes with `ActorVersion`. Uses the long timeout tier, since the version can carry its source files. |
| `delete()` | Delete the version. |
| `envVars()` | An `ActorEnvVarCollectionClient` for the version's environment variables. |
| `envVar(String name)` | An `ActorEnvVarClient` for a single environment variable. |
diff --git a/docs/misc.md b/docs/misc.md
index 65450de..518d54f 100644
--- a/docs/misc.md
+++ b/docs/misc.md
@@ -7,30 +7,46 @@ Browse public Actors in the Apify Store. `client.store()` returns a `StoreCollec
| Method | Description |
|---|---|
| `list(StoreListOptions)` | A page of Store Actors. Completes with `PaginationList`. |
-| `iterate(StoreListOptions, Long chunkSize)` | A lazy `Flow.Publisher` over all matches, fetching pages on demand. The options' `limit` caps the total number of rows read, which are the Actors yielded unless the API drops entries after counting them (`null`/unset or non-positive = all); `chunkSize` is the per-request page size (`null` = server default). |
+| `iterate(StoreListOptions, Long chunkSize)` | A lazy `Flow.Publisher` over all matches, fetching pages on demand. The options' `limit` caps the total number of rows read, which are the Actors yielded unless the API drops entries after counting them (`null`/unset or non-positive = all); `chunkSize` is the per-request page size (`null` = server default). With `search` there is a single page instead: see below. |
`StoreListOptions` fields: `offset` (number of Actors to skip), `limit` (maximum number of Actors to
-return), `search` (full-text search query), `sortBy` (the sort field, e.g. `popularity`, `newest`),
-`category` (filter Actors by category), `username` (filter Actors by owner username), `pricingModel`
-(filter by pricing model: `FREE`, `PRICE_PER_DATASET_ITEM`, `PAY_PER_EVENT`; the deprecated rental model
-`FLAT_PRICE_PER_MONTH` is no longer listed),
+return; the API default and maximum is 1000, or 100 with `search`), `search` (search query),
+`sortBy` (deprecated: the API ignores it, and orders the results by relevance with `search` and by
+Store position otherwise, so sort them on the client), `category` (filter by one or more category IDs
+such as `AI_AND_ML`, comma-separated and case-insensitive; an Actor must match all of them, and an
+unknown category fails with a `400` error), `username` (filter Actors by owner username),
+`pricingModel` (filter by pricing model: `FREE`, `PRICE_PER_DATASET_ITEM`, `PAY_PER_EVENT`; the
+deprecated rental model `FLAT_PRICE_PER_MONTH` is no longer listed),
`includeUnrunnableActors` (include Actors the current user cannot run), `allowsAgenticUsers` (only
Actors that allow agentic users), `responseFormat` (the response shape: `full` or `agent`).
+A `search` returns the Actors ranked by relevance as a single page of at most 100: the API ignores
+`offset` and has no second page. `iterate` therefore sends one request for a search, when you call
+`iterate` rather than on first demand, with the options' `limit` as its size. `chunkSize` and
+`offset` have no effect. Narrow a search with `category`, `username`, or `pricingModel`.
+
```java
// Publishers.collect() drains the whole publisher; fine here since `limit` already caps it.
// To stop early without fetching further pages, subscribe with your own Flow.Subscriber instead
// (request(1) at a time, cancel() once you have enough); see IterateStore.java in the examples.
List items =
- Publishers.collect(client.store().iterate(new StoreListOptions().search("crawler").limit(20L), 10L))
+ Publishers.collect(client.store().iterate(new StoreListOptions().username("apify").limit(20L), 10L))
.join();
items.forEach(item -> System.out.println(item.getUsername() + "/" + item.getName()));
+
+// A search is one page of at most 100 Actors.
+List found =
+ Publishers.collect(client.store().iterate(new StoreListOptions().search("crawler"), null)).join();
```
`ActorStoreListItem` fields: `getId()`, `getName()`, `getUsername()`, `getTitle()`,
-`getDescription()`, `getStats()` (`ActorStats`; see [Actors](actors.md#actorclient)),
-`getCurrentPricingInfo()` (`PricingInfo`: `getPricingModel()`), `getPictureUrl()`,
-`getUserPictureUrl()`, `getUrl()`, `getReadmeSummary()`. Any field not covered by a typed getter is
+`getUserFullName()`, `getDescription()`, `getCategories()` (`List` of category IDs),
+`getNotice()`, `getStats()` (`StoreActorStats`: `getTotalUsers()`, `getTotalRuns()`,
+`getTotalUsers7Days()`, `getTotalUsers30Days()`, `getTotalUsers90Days()`, `getActorReviewRating()`,
+`getActorReviewCount()`), `getCurrentPricingInfo()` (`PricingInfo`: `getPricingModel()`),
+`getIsWhiteListedForAgenticPayments()`, `getIsVerified()` (whether the developer has a verified
+identity), `getBadge()`, `getPictureUrl()`, `getUserPictureUrl()`, `getUrl()`,
+`getReadmeSummary()`. Any field not covered by a typed getter is
still available via the inherited `getExtra()` (see
[the docs index](README.md#model-fields-and-unmodeled-data-getextra)).
@@ -94,7 +110,7 @@ Access a build's or run's log directly, or via `client.run(id).log()` / `client.
|---|---|
| `get()` / `get(LogOptions)` | The whole log as text. Completes with `Optional` when addressed by an explicit id (`client.log(id)`); on `run.log()`/`build.log()` (no log id of its own), a 404 is ambiguous and throws `NotFoundError` instead; see [Fetching single resources](../README.md#fetching-single-resources). |
| `getAsBytes()` / `getAsBytes(LogOptions)` | As `get()`, but completes with `Optional` (the raw bytes, not decoded as text). Same 404 handling as `get()`. |
-| `stream()` / `stream(LogOptions)` | A live `InputStream` over the log (for redirection). Completes with `InputStream`; throws on any error response, including a 404. |
+| `stream()` / `stream(LogOptions)` | A live `InputStream` over the log (for redirection). Completes with `InputStream`. The request is retried like any other, until the headers arrive; it throws on an error response that is not retried, or the last one once the retries run out, including a 404. |
`LogOptions` fields: `raw(Boolean)`, `download(Boolean)`.
diff --git a/docs/storages.md b/docs/storages.md
index 552dbeb..b56fa1a 100644
--- a/docs/storages.md
+++ b/docs/storages.md
@@ -52,7 +52,7 @@ any field not covered by a typed getter above is still available via the inherit
| `iterateItems(DatasetListItemsOptions)` / `iterateItems(DatasetListItemsOptions, Long chunkSize)` | A lazy `Flow.Publisher` over all items; the options' `limit` caps the dataset *rows* read (`null`/unset or non-positive = all), the optional `chunkSize` sets the per-request page size. Dataset items have no default page limit, so without `chunkSize` the whole dataset (or all `limit` rows) is loaded in one response: pass `chunkSize` to iterate a large dataset. |
| `iterateItems(DatasetListItemsOptions, Long chunkSize, Class)` | As above, decoded into `T`. Returns `Flow.Publisher`. For typed iteration in one response, pass a `null` chunk size: `iterateItems(opts, null, T.class)`. |
| `downloadItems(DownloadItemsFormat, DatasetDownloadOptions)` | Serialized bytes. `DownloadItemsFormat` is one of `JSON`, `JSONL`, `CSV`, `XLSX`, `XML`, `RSS`, `HTML`. Completes with `byte[]`. |
-| `streamItems(DownloadItemsFormat, DatasetDownloadOptions)` | As above, but resolves to a live `InputStream` over the export instead of fully buffering it, so a large export is processed in chunks. The caller closes the stream (or reads it to the end). Throws on any error response, including a 404. |
+| `streamItems(DownloadItemsFormat, DatasetDownloadOptions)` | As above, but resolves to a live `InputStream` over the export instead of fully buffering it, so a large export is processed in chunks. The caller closes the stream (or reads it to the end). The request is retried like any other, until the headers arrive; it throws on an error response that is not retried, or the last one once the retries run out, including a 404. |
| `pushItems(Object)` | Push a single item (a `Map`, a POJO, a `JsonNode` object, ...), a list/array of items, or a `String` that already is the JSON serialization of either (sent as it is). The API accepts only an object or an array of objects, so anything else (a number, a plain string, an array of strings) throws `IllegalArgumentException` before a request is sent. A push that times out is not retried, so items cannot be stored twice. Completes with no value (`CompletableFuture`). |
| `getStatistics()` | Dataset statistics. Completes with `JsonNode`; throws `NotFoundError` if the dataset is gone (no separate "statistics absent" state). |
| `createItemsPublicUrl(DatasetListItemsOptions, Long expiresInSecs)` | A public (optionally signed) items URL, served as `json`. `expiresInSecs` must be positive and at most `4611686018427387` when set. Completes with `String`. |
@@ -142,6 +142,8 @@ datasets.
| `getRecord(String key)` / `getRecord(String key, GetRecordOptions)` | Fetch a record. Completes with `Optional`. |
| `setRecord(String key, byte[] value, String contentType)` | Store raw bytes. Completes with no value (`CompletableFuture`). |
| `setRecord(String key, byte[] value, String contentType, SetRecordOptions)` | Store raw bytes with write options (`SetRecordOptions`: `timeoutSecs` (`Long`) or `timeout` (`Timeout`: a tier, an exact duration or `NO_TIMEOUT`; the default is the `LONG` tier), `doNotRetryTimeouts` (`Boolean`), `contentEncoding` (`String`, see below)). Completes with no value. |
+| `getRecordStream(String key)` / `getRecordStream(String key, GetRecordOptions)` | As `getRecord`, but completes with an `Optional` whose `getValue()` is a live `InputStream`, so a large record is processed in chunks. Close the record (or read its stream to the end) when done. The request is retried like any other, until the headers arrive. Throws on an error response that is not retried, or the last one once the retries run out, except a 404, which completes with empty. A failure while reading the body is not retried. |
+| `setRecord(String key, InputStream value, String contentType)` / `setRecord(String key, InputStream value, String contentType, SetRecordOptions)` | Store the bytes read from a stream, without holding them in memory, so a large file can be uploaded. The stream is closed when the call completes. It can be read once, so the upload is sent once: it is not retried, compressed, or sent again to follow a redirect, and `doNotRetryTimeouts` has no effect. Completes with no value. |
| `setRecordJson(String key, Object value)` | Store JSON. Completes with no value. |
| `deleteRecord(String key)` | Delete a record. Completes with no value. |
| `getRecordPublicUrl(String key)` | A public (optionally signed) record URL. Completes with `String`. |
@@ -184,7 +186,20 @@ client.keyValueStore("my-store")
.join();
```
-`KeyValueStoreRecord` exposes `getKey()`, `getValue()` (raw bytes) and `getContentType()`.
+Copy a large record without reading it into memory by passing the stream of one call to the other:
+
+```java
+try (KeyValueStoreRecordStream source =
+ client.keyValueStore("my-store").getRecordStream("video.mp4").join().orElseThrow()) {
+ client.keyValueStore("other-store")
+ .setRecord("video.mp4", source.getValue(), source.getContentType())
+ .join();
+}
+```
+
+`KeyValueStoreRecord` exposes `getKey()`, `getValue()` (raw bytes), and `getContentType()`;
+`KeyValueStoreRecordStream` exposes `getKey()`, `getValue()` (the `InputStream`), `getContentType()`,
+and `close()`.
`KeyValueStoreKeysPage` exposes `getItems()` (a list of `KeyValueStoreKey` with `getKey()`/`getSize()`),
`isTruncated()`, `getExclusiveStartKey()` and `getNextExclusiveStartKey()`.
diff --git a/docs/tasks.md b/docs/tasks.md
index 1d41a7c..9b15804 100644
--- a/docs/tasks.md
+++ b/docs/tasks.md
@@ -25,7 +25,7 @@ Task task = client.tasks().create(Map.of(
|---|---|
| `get()` / `update(Object)` / `delete()` | CRUD. Complete with `Optional` / `Task` / no value. |
| `publish()` / `unpublish()` | Publish/unpublish the task on its public landing page, by setting `isPublic` through `update(Object)`. Both require write permission to both the task and its Actor; `publish()` additionally requires the task's Actor to be public and a configured `publicConfig`. `unpublish()` preserves `publicConfig` so the task can be republished without re-entering it. Complete with the updated `Task`. |
-| `start(Object input, TaskStartOptions)` | Start a task run (input overrides stored input; `null` uses it). Completes with `ActorRun`. |
+| `start(Object input, TaskStartOptions)` | Start a task run (input overrides stored input; `null` uses it). Completes with `ActorRun`. As for an Actor, the `input` can be a `byte[]`, `String`, or `InputStream` that is sent as it is; a stream is sent once, with no retry. |
| `call(Object input, TaskStartOptions, Long waitSecs)` | Start and poll until finished; does **not** stream the run's log. Completes with `ActorRun`. |
| `call(Object input, TaskCallOptions, Long waitSecs)` | As above, additionally streaming the run's log for the duration of the wait by default. Use `TaskCallOptions.disableLogStreaming()` to opt out, or `logOptions(StreamedLogOptions)` for a custom destination. |
| `getInput()` | The stored input. Completes with `JsonNode`; throws `NotFoundError` if the task is gone (no separate "input absent" state). |
diff --git a/pom.xml b/pom.xml
index baf59cd..034c22e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.apifyapify-client
- 0.14.1
+ 0.15.0jarApify Java Client
diff --git a/src/main/java/com/apify/client/Version.java b/src/main/java/com/apify/client/Version.java
index 0654df4..3bef73f 100644
--- a/src/main/java/com/apify/client/Version.java
+++ b/src/main/java/com/apify/client/Version.java
@@ -13,7 +13,7 @@ public final class Version {
* The semantic version of this client library (see SemVer).
* Changes to the public interface other than additive ones are considered breaking changes.
*/
- public static final String CLIENT_VERSION = "0.14.1";
+ public static final String CLIENT_VERSION = "0.15.0";
/**
* The version of the Apify OpenAPI specification this client was generated and verified against.
diff --git a/src/main/java/com/apify/client/actor/ActorClient.java b/src/main/java/com/apify/client/actor/ActorClient.java
index 65c8572..749b04b 100644
--- a/src/main/java/com/apify/client/actor/ActorClient.java
+++ b/src/main/java/com/apify/client/actor/ActorClient.java
@@ -16,6 +16,7 @@
import com.apify.client.run.RunClient;
import com.apify.client.run.RunCollectionClient;
import com.apify.client.webhook.NestedWebhookCollectionClient;
+import java.io.InputStream;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -73,8 +74,13 @@ public CompletableFuture delete() {
/**
* Starts the Actor and completes with the created run as soon as it exists (no waiting). {@code
- * input} is any JSON-serializable value, a {@code byte[]} or {@link String} that is sent as it is
- * (set the content type with the options' {@code contentType}), or {@code null} for no input.
+ * input} is any JSON-serializable value, a {@code byte[]}, {@link String}, or {@link InputStream}
+ * that is sent as it is (set the content type with the options' {@code contentType}), or {@code
+ * null} for no input.
+ *
+ *
An {@code InputStream} is read as it is sent, closed when the call completes, and never held
+ * in memory. It can be read once, so the start is sent once: a failed request is not retried, and
+ * a rejection for lack of resources is thrown even if {@code waitForResources} is set.
*/
public CompletableFuture start(Object input, ActorStartOptions options) {
return RunStartSupport.start(
diff --git a/src/main/java/com/apify/client/actor/ActorCollectionClient.java b/src/main/java/com/apify/client/actor/ActorCollectionClient.java
index 75dc2ce..6dc815b 100644
--- a/src/main/java/com/apify/client/actor/ActorCollectionClient.java
+++ b/src/main/java/com/apify/client/actor/ActorCollectionClient.java
@@ -18,7 +18,11 @@ public ActorCollectionClient(HttpClientCore http, String baseUrl) {
ActorListOptions::new);
}
- /** Creates a new Actor. {@code actor} is any JSON-serializable Actor definition. */
+ /**
+ * Creates a new Actor. {@code actor} is any JSON-serializable Actor definition. Fails with a
+ * {@link com.apify.client.http.ConflictError} (409, {@code actor-name-not-unique}) if you already
+ * have an Actor with the same name.
+ */
public CompletableFuture create(Object actor) {
return ctx.createResource(new QueryParams(), actor, Actor.class, Timeout.MEDIUM);
}
diff --git a/src/main/java/com/apify/client/actor/ActorServerClient.java b/src/main/java/com/apify/client/actor/ActorServerClient.java
index bbf9590..8fe2899 100644
--- a/src/main/java/com/apify/client/actor/ActorServerClient.java
+++ b/src/main/java/com/apify/client/actor/ActorServerClient.java
@@ -11,6 +11,7 @@
import com.apify.client.internal.QueryParams;
import com.apify.client.internal.RequestPolicy;
import com.apify.client.internal.ResourceContext;
+import java.io.InputStream;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
@@ -209,19 +210,31 @@ public CompletableFuture> getOpenApiSpec(Timeout timeout) {
*/
public CompletableFuture request(String path, ActorServerRequestOptions options) {
ActorServerRequestOptions opts = options != null ? options : new ActorServerRequestOptions();
- byte[] body = Json.toRequestBody(opts.bodyValue());
+ RequestPolicy policy = RequestPolicy.server(opts.compressionValue());
+ InputStream stream = opts.bodyValue() instanceof InputStream in ? in : null;
+ byte[] body = stream == null ? Json.toRequestBody(opts.bodyValue()) : null;
return getUrl()
.thenCompose(
serverUrl ->
- http.call(
- opts.methodValue(),
- requestUrl(serverUrl, path, opts),
- body,
- contentTypeOf(opts),
- opts.headersValue(),
- opts.timeoutValue(),
- false,
- RequestPolicy.server(opts.compressionValue())));
+ stream != null
+ ? http.callWithStream(
+ opts.methodValue(),
+ requestUrl(serverUrl, path, opts),
+ stream,
+ contentTypeOf(opts),
+ opts.headersValue(),
+ opts.timeoutValue(),
+ policy)
+ : http.call(
+ opts.methodValue(),
+ requestUrl(serverUrl, path, opts),
+ body,
+ contentTypeOf(opts),
+ opts.headersValue(),
+ opts.timeoutValue(),
+ false,
+ policy))
+ .whenComplete((response, error) -> closeUnused(stream));
}
/** A {@code GET} request to {@code path} on the Actor's server; see {@link #request}. */
@@ -246,24 +259,47 @@ public CompletableFuture request() {
public CompletableFuture requestStream(
String path, ActorServerRequestOptions options) {
ActorServerRequestOptions opts = options != null ? options : new ActorServerRequestOptions();
- byte[] body = Json.toRequestBody(opts.bodyValue());
+ RequestPolicy policy = RequestPolicy.server(opts.compressionValue());
+ InputStream stream = opts.bodyValue() instanceof InputStream in ? in : null;
+ byte[] body = stream == null ? Json.toRequestBody(opts.bodyValue()) : null;
return getUrl()
.thenCompose(
serverUrl ->
- http.streamRequest(
- opts.methodValue(),
- requestUrl(serverUrl, path, opts),
- body,
- contentTypeOf(opts),
- opts.headersValue(),
- opts.timeoutValue(),
- RequestPolicy.server(opts.compressionValue())))
+ stream != null
+ ? http.streamRequest(
+ opts.methodValue(),
+ requestUrl(serverUrl, path, opts),
+ stream,
+ contentTypeOf(opts),
+ opts.headersValue(),
+ opts.timeoutValue(),
+ policy)
+ : http.streamRequest(
+ opts.methodValue(),
+ requestUrl(serverUrl, path, opts),
+ body,
+ contentTypeOf(opts),
+ opts.headersValue(),
+ opts.timeoutValue(),
+ policy))
+ .whenComplete((response, error) -> closeUnused(stream))
.thenApply(
response ->
new ActorServerStreamResponse(
response.statusCode(), response.headers(), response.body()));
}
+ /**
+ * Closes a stream body when the URL lookup fails, before the request is made, for example because
+ * the Actor is not a Server Actor. Once the request is made, {@code HttpClientCore} closes the
+ * stream when the call completes.
+ */
+ private static void closeUnused(InputStream stream) {
+ if (stream != null) {
+ HttpClientCore.closeQuietly(stream);
+ }
+ }
+
/** Fetches the Actor and checks that it is a Server Actor. */
private CompletableFuture fetchServerActor(Timeout timeout) {
return ctx.getResourceRequired("", new QueryParams(), Actor.class, timeout)
@@ -394,7 +430,11 @@ private static String contentTypeOf(ActorServerRequestOptions options) {
return set;
}
Object body = options.bodyValue();
- boolean sentAsIs = body == null || body instanceof byte[] || body instanceof String;
+ boolean sentAsIs =
+ body == null
+ || body instanceof byte[]
+ || body instanceof String
+ || body instanceof InputStream;
return sentAsIs ? null : ResourceContext.CONTENT_TYPE_JSON;
}
}
diff --git a/src/main/java/com/apify/client/actor/ActorServerRequestOptions.java b/src/main/java/com/apify/client/actor/ActorServerRequestOptions.java
index 410a8af..d96cdcc 100644
--- a/src/main/java/com/apify/client/actor/ActorServerRequestOptions.java
+++ b/src/main/java/com/apify/client/actor/ActorServerRequestOptions.java
@@ -3,6 +3,7 @@
import com.apify.client.http.HttpCompressor;
import com.apify.client.http.Timeout;
import com.apify.client.internal.QueryParams;
+import java.io.InputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -85,10 +86,14 @@ public ActorServerRequestOptions headers(Map headers) {
}
/**
- * The request body: a {@code byte[]} or a {@link String} is sent as it is (set its {@code
- * Content-Type} with {@link #header}), and anything else, a {@link Map}, a list or a POJO, is
- * serialized to JSON and sent as {@code application/json} unless a {@code Content-Type} header is
- * set.
+ * The request body: a {@code byte[]}, a {@link String}, or an {@link InputStream} is sent as it
+ * is (set its {@code Content-Type} with {@link #header}), and anything else, a {@link Map}, a
+ * list, or a POJO, is serialized to JSON and sent as {@code application/json} unless a {@code
+ * Content-Type} header is set.
+ *
+ *
An {@code InputStream} is read as it is sent and closed when the call completes, so it is
+ * never held in memory. It can be read once, so the request is sent once, with no retry (not even
+ * for a 429 or 503 response), no compression, and no redirect followed.
*/
public ActorServerRequestOptions body(Object body) {
this.body = body;
diff --git a/src/main/java/com/apify/client/actor/ActorStartOptions.java b/src/main/java/com/apify/client/actor/ActorStartOptions.java
index 888fb81..28b4388 100644
--- a/src/main/java/com/apify/client/actor/ActorStartOptions.java
+++ b/src/main/java/com/apify/client/actor/ActorStartOptions.java
@@ -101,7 +101,8 @@ public ActorStartOptions webhooks(List