Apibara blog

News and updates about Apibara

Indexing status endpoint for all indexers

This week, we released an update to all Apibara integrations. This update improves the integrations by exposing a new gRPC service to query the indexing status and progress.

Upgrading is easy. Check what integrations you have installed with

apibara plugins list
# NAME       KIND   VERSION
#
# mongo      sink   0.3.0
# postgres   sink   0.3.0
# console    sink   0.3.0
# parquet    sink   0.3.0

Then, upgrade the plugins with the following:

apibara plugin install sink-webhook

Every time you run an indexer, the status server will automatically start in the background. The server binds to a random port to allow you to run multiple indexers simultaneously, so look for the following message to find out how to reach your server.

INFO apibara_sink_common::status: status server listening on 0.0.0.0:8118

Alternatively, specify an address and port with the --status-server-address flag, for example --status-server-address=0.0.0.0:8118.

While the indexer is running, query its state using a gRPC client. In this example, we use grpcurl to query it from the command line. The gRPC service definition is available on GitHub (don't forget to star and subscribe while you're there) so you can generate a client in your favourite language!

# The status server supports reflection!

$ grpcurl -plaintext localhost:8118 list
# apibara.sink.v1.Status
# grpc.reflection.v1alpha.ServerReflection

# The only method exposed is `GetStatus`
$ grpcurl -plaintext localhost:8118 list apibara.sink.v1.Status
# apibara.sink.v1.Status.GetStatus

# Call this method to get the current status
$ grpcurl -plaintext localhost:8118 apibara.sink.v1.Status.GetStatus
# {
#   "status": "SINK_STATUS_RUNNING",
#   "startingBlock": "3129",
#   "currentBlock": "4248",
#   "headBlock": "241673"
# }

This API is the last piece needed before working on the new runner abstraction. The runner API enables developers to start, stop and query indexers through a single API. It's like docker-compose but for indexers.

Apibara

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

© 2024 GNC Labs Limited. All rights reserved.