Skip to main content

Crate apibara_dna_sdk

Crate apibara_dna_sdk 

Source
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:

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§

BearerTokenFromEnv
A BearerTokenProvider that provides a bearer token from an environment variable.
DataStream
A DNA stream returned by StreamClient::stream_data.
InvalidMetadataValue
A possible error when converting a MetadataValue from a string or byte slice.
MetadataMap
A set of gRPC custom metadata entries.
StaticBearerToken
A BearerTokenProvider that provides a static bearer token.
StreamClient
A DNA stream client.
StreamClientBuilder
Configure the StreamClient before connecting to the server.
StreamDataRequestBuilder
This builder is used to create a StreamDataRequest.

Enums§

BearerTokenError
The error returned by implementors of the BearerTokenProvider trait.
DataStreamError
Error type for the data stream client.
StreamClientBuilderError
The error type for the StreamClientBuilder.

Constants§

DEFAULT_ENV_VAR_NAME
The default environment variable name is DNA_TOKEN.

Traits§

BearerTokenProvider
An object that provides a bearer token to authenticate with the DNA server.

Type Aliases§

MetadataKey
A metadata key.
MetadataValue
A metadata value.