Apibara blog

News and updates about Apibara

New indexer Typescript SDK and integrations

New indexer Typescript SDK

You can now write type-safe indexers using the new Typescript SDK! Use it by importing the @apibara/indexer package from your favourite CDN (like esm.sh or Skypack) and then adding types to your variables and functions.

import type { Config } from "https://esm.sh/@apibara/indexer@0.1.2";
import type {
} from "https://esm.sh/@apibara/indexer@0.1.2/starknet";
import type { Console } from "https://esm.sh/@apibara/indexer@0.1.2/sink/console";

export const config: Config<Starknet, Console> = {
  streamUrl: "https://goerli.starknet.a5a.ch",
  network: "starknet",
  filter: {
    header: {},
  startingBlock: 800_000,
  sinkType: "console",
  sinkOptions: {},

export default function transform(block: Block) {
  return block;

Integrations updates

We updated the integrations based on your feedback. You can update using the apibara CLI.

Start by listing all the integrations you installed:

apibara plugins list
# mongo     sink  0.1.0
# postgres  sink  0.1.0
# webhook   sink  0.1.0
# console   sink  0.1.0
# parquet   sink  0.1.0

Then update them one by one:

apibara plugin install sink-console

Check that the upgrade was successful.

apibara plugins list
# mongo     sink  0.2.0
# postgres  sink  0.2.0
# webhook   sink  0.2.0
# console   sink  0.2.0
# parquet   sink  0.2.0

Changes to the indexer transform function

We changed the indexer’s transform function to accept a single block at the time. Previously this function was invoked with an entire batch of data. Talking with early adopters, we realised this behaviour is confusing, so now the function accepts a block at a time.

Upgrading your indexers is easy; change your transform function as follows:

diff --git a/script.ts b/script.ts
index 999ba82..ea9667a 100644
--- a/old.ts
+++ b/new.ts
@@ -1,8 +1,5 @@
-export default function transform(batch: Block[]) {
-  return batch.flatMap(transformBlock);
-function transformBlock(block: Block) {
+export default function transform(block: Block) {
   // transform a single block
   return block;

Disk persistence for development

Before this release, developers had only two options for persisting the indexer state between restarts:

  • No persistence: the indexer would restart from the beginning every time it was launched. This behaviour is acceptable for the early stages of development but becomes cumbersome later in the development lifecycle.
  • Etcd persistence: store the state in a distributed key-value store and ensure that only one copy of the same indexer runs simultaneously. This is excellent for production usage, but overkill for development.

This release adds a third option:

  • Disk persistence: store the indexer’s state in a file inside a user-specified folder. Developers can restart an indexer simply by deleting its state file. Notice that this model doesn’t ensure that only one copy of the indexer is running at the same time, and so it’s not recommended for production usage. You can enable this option by running your indexer with the --persist-to-fs=<dir> option.

Apibara Installer

We fixed a bug installing the CLI tool on MacOS.

Starknet DNA Service

We updated the Starknet DNA Service to work better with nodes implementing the Starknet JSON-RPC Spec v0.4. Here’s how to upgrade if you’re running a Starknet DNA service:

  • Ensure you’re running Pathfinder v0.72 or newer
  • Ensure you point the Starknet DNA Service to the RPC v0.4 endpoint (e.g. http://<pathfinder0ip>/rpc/v0.4)
  • Upgrade the apibara/starknet Docker image to v1.1.1

Apibara is the fastest platform to build production-grade indexers that connect onchain data to web2 services.

© 2024 GNC Labs Limited. All rights reserved.