| Crates.io | forex-factory |
| lib.rs | forex-factory |
| version | 0.1.0 |
| created_at | 2026-01-23 07:43:12.02078+00 |
| updated_at | 2026-01-23 07:43:12.02078+00 |
| description | Async Rust library for scraping economic event data from Forex Factory calendar |
| homepage | |
| repository | https://github.com/matiu2/forex-factory |
| max_upload_size | |
| id | 2063744 |
| size | 156,546 |
A Rust library for scraping economic event data from the Forex Factory calendar.
[features]
default = ["rustls", "brotli"]
# TLS backends - choose one
rustls = ["reqwest/rustls"] # Pure Rust TLS (default)
rustls-native-certs = ["reqwest/rustls-native-certs"] # Rustls with system certs
rustls-no-provider = ["reqwest/rustls-no-provider"] # Rustls, bring your own provider
native-tls = ["reqwest/native-tls"] # System TLS (OpenSSL/Schannel/SecureTransport)
native-tls-vendored = ["reqwest/native-tls-vendored"] # Bundled OpenSSL
# Compression
gzip = ["reqwest/gzip"]
brotli = ["reqwest/brotli"]
deflate = ["reqwest/deflate"]
zstd = ["reqwest/zstd"]
# Other
http2 = ["reqwest/http2"] # HTTP/2 support
http3 = ["reqwest/http3"] # HTTP/3 support (unstable)
socks = ["reqwest/socks"] # SOCKS5 proxy support
hickory-dns = ["reqwest/hickory-dns"] # Hickory DNS resolver
# WASM
wasm-timezone = ["js-sys"] # Auto-detect browser timezone on WASM
# Use rustls (default)
cargo add forex-factory
# Use native TLS
cargo add forex-factory --no-default-features --features native-tls
# With compression support
cargo add forex-factory --features gzip,brotli
# For WASM (browser handles TLS)
cargo add forex-factory --no-default-features
# For WASM with automatic timezone detection
cargo add forex-factory --no-default-features --features wasm-timezone
src/
├── lib.rs # Re-exports public API
├── error.rs # Error types (thiserror)
├── types.rs # Module declarations for types
├── types/
│ ├── impact.rs # Impact enum (Low, Medium, High)
│ ├── currency.rs # Currency resolution utilities
│ ├── event.rs # EconomicEvent struct
│ └── query.rs # EventQuery for filtering
├── scraper.rs # Module declarations for scraper
├── scraper/
│ ├── http_client.rs # HttpCalendarFetcher
│ └── parser.rs # CalendarParser
├── service.rs # Module declarations for service
└── service/
└── calendar.rs # CalendarService (high-level API)
CalendarService - High-level async service for fetching and querying eventsCalendarParser - HTML parser for Forex Factory calendar pagesHttpCalendarFetcher - HTTP client for fetching calendar pagesEconomicEvent - Struct representing a single economic eventEventQuery - Builder for filtering eventsImpact - Enum for event impact levels (Low, Medium, High)Error - Library error typeResult<T> - Library result type aliasresolve_currency - Function to resolve country names to currency codesuse forex_factory::{CalendarService, EventQuery, Impact, Result};
async fn fetch_events() -> Result<()> {
let service = CalendarService::new()?;
// Get all events for this week
let events = service.get_week_events().await?;
// Query with filters
let query = EventQuery::new()
.with_currency_pair("EUR/USD")
.with_min_impact(Impact::Medium);
let filtered = service.query_events(&query).await?;
Ok(())
}
On WASM targets:
cookie_store and timeout are handled by the browser--no-default-features to avoid pulling in native TLS dependenciesOn native targets, the library automatically detects your system timezone.
On WASM, you have two options:
Option 1: Enable wasm-timezone feature (recommended)
cargo add forex-factory --no-default-features --features wasm-timezone
This uses js-sys to automatically detect the browser's timezone via
Intl.DateTimeFormat().resolvedOptions().timeZone.
Option 2: Manual timezone
// Get timezone from JS yourself and pass it:
let service = CalendarService::with_timezone("America/New_York")?;
Without either option, WASM defaults to UTC.