dune_api/lib.rs
1//! Dune Analytics API client for Rust
2//!
3//! An unofficial Rust client for the [Dune Analytics API](https://docs.dune.com/api-reference).
4//!
5//! # Example
6//!
7//! ```no_run
8//! # async fn example() -> dune::error::Result<()> {
9//! let client = dune::Client::new("your-api-key")?;
10//!
11//! // Execute a query and wait for results
12//! let result = client.executions().run_query(1234, None).await?;
13//! for row in result.result.unwrap().rows {
14//! println!("{:?}", row);
15//! }
16//!
17//! // Execute raw SQL
18//! let result = client.executions().run_sql("SELECT 1 as value", None).await?;
19//! println!("{:?}", result.result);
20//!
21//! // Get cached results for a query
22//! let result = client.executions().query_results(1234).await?;
23//! println!("{:?}", result.result);
24//! # Ok(())
25//! # }
26//! ```
27//!
28//! # Features
29//!
30//! - **Queries**: Create, read, update, archive/unarchive queries
31//! - **Executions**: Execute queries, run SQL, get results (JSON or CSV)
32//! - **Tables**: Upload data, create tables, insert rows
33//! - **Materialized Views**: Create, refresh, manage materialized views
34//! - **Pipelines**: Execute coordinated query workflows
35//! - **Usage**: Track API consumption and credits
36
37mod client;
38pub mod error;
39
40pub mod executions;
41pub mod matviews;
42pub mod pipelines;
43pub mod queries;
44pub mod tables;
45pub mod usage;
46
47pub use client::{Client, Config};
48pub use error::{Error, Result};
49pub use yldfi_common::http::HttpClientConfig;
50pub use yldfi_common::{with_retry, with_simple_retry, RetryConfig, RetryError, RetryableError};
51
52/// Default base URL for the Dune Analytics API
53pub const DEFAULT_BASE_URL: &str = "https://api.dune.com/api";
54
55/// Create a config with an API key
56#[must_use]
57pub fn config_with_api_key(api_key: impl Into<String>) -> Config {
58 Config::new(api_key)
59}