Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rust-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

# The `rustls` feature swaps the TLS stack, so it needs its own lint and compile check.
- name: Clippy with rustls
run: cargo clippy --no-default-features --features rustls -- -D warnings
run: cargo clippy --no-default-features --features rustls --all-targets -- -D warnings

# The `zstd` feature is on by default, so the build without it needs its own check.
- name: Clippy without zstd
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ All notable changes to the Rust Apify API client are documented here. The format
based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project adheres
to [Semantic Versioning](https://semver.org/).

## [0.18.0] - 2026-11-20

### Added
- `SetRecordOptions` is re-exported at the crate root.

### Fixed
- `UserClient::get` no longer fails for a request authenticated with a proxy password. The API
answers it with only the reduced data Apify Proxy reads, without `id` and `username`.
- `client.user(id).get()` no longer fails for the public profile of another user, which has no `id`.

### Changed
- Synced with Apify OpenAPI spec `v2-2026-11-18T151559Z` (`API_SPEC_VERSION`). It adds the reduced
proxy variant to the responses of `GET /v2/users/me` and `GET /v2/users/{userId}`, types the
schedule's `uiState` as nullable, and changes descriptions: single-tenant Server Actor runs
ignore the `requestId` of a charge, a charge is sent from the run itself with the token in
`APIFY_TOKEN`, and API tokens are shown only once.
- **Breaking:** `User::id` is `Option<String>`, because the public profile and the reduced proxy
data have no `id`.
- Documented that only the run itself can metamorph, with its own token, on
`RunClient::metamorph` and `metamorph_raw`.
- Documented the other description changes on `RunChargeOptions`, `RunClient::charge`, and in the
docs.

## [0.17.0] - 2026-11-10

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "apify-client"
version = "0.17.0"
version = "0.18.0"
authors = ["Apify Technologies <support@apify.com>"]
description = "Rust client for the Apify API (https://apify.com)."
license = "Apache-2.0"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ It provides a resource-oriented, async interface that follows the

```toml
[dependencies]
apify-client = "0.17"
apify-client = "0.18"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde_json = "1" # for the `serde_json::Value` responses used in the Quick start
```
Expand Down Expand Up @@ -49,7 +49,7 @@ instead, disable the default features and name `rustls`. The `"zstd"` entry keep
so drop it if you do not need it:

```toml
apify-client = { version = "0.17", default-features = false, features = ["rustls", "zstd"] }
apify-client = { version = "0.18", default-features = false, features = ["rustls", "zstd"] }
```

The `rustls` feature requires `rustls-webpki` 0.103.16 or newer and `webpki-roots` 1.0.10 or
Expand Down Expand Up @@ -304,8 +304,8 @@ code snippets in this README and `docs/` as doctests (`cargo test --doc`).

## Examples

Runnable examples live in [`examples/`](examples). Each requires `APIFY_TOKEN` and can be
run with `cargo run --example <name>`:
Runnable examples live in [`examples/`](examples). Each requires `APIFY_TOKEN`, and `APIFY_API_URL` optionally overrides the API URL
(default `https://api.apify.com/v2`). Run one with `cargo run --example <name>`:

- `run_store_actor` — run a Store Actor, wait, read its default dataset.
- `storages` — create each storage type (dataset, key-value store, request queue), write and read back.
Expand Down
23 changes: 14 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Add the crate and an async runtime:

```toml
[dependencies]
apify-client = "0.17"
apify-client = "0.18"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```

Expand Down Expand Up @@ -64,30 +64,35 @@ suite and the Apify platform use), so production code typically does
`ApifyClient::new(std::env::var("APIFY_TOKEN")?)`. The literal `"my-api-token"` above is only a
placeholder for brevity.

Create the token on the [Integrations page](https://console.apify.com/settings/integrations) in
Apify Console. Apify Console shows the token only once, right after you create or rotate it, so copy it
and store it somewhere safe.

## Imports

The client, the builder, and **every** option/parameter struct are re-exported at the crate
root, so you can import them directly from `apify_client` — you never need the longer
`apify_client::clients::<module>::<Type>` path. The complete set of re-exported option/parameter
types is:

- Actors: `ActorStartOptions`, `ActorCallOptions`, `TaskStartOptions`, `ActorBuildOptions`, `ActorListOptions`
- Actors: `ActorStartOptions`, `ActorCallOptions`, `TaskStartOptions`, `ActorBuildOptions`, `ActorListOptions`, `WaitForResources`
- Runs: `RunListOptions`, `RunResurrectOptions`, `RunMetamorphOptions`, `RunChargeOptions`, `LastRunOptions`
- Datasets: `DatasetListItemsOptions`, `DatasetDownloadOptions`, `DownloadItemsFormat`
- Key-value stores: `ListKeysOptions`, `GetRecordOptions`
- Request queues: `ListRequestsOptions`
- Key-value stores: `ListKeysOptions`, `GetRecordOptions`, `SetRecordOptions`
- Request queues: `ListRequestsOptions`, `BatchAddRequestsOptions`
- Store: `StoreListOptions`
- Logs: `LogOptions`, `LogRedirect`, `LogSink`, `StreamedLog`, `StreamedLogOptions`
- Shared: `ListOptions`, `StorageListOptions`
- Logs: `LogOptions`, `LogRedirect`, `LogSink`, `StdoutLogSink`, `StreamedLog`, `StreamedLogOptions`
- Shared: `ListOptions`, `StorageListOptions`, `Timeout`
- Server Actors: `ActorServerRequestOptions`, `ActorServerBody`, `ActorServerCompression`
- Client configuration: `RequestCompression`
- Client configuration: `RequestCompression`, `HttpCompressor`, `BrotliHttpCompressor`, `GzipHttpCompressor`, and `ZstdHttpCompressor` (needs the `zstd` feature)

plus the common container `PaginationList`, `ListIterator`
(the return type of every collection client's `iterate()` method), `StoreActorIterator`
(a type alias for `ListIterator<ActorStoreListItem>`, the return type of
`StoreCollectionClient::iterate`), and the two cursor-based iterators `KeyValueStoreKeysIterator`
`StoreCollectionClient::iterate`), the two cursor-based iterators `KeyValueStoreKeysIterator`
(from `KeyValueStoreClient::iterate_keys`) and `RequestQueueRequestsIterator` (from
`RequestQueueClient::paginate_requests`). Import any of them directly from `apify_client`:
`RequestQueueClient::paginate_requests`), and `RunDatasetItemsIterator` (from
`RunClient::iterate_dataset_items`). Import any of them directly from `apify_client`:

```rust,no_run
use apify_client::{ApifyClient, ActorListOptions, StoreListOptions, DownloadItemsFormat};
Expand Down
2 changes: 1 addition & 1 deletion docs/actors.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ When your multi-tenant Server Actor calls another one while it handles a request
`X-Actor-Request-ID` header in `parent_request_id`. The client sends it as the same header, so the
called Actor charges at the pricing tier of your incoming request. Use a client created with the
run's `APIFY_TOKEN`. For details, see
[Compose multi-tenant Server Actors](https://docs.apify.com/platform/actors/development/programming-interface/standby#compose-server-actors).
[Call another multi-tenant Server Actor](https://docs.apify.com/platform/actors/monetize/server-actors#call-another-multi-tenant-server-actor).

```rust,no_run
use apify_client::{ActorServerRequestOptions, ApifyClient};
Expand Down
10 changes: 7 additions & 3 deletions docs/misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,20 @@ organization your API token belongs to. They return a `404` as an error.

| Field | Type | Description |
|---|---|---|
| `id` | `String` | Unique user ID (always present). |
| `username` | `Option<String>` | Username. |
| `id` | `Option<String>` | Unique user ID. Present in the private account details, absent from the public profile and the reduced proxy data. |
| `username` | `Option<String>` | Username. Absent from the reduced proxy data. |
| `profile` | `Option<UserProfile>` | The public profile: `name`, `picture_url` and `website_url` (both normalized to their WHATWG URL serialization) and the other fields in `extra`. |
| `extra` | `Extra` | Any other fields returned by the API (more fields are present for `me` than for a public `user(id)`). |

A request authenticated with a proxy password (`PROXY_PASSWORD` or `ACTOR_RUN_PROXY_PASSWORD`) gets only
the reduced data Apify Proxy reads: `plan.availableProxyGroups`, `effectivePlatformFeatures`, and
`isPaying`, all in `extra`. In that case, `id` and `username` are `None`.

```rust,no_run
# use apify_client::ApifyClient;
# async fn run(client: ApifyClient) -> Result<(), Box<dyn std::error::Error>> {
if let Some(user) = client.me().get().await? {
println!("account id {}, username {:?}", user.id, user.username);
println!("account id {:?}, username {:?}", user.id, user.username);
}
# Ok(())
# }
Expand Down
5 changes: 3 additions & 2 deletions docs/runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ collections are available via `actor.runs()` and `task.runs()`.
| `update(fields)` | `&impl Serialize` | `ActorRun` | Updates the run (e.g. status message). |
| `delete()` | — | `()` | Deletes the run. |
| `abort(gracefully)` | `Option<bool>` | `ActorRun` | Aborts the run. `None` omits the param (server default, immediate); `Some(true)`/`Some(false)` abort gracefully/immediately. |
| `metamorph(target, input, options)` | `&str`, `Option<&impl Serialize>`, `RunMetamorphOptions` | `ActorRun` | Transforms the run into another Actor. |
| `metamorph(target, input, options)` | `&str`, `Option<&impl Serialize>`, `RunMetamorphOptions` | `ActorRun` | Transforms the run into another Actor. Only the run itself can metamorph: use the run's own token from `APIFY_TOKEN`, as the API rejects any other token. |
| `metamorph_raw(target, input, options)` | `&str`, `&[u8]`, `RunMetamorphOptions` | `ActorRun` | Like `metamorph`, but sends `input` as a raw request body (no JSON serialization), paired with `options.content_type`. |
| `reboot()` | — | `ActorRun` | Reboots the run's container. |
| `resurrect(options)` | `RunResurrectOptions` | `ActorRun` | Resurrects a run in a terminal state (`SUCCEEDED`, `FAILED`, `ABORTED`, `TIMED-OUT`). To continue a run that reached its cost limit, pass a higher `max_total_charge_usd`; the limit covers the whole run, including the cost before the resurrection. |
Expand Down Expand Up @@ -77,7 +77,8 @@ streamed_log.stop().await?;
the charge, so a retry past that window creates a new charge instead of being deduplicated),
`request_id` (ID of the Server Actor request being charged, from the `X-Actor-Request-ID` header of
the incoming request; required for multi-tenant Server Actor runs, where it maps the charge to the
caller's account; omitted from the request when `None`).
caller's account, and ignored by runs of single-tenant Server Actors; omitted from the request
when `None`). Call `charge` from the run itself, with the token the run received in `APIFY_TOKEN`.

`ActorRun.status` is a stringly-typed `Option<String>` carrying the API's run status. Known
values are `READY`, `RUNNING`, `SUCCEEDED`, `FAILED`, `ABORTING`, `ABORTED`, `TIMING-OUT`, and
Expand Down
8 changes: 7 additions & 1 deletion examples/create_build_run_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("APIFY_TOKEN").expect("set APIFY_TOKEN");
let client = ApifyClient::new(token);
// `APIFY_API_URL` optionally points the example at another API, such as a staging deployment.
let api_url =
std::env::var("APIFY_API_URL").unwrap_or_else(|_| "https://api.apify.com/v2".into());
let client = ApifyClient::builder()
.token(token)
.base_url(api_url)
.build();

// Create a minimal Actor with an inline source-files version.
let suffix = uuid_like();
Expand Down
10 changes: 8 additions & 2 deletions examples/get_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ use chrono::Utc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("APIFY_TOKEN").expect("set APIFY_TOKEN");
let client = ApifyClient::new(token);
// `APIFY_API_URL` optionally points the example at another API, such as a staging deployment.
let api_url =
std::env::var("APIFY_API_URL").unwrap_or_else(|_| "https://api.apify.com/v2".into());
let client = ApifyClient::builder()
.token(token)
.base_url(api_url)
.build();

let user = client.me().get().await?.expect("current user");
println!("Account id: {}", user.id);
println!("Account id: {}", user.id.as_deref().unwrap_or("(none)"));
println!("Username: {}", user.username.as_deref().unwrap_or("(none)"));

// Monthly usage for the current billing cycle (`None` == current cycle).
Expand Down
8 changes: 7 additions & 1 deletion examples/iterate_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ use apify_client::{ApifyClient, StoreListOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("APIFY_TOKEN").expect("set APIFY_TOKEN");
let client = ApifyClient::new(token);
// `APIFY_API_URL` optionally points the example at another API, such as a staging deployment.
let api_url =
std::env::var("APIFY_API_URL").unwrap_or_else(|_| "https://api.apify.com/v2".into());
let client = ApifyClient::builder()
.token(token)
.base_url(api_url)
.build();

// Iterate the store, fetching pages of 5 on demand. `with_chunk_size` sets the per-request
// page size; the options' `limit` (left unset here) would instead cap the total number of
Expand Down
8 changes: 7 additions & 1 deletion examples/log_redirection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ use apify_client::{ActorCallOptions, ApifyClient, LogRedirect, StreamedLogOption
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("APIFY_TOKEN").expect("set APIFY_TOKEN");
let client = ApifyClient::new(token);
// `APIFY_API_URL` optionally points the example at another API, such as a staging deployment.
let api_url =
std::env::var("APIFY_API_URL").unwrap_or_else(|_| "https://api.apify.com/v2".into());
let client = ApifyClient::builder()
.token(token)
.base_url(api_url)
.build();

// The (separate) Actor whose log we will redirect into this program's output.
let source_actor = "apify/hello-world";
Expand Down
8 changes: 7 additions & 1 deletion examples/raw_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ use futures_util::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("APIFY_TOKEN").expect("set APIFY_TOKEN");
let client = ApifyClient::new(token);
// `APIFY_API_URL` optionally points the example at another API, such as a staging deployment.
let api_url =
std::env::var("APIFY_API_URL").unwrap_or_else(|_| "https://api.apify.com/v2".into());
let client = ApifyClient::builder()
.token(token)
.base_url(api_url)
.build();

// Run a short public Actor and wait for it to finish so it has a complete log.
let run = client
Expand Down
8 changes: 7 additions & 1 deletion examples/run_and_last_run_storages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ use apify_client::{ApifyClient, LastRunOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("APIFY_TOKEN").expect("set APIFY_TOKEN");
let client = ApifyClient::new(token);
// `APIFY_API_URL` optionally points the example at another API, such as a staging deployment.
let api_url =
std::env::var("APIFY_API_URL").unwrap_or_else(|_| "https://api.apify.com/v2".into());
let client = ApifyClient::builder()
.token(token)
.base_url(api_url)
.build();

// Start a run and wait for it to finish.
let run = client
Expand Down
8 changes: 7 additions & 1 deletion examples/run_store_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ use apify_client::{ApifyClient, StoreListOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("APIFY_TOKEN").expect("set APIFY_TOKEN");
let client = ApifyClient::new(token);
// `APIFY_API_URL` optionally points the example at another API, such as a staging deployment.
let api_url =
std::env::var("APIFY_API_URL").unwrap_or_else(|_| "https://api.apify.com/v2".into());
let client = ApifyClient::builder()
.token(token)
.base_url(api_url)
.build();

// Discover the public `apify/hello-world` Actor through the Apify Store API. It is free,
// fast, and runs without input, which keeps this example reliable.
Expand Down
8 changes: 7 additions & 1 deletion examples/storages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("APIFY_TOKEN").expect("set APIFY_TOKEN");
let client = ApifyClient::new(token);
// `APIFY_API_URL` optionally points the example at another API, such as a staging deployment.
let api_url =
std::env::var("APIFY_API_URL").unwrap_or_else(|_| "https://api.apify.com/v2".into());
let client = ApifyClient::builder()
.token(token)
.base_url(api_url)
.build();

// ---- Dataset: create, push, read ----
let dataset = client.datasets().get_or_create(None).await?;
Expand Down
13 changes: 10 additions & 3 deletions src/clients/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ pub struct RunChargeOptions {
pub idempotency_key: Option<String>,
/// ID of the Server Actor request being charged, taken from the `X-Actor-Request-ID` header
/// of the incoming request. Required for multi-tenant Server Actor runs, where it maps the
/// charge to the caller's account instead of the account that started the run. Omitted from
/// the request body when `None`.
/// charge to the caller's account instead of the account that started the run. Runs of
/// single-tenant Server Actors ignore it. Omitted from the request body when `None`.
pub request_id: Option<String>,
}

Expand Down Expand Up @@ -177,6 +177,10 @@ impl RunClient {

/// Transforms the run into a run of another Actor (metamorph).
///
/// Only the run itself can metamorph: the client must use the run's own API token, which the
/// run gets in the `APIFY_TOKEN` environment variable. With any other token, the API rejects
/// the request.
///
/// `options.content_type` sets the content type of the input body (default
/// `application/json`). To send a non-JSON input as raw bytes, use
/// [`metamorph_raw`](Self::metamorph_raw).
Expand All @@ -197,6 +201,8 @@ impl RunClient {
/// Transforms the run into a run of another Actor (metamorph) with a raw request body
/// instead of a JSON-serializable value.
///
/// Like [`metamorph`](Self::metamorph), only the run itself can call it, with its own token.
///
/// The bytes are sent exactly as given, with no JSON serialization — pair this with
/// `options.content_type` for a non-JSON input. For an object or array input, use
/// [`metamorph`](Self::metamorph) instead.
Expand Down Expand Up @@ -289,7 +295,8 @@ impl RunClient {
/// An idempotency key is always sent (generated when `options.idempotency_key` is `None`), so
/// a charge that the transport retries is applied at most once.
///
/// The charge endpoint returns an empty body on success, so any 2xx response is a success.
/// Call it from the run itself, with the token the run received in `APIFY_TOKEN`. The charge
/// endpoint returns an empty body on success, so any 2xx response is a success.
pub async fn charge(&self, options: RunChargeOptions) -> ApifyClientResult<()> {
let count = options.count.unwrap_or(1);
let idempotency_key = options
Expand Down
3 changes: 2 additions & 1 deletion src/clients/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ impl UserClient {
/// Fetches the user account information, or `None` if the user does not exist.
///
/// For the current user (`me`) this returns private account details; for other users
/// it returns the public profile.
/// it returns the public profile. A request authenticated with a proxy password gets only the
/// reduced data Apify Proxy reads, so `id` and `username` can be `None`.
pub async fn get(&self) -> ApifyClientResult<Option<User>> {
get_resource(&self.ctx, None, &QueryParams::new(), Timeout::Short).await
}
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ pub use clients::actor_server::{
ActorServerBody, ActorServerCompression, ActorServerRequestOptions,
};
pub use clients::dataset::{DatasetDownloadOptions, DatasetListItemsOptions, DownloadItemsFormat};
pub use clients::key_value_store::{GetRecordOptions, KeyValueStoreKeysIterator, ListKeysOptions};
pub use clients::key_value_store::{
GetRecordOptions, KeyValueStoreKeysIterator, ListKeysOptions, SetRecordOptions,
};
pub use clients::log::LogOptions;
pub use clients::pagination::ListIterator;
pub use clients::request_queue::{
Expand Down
Loading
Loading