Refyne Rust SDK
Official Rust SDK for the Refyne API - LLM-powered web extraction.
API Endpoint: https://api.refyne.uk | Documentation: refyne.uk/docs
Installation
Add this to your Cargo.toml:
[]
= "0.0"
= { = "1.0", = ["rt-multi-thread", "macros"] }
= "1.0"
Quick Start
use ;
use json;
async
Features
- Builder Pattern: Fluent configuration for client setup
- Cache-Control Aware: Automatic response caching based on server headers
- Retry Logic: Exponential backoff with rate limit handling
- API Version Checking: Warns when SDK may be outdated
- Custom HTTP Client: Inject your own reqwest client
- Custom Caching: Implement the
Cachetrait for custom storage
Configuration
use Client;
use Duration;
let client = builder
.base_url // Custom API endpoint
.timeout // Request timeout
.max_retries // Retry attempts
.cache_enabled // Disable caching
.user_agent_suffix // Custom User-Agent suffix
.build?;
API Methods
Extract Data
use ;
let result = client.extract.await?;
Start a Crawl Job
use ;
let job = client.crawl.await?;
println!;
Monitor Job Status
let job = client.get_job.await?;
println!;
// Get results when complete
let results = client.get_job_results.await?;
Manage Schemas
// List all schemas
let schemas = client.list_schemas.await?;
// Create a schema
let schema = client.create_schema.await?;
LLM Configuration (BYOK)
// List available providers
let providers = client.list_providers.await?;
// Add your own API key
client.upsert_llm_key.await?;
// Get the fallback chain
let chain = client.get_llm_chain.await?;
Error Handling
use Error;
match client.extract.await
Custom Cache Implementation
use ;
use Arc;
let client = builder
.cache
.build?;
Documentation
Testing with Demo Site
A demo site is available at demo.refyne.uk for testing SDK functionality. The site contains realistic data across multiple content types:
| Endpoint | Content Type | Example Use Case |
|---|---|---|
https://demo.refyne.uk/products |
Product catalog | Extract prices, descriptions, ratings |
https://demo.refyne.uk/jobs |
Job listings | Extract salaries, requirements, companies |
https://demo.refyne.uk/blog |
Blog posts | Extract articles, authors, tags |
https://demo.refyne.uk/news |
News articles | Extract headlines, sources, timestamps |
Example:
let result = client.extract.await?;
License
MIT License - see LICENSE for details.