Home

Index API

DijetsNodeGo can be configured to run with an indexer. That is, it saves (indexes) every container (a block, vertex or transaction) it accepts on the Value Chain, Method Chain and Utility Chain. To run DijetsNodeGo with indexing enabled, set command line flag --index-enabled to true. DijetsNodeGo will only index containers that are accepted when running with --index-enabled set to true. To ensure your node has a complete index, run a node with a fresh database and --index-enabled set to true. The node will accept every block, vertex and transaction in the network history during bootstrapping, ensuring your index is complete. It is OK to turn off your node if it is running with indexing enabled. If it restarts with indexing still enabled, it will accept all containers that were accepted while it was offline. The indexer should never fail to index an accepted block, vertex or transaction.

Indexed containers (that is, accepted blocks, vertices and transactions) are timestamped with the time at which the node accepted that container. Note that if the container was indexed during bootstrapping, other nodes may have accepted the container much earlier. Every container indexed during bootstrapping will be timestamped with the time at which the node bootstrapped, not when it was first accepted by the network.

Note that for DAGs (including the Value Chain), nodes may accept vertices and transactions in a different order from one another.

If --index-enabled is changed to false from true, Dijets Node won't start as doing so would cause a previously complete index to become incomplete, unless the user explicitly says to do so with --index-allow-incomplete. This protects you from accidentally running with indexing disabled, after previously running with it enabled, which would result in an incomplete index.

This document shows how to query data from Dijets Node's Index API. The Index API is only available when running with --index-enabled.

Go Client#

There is a Go implementation of an Index API client. This client can be used inside a Go program to connect to a Dijets node instance that is running with the Index API enabled and make calls to the Index API.

Format#

This API uses the json 2.0 RPC format. For more information on making JSON RPC calls, see here.

Endpoints#

Each chain has one or more index. To see if a Utility Chain block is accepted, for example, send an API call to the Utility Chain block index. To see if an Value Chain vertex is accepted, for example, send an API call to the Value Chain vertex index.

Utility Chain Blocks#


_10
/ext/index/C/block

Method Chain Blocks#


_10
/ext/index/P/block

Value Chain Transactions#


_10
/ext/index/X/tx

Value Chain Azimuth IDs#


_10
/ext/index/X/vtx

Methods#

index.getContainerByID#

Get container by ID.

Signature:


_10
index.getContainerByID({
_10
id: string,
_10
encoding: string
_10
}) -> {
_10
id: string,
_10
bytes: string,
_10
timestamp: string,
_10
encoding: string,
_10
index: string
_10
}

Request:

  • id is the container's ID
  • encoding is "hex" only.

Response:

  • id is the container's ID
  • bytes is the byte representation of the container
  • timestamp is the time at which this node accepted the container
  • encoding is "hex" only.
  • index is how many containers were accepted in this index before this one

Example Call:


_11
curl --location --request POST 'localhost:9650/ext/index/X/tx' \
_11
--header 'Content-Type: application/json' \
_11
--data-raw '{
_11
"jsonrpc": "2.0",
_11
"method": "index.getContainerByID",
_11
"params": {
_11
"id": "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY",
_11
"encoding":"hex"
_11
},
_11
"id": 1
_11
}'

Example Response:


_11
{
_11
"jsonrpc": "2.0",
_11
"id": 1,
_11
"result": {
_11
"id": "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY",
_11
"bytes": "0x00000000000400003039d891ad56056d9c01f18f43f58b5c784ad07a4a49cf3d1f11623804b5cba2c6bf00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000070429ccc5c5eb3b80000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000050429d069189e0000000000010000000000000000c85fc1980a77c5da78fe5486233fc09a769bb812bcb2cc548cf9495d046b3f1b00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c0000000100000009000000011cdb75d4e0b0aeaba2ebc1ef208373fedc1ebbb498f8385ad6fb537211d1523a70d903b884da77d963d56f163191295589329b5710113234934d0fd59c01676b00b63d2108",
_11
"timestamp": "2021-04-02T15:34:00.262979-07:00",
_11
"encoding": "hex",
_11
"index": "0"
_11
}
_11
}

index.getContainerByIndex#

Get container by index. The first container accepted is at index 0, the second is at index 1, etc.

Signature:


_10
index.getContainerByIndex({
_10
index: uint64,
_10
encoding: string
_10
}) -> {
_10
id: string,
_10
bytes: string,
_10
timestamp: string,
_10
encoding: string,
_10
index: string
_10
}

Request:

  • index is how many containers were accepted in this index before this one
  • encoding is "hex" only.

Response:

  • id is the container's ID
  • bytes is the byte representation of the container
  • timestamp is the time at which this node accepted the container
  • index is how many containers were accepted in this index before this one
  • encoding is "hex" only.

Example Call:


_11
curl --location --request POST 'localhost:9650/ext/index/X/tx' \
_11
--header 'Content-Type: application/json' \
_11
--data-raw '{
_11
"jsonrpc": "2.0",
_11
"method": "index.getContainerByIndex",
_11
"params": {
_11
"index":0,
_11
"encoding": "hex"
_11
},
_11
"id": 1
_11
}'

Example Response:


_11
{
_11
"jsonrpc": "2.0",
_11
"id": 1,
_11
"result": {
_11
"id": "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY",
_11
"bytes": "0x00000000000400003039d891ad56056d9c01f18f43f58b5c784ad07a4a49cf3d1f11623804b5cba2c6bf00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000070429ccc5c5eb3b80000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000050429d069189e0000000000010000000000000000c85fc1980a77c5da78fe5486233fc09a769bb812bcb2cc548cf9495d046b3f1b00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c0000000100000009000000011cdb75d4e0b0aeaba2ebc1ef208373fedc1ebbb498f8385ad6fb537211d1523a70d903b884da77d963d56f163191295589329b5710113234934d0fd59c01676b00b63d2108",
_11
"timestamp": "2021-04-02T15:34:00.262979-07:00",
_11
"encoding": "hex",
_11
"index": "0"
_11
}
_11
}

index.getContainerRange#

Returns the transactions at index [startIndex], [startIndex+1], ... , [startIndex+n-1]

  • If [n] == 0, returns an empty response (for example: null).
  • If [startIndex] > the last accepted index, returns an error (unless the above apply.)
  • If [n] > [MaxFetchedByRange], returns an error.
  • If we run out of transactions, returns the ones fetched before running out.
  • numToFetch must be in [0,1024].

Signature:


_11
index.getContainerRange({
_11
startIndex: uint64,
_11
numToFetch: uint64,
_11
encoding: string
_11
}) -> []{
_11
id: string,
_11
bytes: string,
_11
timestamp: string,
_11
encoding: string,
_11
index: string
_11
}

Request:

  • startIndex is the beginning index
  • numToFetch is the number of containers to fetch
  • encoding is "hex" only.

Response:

  • id is the container's ID
  • bytes is the byte representation of the container
  • timestamp is the time at which this node accepted the container
  • encoding is "hex" only.
  • index is how many containers were accepted in this index before this one

Example Call:


_12
curl --location --request POST 'localhost:9650/ext/index/X/tx' \
_12
--header 'Content-Type: application/json' \
_12
--data-raw '{
_12
"jsonrpc": "2.0",
_12
"method": "index.getContainerRange",
_12
"params": {
_12
"startIndex":0,
_12
"numToFetch":100,
_12
"encoding": "hex"
_12
},
_12
"id": 1
_12
}'

Example Response:


_13
{
_13
"jsonrpc": "2.0",
_13
"id": 1,
_13
"result": [
_13
{
_13
"id": "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY",
_13
"bytes": "0x00000000000400003039d891ad56056d9c01f18f43f58b5c784ad07a4a49cf3d1f11623804b5cba2c6bf00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000070429ccc5c5eb3b80000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000050429d069189e0000000000010000000000000000c85fc1980a77c5da78fe5486233fc09a769bb812bcb2cc548cf9495d046b3f1b00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c0000000100000009000000011cdb75d4e0b0aeaba2ebc1ef208373fedc1ebbb498f8385ad6fb537211d1523a70d903b884da77d963d56f163191295589329b5710113234934d0fd59c01676b00b63d2108",
_13
"timestamp": "2021-04-02T15:34:00.262979-07:00",
_13
"encoding": "hex",
_13
"index": "0"
_13
}
_13
]
_13
}

index.getIndex#

Get a container's index.

Signature:


_10
index.getIndex({
_10
id: string,
_10
encoding: string
_10
}) -> {
_10
index: string
_10
}

Request:

  • id is the ID of the container to fetch
  • encoding is "hex" only.

Response:

  • index is how many containers were accepted in this index before this one

Example Call:


_11
curl --location --request POST 'localhost:9650/ext/index/X/tx' \
_11
--header 'Content-Type: application/json' \
_11
--data-raw '{
_11
"jsonrpc": "2.0",
_11
"method": "index.getIndex",
_11
"params": {
_11
"id":"6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY",
_11
"encoding": "hex"
_11
},
_11
"id": 1
_11
}'

Example Response:


_10
{
_10
"jsonrpc": "2.0",
_10
"result": {
_10
"index": "0"
_10
},
_10
"id": 1
_10
}

index.getLastAccepted#

Get the most recently accepted container.

Signature:


_10
index.getLastAccepted({
_10
encoding:string
_10
}) -> {
_10
id: string,
_10
bytes: string,
_10
timestamp: string,
_10
encoding: string,
_10
index: string
_10
}

Request:

  • encoding is "hex" only.

Response:

  • id is the container's ID
  • bytes is the byte representation of the container
  • timestamp is the time at which this node accepted the container
  • encoding is "hex" only.

Example Call:


_10
curl --location --request POST 'localhost:9650/ext/index/X/tx' \
_10
--header 'Content-Type: application/json' \
_10
--data-raw '{
_10
"jsonrpc": "2.0",
_10
"method": "index.getLastAccepted",
_10
"params": {
_10
"encoding": "hex"
_10
},
_10
"id": 1
_10
}'

Example Response:


_11
{
_11
"jsonrpc": "2.0",
_11
"id": 1,
_11
"result": {
_11
"id": "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY",
_11
"bytes": "0x00000000000400003039d891ad56056d9c01f18f43f58b5c784ad07a4a49cf3d1f11623804b5cba2c6bf00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000070429ccc5c5eb3b80000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db000000050429d069189e0000000000010000000000000000c85fc1980a77c5da78fe5486233fc09a769bb812bcb2cc548cf9495d046b3f1b00000001dbcf890f77f49b96857648b72b77f9f82937f28a68704af05da0dc12ba53f2db00000007000003a352a38240000000000000000000000001000000013cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c0000000100000009000000011cdb75d4e0b0aeaba2ebc1ef208373fedc1ebbb498f8385ad6fb537211d1523a70d903b884da77d963d56f163191295589329b5710113234934d0fd59c01676b00b63d2108",
_11
"timestamp": "2021-04-02T15:34:00.262979-07:00",
_11
"encoding": "hex",
_11
"index": "0"
_11
}
_11
}

index.isAccepted#

Returns true if the container is in this index.

Signature:


_10
index.isAccepted({
_10
id: string,
_10
encoding: string
_10
}) -> {
_10
isAccepted: bool
_10
}

Request:

  • id is the ID of the container to fetch
  • encoding is "hex" only.

Response:

  • isAccepted displays if the container has been accepted

Example Call:


_11
curl --location --request POST 'localhost:9650/ext/index/X/tx' \
_11
--header 'Content-Type: application/json' \
_11
--data-raw '{
_11
"jsonrpc": "2.0",
_11
"method": "index.isAccepted",
_11
"params": {
_11
"id":"6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY",
_11
"encoding": "hex"
_11
},
_11
"id": 1
_11
}'

Example Response:


_10
{
_10
"jsonrpc": "2.0",
_10
"result": {
_10
"isAccepted": true
_10
},
_10
"id": 1
_10
}