Expand description
§Apibara SDK
This crate is the official SDK for Apibara. Apibara is the fastest way to build production-grade web3 indexers.
The SDK provides the following features:
- A client to stream onchain data. The client handles authentication and connection timeouts.
- Chain-specific filter builders and data parsers.
§Features
By default, the SDK is built without any chain support. To enable support for a chain, you need to enable the corresponding feature.
starknet: enable Starknet support.
§Authentication
If you’re connected to a protected endpoint (like the ones hosted by Apibara), you need to provide a valid API key.
The main mechanism to provide authentication is through the BearerTokenProvider trait. We provide two implementations:
- BearerTokenFromEnv: reads the API key from the
DNA_TOKENenvironment variable. - StaticBearerToken: uses the API key provided at construction.
You are free to implement your own bearer token provider, for example one that fetches the token from a remote vault server.
§Connection issues
The client does not reconnect automatically. If the connection is lost, you need to create a new client. This is done to prevent your application not processing a block or processing the same block twice. By handling reconnection within your application, you can decide whether you want to process blocks at least or at most once.
Modules§
- proto
- Contains the gRPC types to interact with the Apibara DNA service.
- starknet
- Starknet-specific types and utilities.
Structs§
- Bearer
Token From Env - A BearerTokenProvider that provides a bearer token from an environment variable.
- Data
Stream - A DNA stream returned by StreamClient::stream_data.
- Invalid
Metadata Value - A possible error when converting a
MetadataValuefrom a string or byte slice. - Metadata
Map - A set of gRPC custom metadata entries.
- Static
Bearer Token - A BearerTokenProvider that provides a static bearer token.
- Stream
Client - A DNA stream client.
- Stream
Client Builder - Configure the StreamClient before connecting to the server.
- Stream
Data Request Builder - This builder is used to create a StreamDataRequest.
Enums§
- Bearer
Token Error - The error returned by implementors of the BearerTokenProvider trait.
- Data
Stream Error - Error type for the data stream client.
- Stream
Client Builder Error - The error type for the StreamClientBuilder.
Constants§
- DEFAULT_
ENV_ VAR_ NAME - The default environment variable name is
DNA_TOKEN.
Traits§
- Bearer
Token Provider - An object that provides a bearer token to authenticate with the DNA server.
Type Aliases§
- Metadata
Key - A metadata key.
- Metadata
Value - A metadata value.