apify-rs
Rust client for the Apify platform API.
Apify is a web scraping and automation cloud platform. Users publish Actors (serverless programs) to the Apify Store, run them with a JSON input, and retrieve structured results from Datasets or Key-Value Stores.
This crate mirrors the Apify REST API v2 and provides an idiomatic, strongly-typed Rust interface for managing Actors, Tasks, and Runs.
Disclaimer
This project was written with the help of large language models (LLMs). It is not well tested in production, so please review and test thoroughly before using it for critical workloads.
Features
- Resource-oriented clients —
ActorClient,TaskClient, andRunClientwrap related REST endpoints. - Typed models —
Actor,Task,Run, and supporting structs withserdesupport. - Convenience helpers —
wait_for_finish, synchronous run variants, typed dataset item retrieval, and exponential-backoff retries on429. - CLI demo — a
clap-powered binary (cargo run -- --help) showing how to create Tasks, start Runs, poll for completion, and read results. - Instagram example — ready-to-use structs and formatting helpers for the Instagram Profile Scraper Actor output.
Quick start
use ApifyClient;
let client = new;
// Run a task asynchronously
let run = client.tasks.run.await?;
println!;
// Poll until the run finishes
let finished = client.runs.wait_for_finish.await?;
println!;
Installation
You can install the CLI or add the library to your project:
# Installs the `apify` binary
# Adds the library to your Cargo.toml
Documentation
API documentation is hosted on docs.rs/apify-rs.
CLI usage
Set APIFY_TOKEN in your environment and run:
When developing locally you can also use:
Example workflow:
# Create an Instagram scraping task
# Start the task and wait for completion
# Fetch the resulting dataset
Project structure
| Module | Purpose |
|---|---|
src/lib.rs |
Root crate, ApifyClient, ApifyClientBuilder |
src/client.rs |
Low-level HttpClient with auth, JSON, retries |
src/error.rs |
ApifyError enum mapping HTTP & API errors |
src/models.rs |
Request/response structs and enums |
src/resources/actors.rs |
List, get, and run Actors |
src/resources/tasks.rs |
CRUD and run Tasks |
src/resources/runs.rs |
Monitor Runs, fetch datasets, abort/resurrect |
src/instagram.rs |
Typed Instagram output structs & formatting |
src/main.rs |
CLI binary |
Running tests
License
This project is provided as-is for demonstration purposes. See the source files for individual licensing information.