Skip to main content

Crate apify_client

Crate apify_client 

Source
Expand description

§apify-client

An idiomatic Rust client for the Apify API.

It provides a resource-oriented interface that mirrors the official JavaScript and Python clients: start from an ApifyClient, then drill down into resources (Actors, runs, datasets, key-value stores, request queues, tasks, schedules, webhooks, the store, users and logs).

§Quick start

use apify_client::ApifyClient;

let client = ApifyClient::new("my-api-token");

// Start an Actor and wait for it to finish.
let run = client
    .actor("apify/hello-world")
    .call::<serde_json::Value>(None, Default::default(), None)
    .await?;

// Read items from the run's default dataset.
if let Some(dataset_id) = &run.default_dataset_id {
    let items = client
        .dataset(dataset_id)
        .list_items::<serde_json::Value>(Default::default())
        .await?;
    println!("Got {} items", items.items.len());
}

§Architecture

§Cancellation

The reference JavaScript client accepts an AbortSignal option on most methods so a caller can cancel an in-flight request. Rust futures are cancel-safe by construction: they do nothing until polled, so dropping one (e.g. via tokio::select!, or letting a tokio::time::timeout elapse) stops the underlying request without any API for it. This client therefore exposes no separate cancellation parameter — dropping the future returned by any method is the idiomatic equivalent.

Re-exports§

pub use common::ListOptions;
pub use common::PaginationList;
pub use common::QueryParams;
pub use common::StorageListOptions;
pub use error::ApiError;
pub use error::ApifyClientError;
pub use error::ApifyClientResult;
pub use http_client::RequestCompression;
pub use clients::actor::ActorBuildOptions;
pub use clients::actor::ActorStartOptions;
pub use clients::actor_collection::ActorListOptions;
pub use clients::dataset::DatasetDownloadOptions;
pub use clients::dataset::DatasetListItemsOptions;
pub use clients::dataset::DownloadItemsFormat;
pub use clients::key_value_store::GetRecordOptions;
pub use clients::key_value_store::KeyValueStoreKeysIterator;
pub use clients::key_value_store::ListKeysOptions;
pub use clients::log::LogOptions;
pub use clients::pagination::ListIterator;
pub use clients::request_queue::BatchAddRequestsOptions;
pub use clients::request_queue::ListRequestsOptions;
pub use clients::request_queue::RequestQueueRequestsIterator;
pub use clients::run::LastRunOptions;
pub use clients::run::RunChargeOptions;
pub use clients::run::RunMetamorphOptions;
pub use clients::run::RunResurrectOptions;
pub use clients::run_collection::RunListOptions;
pub use clients::store_collection::StoreActorIterator;
pub use clients::store_collection::StoreListOptions;

Modules§

clients
Resource clients.
common
Shared building blocks used across resource clients: the response envelope, query-parameter helpers, pagination types and the User-Agent builder.
error
Error types returned by the Apify client.
http_client
The HTTP layer of the client.
models
Data models for Apify API resources.

Structs§

ApifyClient
The entry point for interacting with the Apify API.
ApifyClientBuilder
Builder for ApifyClient.

Constants§

API_SPEC_VERSION
The version of the Apify OpenAPI specification that this client was generated and verified against.
CLIENT_VERSION
Semantic version of this client crate.