apibara_dna_sdk/lib.rs
1//! # Apibara SDK
2//!
3//! This crate is the official SDK for [Apibara](https://www.apibara.com).
4//! Apibara is the fastest way to build production-grade web3 indexers.
5//!
6//! The SDK provides the following features:
7//!
8//! - A client to stream onchain data. The client handles authentication and connection timeouts.
9//! - Chain-specific filter builders and data parsers.
10//!
11//! ## Features
12//!
13//! By default, the SDK is built without any chain support. To enable support for a chain, you need to enable the corresponding feature.
14//!
15//! - `starknet`: enable Starknet support.
16//!
17//! ## Authentication
18//!
19//! If you're connected to a protected endpoint (like the ones hosted by Apibara), you need to provide a valid API key.
20//!
21//! The main mechanism to provide authentication is through the [BearerTokenProvider] trait. We provide two implementations:
22//!
23//! - [BearerTokenFromEnv]: reads the API key from the `DNA_TOKEN` environment variable.
24//! - [StaticBearerToken]: uses the API key provided at construction.
25//!
26//! You are free to implement your own bearer token provider, for example one that fetches the token from a remote vault server.
27//!
28//! ## Connection issues
29//!
30//! The client does not reconnect automatically. If the connection is lost, you need to create a new client.
31//! This is done to prevent your application not processing a block or processing the same block twice.
32//! By handling reconnection within your application, you can decide whether you want to process blocks
33//! at least or at most once.
34
35mod auth;
36mod builder;
37mod client;
38mod interceptor;
39mod request;
40#[cfg(feature = "starknet")]
41pub mod starknet;
42
43pub use crate::auth::*;
44pub use crate::builder::*;
45pub use crate::client::*;
46pub use crate::interceptor::{InvalidMetadataValue, MetadataKey, MetadataMap, MetadataValue};
47pub use crate::request::StreamDataRequestBuilder;
48
49/// Contains the gRPC types to interact with the Apibara DNA service.
50pub use apibara_dna_protocol::dna::stream as proto;