apify-client 0.4.1

An official, but experimental, AI-generated and AI-maintained Rust client for the Apify API (https://apify.com).
Documentation
//! Lazily iterate Actors in the Apify Store using the convenience iteration method.
//!
//! Run with: `APIFY_TOKEN=... cargo run --example iterate_store`

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);

    // Iterate the store, fetching pages of 5 on demand (`limit` is the per-page size, not a
    // total cap). The loop below stops after the first 10 actors regardless of page size.
    let mut iter = client.store().iterate(StoreListOptions {
        limit: Some(5),
        ..Default::default()
    });

    let mut count = 0;
    while let Some(actor) = iter.next().await? {
        println!("{}: {:?}", actor.id, actor.title.or(actor.name));
        count += 1;
        if count >= 10 {
            break;
        }
    }
    println!("Iterated {count} store actors");

    Ok(())
}