Expand description
REST API adapter — JSON APIs with auth, pagination, and data extraction REST API scraping adapter with authentication and pagination support.
Implements crate::ports::ScrapingService for structured REST JSON APIs. Supports:
- HTTP methods:
GET,POST,PUT,PATCH,DELETE,HEAD - Authentication: Bearer token, HTTP Basic, API key (header or query param)
- Automatic pagination: offset/page, cursor, or RFC 8288
Linkheader - JSON response data extraction via dot-separated path
- Custom request headers and query string parameters
- Configurable retries with exponential backoff
All per-request options live in ServiceInput::params; see the
RestApiAdapter::execute docs for the full contract.
§Example
use stygian_graph::adapters::rest_api::{RestApiAdapter, RestApiConfig};
use stygian_graph::ports::{ScrapingService, ServiceInput};
use serde_json::json;
use std::time::Duration;
let adapter = RestApiAdapter::with_config(RestApiConfig {
timeout: Duration::from_secs(20),
max_retries: 2,
..Default::default()
});
let input = ServiceInput {
url: "https://api.github.com/repos/rust-lang/rust/issues".to_string(),
params: json!({
"auth": { "type": "bearer", "token": "ghp_..." },
"query": { "state": "open", "per_page": "30" },
"pagination": { "strategy": "link_header", "max_pages": 5 },
"response": { "data_path": "" }
}),
};
// let output = adapter.execute(input).await.unwrap();Structs§
- Rest
ApiAdapter - REST API scraping adapter.
- Rest
ApiConfig - Configuration for
RestApiAdapter.