Skip to main content

Indexer API

Prerequisites

You must have an access to the Calimero console to interact with Indexer.

Configuration

To be able to call Indexer API you must set few parameters:

  1. Endpoint
  2. Authorization token

Endpoint

Endpoint is constructed from multiple parts:

  • networkId: can be either testnet (with suffix: -calimero-testnet) or mainnet (with suffix:-calimero)
  • shardId: unique identifier of your shard. Consist of user defined shard name and network suffix. All parts are required.
https://api.{{networkId}}.calimero.network/api/v1/shards/{{shardId}}/indexer-graphql/graphql

You can find it directly in the Console.

Authorization token

You must be authorised in order to fetch data. Use existing token or create a new one through the Console UI.

  • Login in Calimero Console.
  • Select the same shard as set in the previous step.
  • Select Security tab from side menu and open Token page.
  • On the Token page find "Create a new token" action and generate a new token.

Authorization token must be provided in header:

Authorization: {{token}}

Indexer API schema is available here

Database structure

Indexer API DB Image

Example:

Method: POST

Url parameters networkId: testnet shardId: test-calimero-testnet (don’t forget to include complete shard id)

https://api.testnet.calimero.network/api/v1/shards/test-calimero-testnet/indexer-graphql/graphql

Headers: Any request to the indexer endpoint must include an Authorization header. The value is the token generated in the previous step.

Body: A GraphQL query

Query

query accounts{
allAccounts{
totalCount
}
}

Response Status 200 is returned if the API call is correct.

{
"data": {
"allAccounts": {
"totalCount": 4
}
}
}

Postman

Example-indexer-api

Apollo Studio

Login to https://studio.apollographql.com/ and create a new project. Open Explorer and set configuration details as mentioned above:

  • endpoint and authorization token

Set Configuration Data

ConfigurationDetails

Enter Query

Query