Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.mvn/wrapper adds maven wrapper with basic maven project Aug 8, 2018
.travis.yml added Travis file Aug 27, 2018
LICENSE added licensing information Aug 27, 2018
mvnw adds maven wrapper with basic maven project Aug 8, 2018
mvnw.cmd adds maven wrapper with basic maven project Aug 8, 2018

Build Status

Amberdata Inbound API

Inbound API Core


Getting started


Amberdata Inbound API

Amberdata provides monitoring, alerting and analytics for blockchains.

The Amberdata platform can accept data from different blockchains. In fact, after working with and researching a few different protocols and implementations (Ethreum, Aion, Stellar, etc), we have found some commonalities between them (and some differences!), and we have developed a global data model.

A more complete documentation on the domain model can be found here: Inbound domain model.

The model defines the different entities and object models that 3rd parties can use to push data into the Amberdata platform via the Inbound API.

Once ingested into the Amberdata platform, these entities are processed by our backend pipeline, where we combine these data sources with off-chain data, extract metrics, and provide insights, analytics and monitoring into the ingested blockchain.

A full Swagger documentation of the REST API is available here and here.

Inbound API Core

This inbound-core project is a library that one can use when developing a new inbound module. You can think of it as a set of utilities which simplifies interacting with the Inbound API directly.

It can be included in any SpringBoot 2.x application, and provides easier means to:

  • create valid requests for objects and sending them to the Inbound API
  • automatically re-sends requests on error
  • provides a basic state storage to track which metrics have already been sent

The main java class is called InboundApiClient and is used to publish metrics instead of interacting with an HTTP client directly. More details available in the Getting Started section.


Here should be instructions of how to add maven repository which contains inbound-domain-model artifact

Use in another project

To add the Amberdata Inbound Core to you Maven project, add this dependency to your pom.xml:


Or to your build.gradle:

dependencies {
    implementation 'io.amberdata.inbound:inbound-core:0.0.4'

Build locally

$ git clone
$ cd inbound-core
$ mvn clean install

Getting Started

The InboundApiClient can be instantiated as a Spring framework component, and needs to configured accordingly to your own blockchain.

Note that you have to have register your blockhain before you start publishing metrics. To do that, follow the instructions: put it here

Three properties control where and how the blockchain data is published to the Inbound API:


Once you have implemented your own inbound module, you can either:

  • set these properties in your own application configuration
  • or pass them as parameters to your application at start time, for example:
$ java -jar <application>.jar                                 \
  --inbound.api.url= \
  --inbound.api.blockchain-id=<blockchain_id_goes_here>     \

Application configuration

To help your SpringBoot application find the InboundApiClient class, its base package needs to be specified in the configuration. The simplest way is to refer to the io.amberdata.inbound.core.InboundCore marker interface in the @ComponentScan annotation:

@ComponentScan(basePackageClasses = InboundCore.class)
public class InboundModuleDemoApplication {
    public static void main (String[] arguments) {, arguments);

Retrieving the Inbound Client

With the above configuration, it is now possible to inject the configured InboundApiClient instance as a dependency:

public class BlocksPublisher {
    private final InboundApiClient inboundApiClient;
    public BlocksPublisher (InboundApiClient inboundApiClient) {
        this.inboundApiClient = inboundApiClient;

To send blockchain objects to the Inbound API, the publish method is called with the appropriate context, for example:

inboundApiClient.publish("/blocks", entities); // sends a list of block entities to the Inbound API endpoint 

Note than you can send an entity (e.g. block) or a list of entities all at once.

Working with state

Saving state

In order to maintain state, each entity can (and probably should) be wrapped into a BlockchainEntityWithState, which contains information about the state:

Block block = new Block.Builder().number(12345L).build();

BlockchainEntityWithState blockWithState = BlockchainEntityWithState.from(
    ResourceState.from("Block", "12345")

inboundApiClient.publish("/blocks", blockWithState);

The BlockchainEntityWithState automatically:

  • publishes the block to the Inbound API
  • stores its number to the internal storage

The latter is for error handling, or in case of crashes, to guarantee that the collection can resume automatically where it left off.

In the example above, ResourceState.from("Block", "12345") provides a generic means to store state:

  • the 1st argument (Block) can be any string which is used to identify the type of entity
  • the 2nd argument (12345) can be any string which is used as the identifier of the entity

Restoring state

Whenever you need information about the last published blockchain entity (e.g. block), you can get it from the internal storage, with an instance of the io.amberdata.inbound.core.state.ResourceStateStorage component, which can be injected into any SpringBoot application:

public class BlocksPublisher {
    private final InboundApiClient     inboundApiClient;
    private final ResourceStateStorage stateStorage;
    public BlocksPublisher (InboundApiClient inboundApiClient, ResourceStateStorage stateStorage) {
        this.inboundApiClient = inboundApiClient;
        this.stateStorage     = stateStorage;

Assuming there is already some state information stored in the internal storage (as soon as some entities have been successfully published to the Inbound API for example), you can get the latest state by calling the getStateToken method, which returns the state's token previously created with ResourceState.from(...):

stateStorage.getStateToken("Block", () -> "<token_default_value>"); 

Note that if no token is found for the key (Block in the example) being requested, the default supplier (passed as a second parameter) is invoked and its value becomes the method's return value (<token_default_value>).

Implementation example

Several examples of Inbound Modules using the inbound-core library are available:


This project is licensed under the Apache Licence 2.0.

See also Contributing

You can’t perform that action at this time.