| Crates.io | arrakis |
| lib.rs | arrakis |
| version | 0.5.0 |
| created_at | 2026-01-20 05:47:54.379344+00 |
| updated_at | 2026-01-20 06:25:36.148466+00 |
| description | A Rust client library for the Dune Analytics API |
| homepage | |
| repository | https://github.com/aoikurokawa/arrakis |
| max_upload_size | |
| id | 2055830 |
| size | 103,085 |
A Rust client library for the Dune Analytics API.
run_sql() that handle polling automaticallyAdd this to your Cargo.toml:
[dependencies]
arrakis = "0.5"
This enables both the async and blocking clients; no extra feature flags are required.
use arrakis::DuneClient;
#[tokio::main]
async fn main() -> Result<(), arrakis::DuneError> {
let client = DuneClient::new("YOUR_API_KEY");
// Execute SQL and wait for results (with 60 second timeout)
let results = client
.run_sql("SELECT * FROM ethereum.transactions LIMIT 10", 60)
.await?;
println!("{:?}", results);
Ok(())
}
use arrakis::blocking::DuneClient;
fn main() -> Result<(), arrakis::DuneError> {
let client = DuneClient::new("YOUR_API_KEY");
// Execute SQL and wait for results (with 60 second timeout)
let results = client.run_sql("SELECT * FROM ethereum.transactions LIMIT 10", 60)?;
println!("{:?}", results);
Ok(())
}
use arrakis::DuneClient;
let client = DuneClient::new("YOUR_API_KEY");
// Simple execution - returns immediately with execution_id
let response = client.execute_sql("SELECT 1").await?;
println!("Execution ID: {}", response.execution_id);
// Wait for results with timeout
let results = client.wait_for_results(&response.execution_id, 120).await?;
use arrakis::{DuneClient, QueryParameter};
let client = DuneClient::new("YOUR_API_KEY");
// Execute a saved query with parameters
let params = vec![
QueryParameter {
key: "address".to_string(),
value: "0x...".to_string(),
parameter_type: "text".to_string(),
},
];
let response = client.execute_query(12345, Some(params), None).await?;
let results = client.run_query(12345, None, None, 60).await?;
let csv_data = client.get_execution_results_csv(&execution_id, None).await?;
client.cancel_execution(&execution_id).await?;
let status = client.get_execution_status(&execution_id).await?;
match status.state {
arrakis::ExecutionState::Completed => println!("Done!"),
arrakis::ExecutionState::Executing => println!("Still running..."),
arrakis::ExecutionState::Failed => println!("Failed!"),
_ => {}
}
| Endpoint | Method |
|---|---|
| Execute SQL | execute_sql() |
| Execute Saved Query | execute_query() |
| Execute Pipeline | execute_pipeline() |
| Get Execution Status | get_execution_status() |
| Get Execution Results (JSON) | get_execution_results() |
| Get Execution Results (CSV) | get_execution_results_csv() |
| Get Latest Query Results | get_latest_results() |
| Get Latest Query Results (CSV) | get_latest_results_csv() |
| Cancel Execution | cancel_execution() |
See the examples directory for more usage patterns:
# Run the async example
DUNE_API_KEY=your_key cargo run --example run_sql
# Run the blocking example
DUNE_API_KEY=your_key cargo run --example sync_run_sql
Licensed under either of:
at your option.