Skip to main content

spider_cloud_agent/
lib.rs

1//! Agentic client for the Spider Cloud API.
2//!
3//! Three things this adds over a plain API binding:
4//!
5//! - it picks the cheapest request settings likely to work, before spending a call
6//! - it reads both status planes and escalates on its own when a fetch is blocked
7//! - it returns only what the caller asked for, so an LLM reading the result pays for less
8//!
9//! The two status planes are the thing to understand first. A call to Spider
10//! Cloud has an HTTP status, and the page it fetched has its own status inside
11//! the body. A 403 in the first means your key is wrong. A 403 in the second
12//! means the site blocked the fetch. See [`status`].
13
14#![cfg_attr(docsrs, feature(doc_cfg))]
15#![forbid(unsafe_code)]
16#![warn(missing_docs)]
17
18pub mod auth;
19pub mod client;
20pub mod credits;
21pub mod error;
22pub mod memory;
23pub mod ops;
24#[cfg(feature = "optimize")]
25#[cfg_attr(docsrs, doc(cfg(feature = "optimize")))]
26pub mod optimize;
27pub mod params;
28pub mod policy;
29pub mod record;
30pub mod response;
31pub mod routing;
32pub mod status;
33pub mod thrift;
34mod transport;
35
36pub use client::{RunBudget, RunSpend, Spider, SpiderBuilder, Transport};
37pub use credits::{Credits, Usd, WholeCredits, CREDITS_PER_USD};
38pub use error::{AuthCause, BudgetKind, Error, Recovery};
39pub use memory::SiteMemoryStore;
40pub use params::{
41    Country, ProxyPool, RequestMode, RequestParams, ReturnFormat, SearchParams, WaitFor,
42};
43pub use policy::{Budget, Ladder, Policy, Rung, Step};
44pub use record::{JsonlRecorder, Recorder};
45pub use response::{Attempt, Body, FailedPage, Outcome, Page, PageResult, Pages};
46pub use routing::Explorer;
47pub use spider_route::{
48    featurize, Action, AttemptOutcome, CallerPins, DeclaredNeed, HeuristicRouter, RouteDecision,
49    RouteInput, RouteSource, Router, RouterVersion, SiteMemory, StatusClass, Wait,
50};
51pub use status::{ApiClass, ApiStatus, PageClass, PageStatus};
52pub use thrift::{Need, ThriftReport, TokenBudget};
53
54/// Result alias used across the crate.
55pub type Result<T> = std::result::Result<T, Error>;