Rust SDK

Rust SDK for

The Rust SDK spice-rs is the easiest way to query from Rust.

It uses Apache Arrow Flight to efficiently stream data to the client and Apache Arrow Records as data frames.



Add Spice SDK

cargo add spiceai


1. Create a SpiceClient by passing in your API key. Get your free API key at

use spiceai::Client;

async fn main() {
  let mut client = Client::new("API_KEY").await.unwrap();

2. Execute a query and get back an Apache Arrow Flight Record Batch Stream.

let flight_data_stream = client.query("SELECT * FROM eth.recent_blocks LIMIT 10;").await.expect("Error executing query");

3. Iterate through the reader to access the records.

while let Some(batch) = {
    match batch {
        Ok(batch) => {
            /* process batch */
            println!("{:?}", batch)
        Err(e) => {
            /* handle error */

Last updated