Expand description
§apify-client
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.
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
- Public interface:
ApifyClientand the resource clients inclients. - Replaceable transport: the
http_client::HttpBackendtrait, with a defaulthttp_client::ReqwestBackend. Swap it viaApifyClientBuilder::http_backend. - Cross-cutting behaviour (auth,
User-Agent, retries with exponential backoff, timeouts) lives inhttp_client::HttpClientand is applied to every request.
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 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::GetRecordsOptions;pub use clients::key_value_store::ListKeysOptions;pub use clients::log::LogOptions;pub use clients::request_queue::ListRequestsOptions;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::StoreListOptions;
Modules§
- clients
- Resource clients.
- common
- Shared building blocks used across resource clients: the response envelope,
query-parameter helpers, pagination types and the
User-Agentbuilder. - error
- Error types returned by the Apify client.
- http_
client - The HTTP layer of the client.
- models
- Data models for Apify API resources.
Structs§
- Apify
Client - The entry point for interacting with the Apify API.
- Apify
Client Builder - 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.