API

Front-end service

Globally, the API is built around 4 methods:

  1. Sending transactions.

  2. Reading account status.

  3. Reading transaction history.

  4. Obtaining more information.

The service is now in alpha version so the API will change.

Sending transaction

Allows sending transactions for confirmation on the peer.

Answer codes:

  • 201 - transaction sent sucessfully.

  • 400 - sending error (there will be an error message in the error field in the reply).

  • 500 - internal error (usually related to data parsing).

POST http://127.0.0.1:8180/v1/backlog

{"commands":[{"data":{"alg":"ed25519","id":"EON-27Z6X-N77SJ-B8GEM","key":"9zUema0KRJFkx2mC4HjEZZ0xCH0MMAdGH34rXfz2p4o="},"deadline":300,"id":"CMD-GC3KG-HB3LK-2ETBN","network":"core.dev.Ti2YGY","publisher":"EON-HRAEQ-8NZL7-C9LHJ","timestamp":1592296782,"type":"core.auth.pk.new","version":1}],"confirmations":{"EON-HRAEQ-8NZL7-C9LHJ":"HyZIa5n3fKxlUY6lnJVjYhAICGnIPi2czQnW7T+h/CDJORR5gJPfmYaIP22/yHCHWhfCkWV4aLZkc2k6XcePAg=="},"deadline":300,"fee":1000,"id":"TX-GC3KG-HFN93-GHF6R","publisher":"EON-HRAEQ-8NZL7-C9LHJ","timestamp":1592296782,"version":1}
{"code":0}

Reading account status

Reading the key/verifying the account's existence

Allows to get a public key by EON-ACC-ID. If the account does not exist, it will return as 404.

GET http://{PROXY}/v1/accounts/{EON-ACC-ID}/state

Example:

GET http://127.0.0.1:8180/v1/accounts/EON-HRAEQ-8NZL7-C9LHJ/state
{
    "id": "EON-HRAEQ-8NZL7-C9LHJ",
    "public_key": {
        "algorithm": "ed25519",
        "value": "s6X2I0RzdMIu60CR4B4bJD6gXy2541I+++BjLwpfPGE="
    }
}

Reading the entire status

Request:

GET http://127.0.0.1:8180/v1/raw/EON-HRAEQ-8NZL7-C9LHJ/

Reply:

{
    "core.auth.pk.alg": "ed25519",
    "core.auth.pk.value": "s6X2I0RzdMIu60CR4B4bJD6gXy2541I+++BjLwpfPGE=",
    "core.balance": 1000000000000000,
    "core.charge.timestamp": 0,
    "core.charge.value": 0,
    "core.created": 0,
    "core.deposit": 1000000000000000,
    "core.version": 1
}

If the account does not exist it will return as empty JSON object: {}.

Reading part of the status

Request:

GET http://127.0.0.1:8180/v1/raw/EON-HRAEQ-8NZL7-C9LHJ/core.auth.pk

Reply:

{
    "alg": "ed25519",
    "value": "s6X2I0RzdMIu60CR4B4bJD6gXy2541I+++BjLwpfPGE="
}

If the account does not exist or the requested data set does not exist it will return as empty JSON object: {}.

If you fully specify the data key, the data in the response will be located by the key ", for example core.auth.pk.alg: {"":"ed25519"}.

Reading the transaction history

Receiving recent transactions

GET http://127.0.0.1:8180/v1/accounts/EON-HRAEQ-8NZL7-C9LHJ/transactions
GET http://127.0.0.1:8180/v1/accounts/EON-HRAEQ-8NZL7-C9LHJ/transactions?page=1&limit=30
[
    {
        "commands": [
            {
                "data": {
                    "alg": "ed25519",
                    "id": "EON-27Z6X-N77SJ-B8GEM",
                    "key": "9zUema0KRJFkx2mC4HjEZZ0xCH0MMAdGH34rXfz2p4o="
                },
                "deadline": 300,
                "id": "CMD-GC3KG-HB3LK-2ETBN",
                "network": "core.dev.Ti2YGY",
                "publisher": "EON-HRAEQ-8NZL7-C9LHJ",
                "timestamp": 1592296782,
                "type": "core.auth.pk.new",
                "version": 1
            }
        ],
        "confirmations": {
            "EON-HRAEQ-8NZL7-C9LHJ": "HyZIa5n3fKxlUY6lnJVjYhAICGnIPi2czQnW7T+h/CDJORR5gJPfmYaIP22/yHCHWhfCkWV4aLZkc2k6XcePAg=="
        },
        "deadline": 300,
        "fee": 1000,
        "id": "TX-GC3KG-HFN93-GHF6R",
        "publisher": "EON-HRAEQ-8NZL7-C9LHJ",
        "timestamp": 1592296782,
        "version": 1
    }
]

Receiving a specific transaction

GET http://127.0.0.1:8180/v1/transactions/TX-GC3KG-HFN93-GHF6R
{
    "block": "block-123",
    "commands": [
        {
            "data": {
                "alg": "ed25519",
                "id": "EON-27Z6X-N77SJ-B8GEM",
                "key": "9zUema0KRJFkx2mC4HjEZZ0xCH0MMAdGH34rXfz2p4o="
            },
            "deadline": 300,
            "id": "CMD-GC3KG-HB3LK-2ETBN",
            "network": "core.dev.Ti2YGY",
            "publisher": "EON-HRAEQ-8NZL7-C9LHJ",
            "timestamp": 1592296782,
            "type": "core.auth.pk.new",
            "version": 1
        }
    ],
    "confirmations": {
        "EON-HRAEQ-8NZL7-C9LHJ": "HyZIa5n3fKxlUY6lnJVjYhAICGnIPi2czQnW7T+h/CDJORR5gJPfmYaIP22/yHCHWhfCkWV4aLZkc2k6XcePAg=="
    },
    "deadline": 300,
    "fee": 1000,
    "id": "TX-GC3KG-HFN93-GHF6R",
    "publisher": "EON-HRAEQ-8NZL7-C9LHJ",
    "timestamp": 1592296782,
    "version": 1
}

Reading block history

Block heading structure

  • id : String - block identifier (just a string, different synchronization algorithms may use a different identifier formats).

  • prev : String - previous block identifier (just a string).

  • height : long - height.

  • timestamp : long - creation time.

Example:

{
    "id": "block-900",
    "prev": "block-899",
    "height": 900,
    "timestamp": 1582095023
}

Receiving the header of the last block

http://127.0.0.1:8180/v1/blocks/last

Receiving a block header by identifier

http://127.0.0.1:8180/v1/blocks/id/block-5

Receiving a block header by height

http://127.0.0.1:8180/v1/blocks/height/900

Receiving block transactions

http://127.0.0.1:8180/v1/blocks/id/block-5/transactions

Reading additional information

Receiving the network identifier

GET http://127.0.0.1:8180/v1/info/network
{
    "network": "core.dev.Ti2YGY"
}

Receiving the current commission

GET http://127.0.0.1:8180/v1/info/fee

Returns 2 parameters - the size and commission for a transaction of this size. This solution should increase the accuracy of commission calculation. To get the commission per byte of a transaction it is necessary to calculate fee / size.

{
    "fee": 1000,
    "size": 1000
}

Receiving the network time

GET http://127.0.0.1:8180/v1/info/timestamp
{
    "timestamp": 1588838916
}

Account registration service (internal use only)

To access the service, you must specify the access token in the request header: Authorization: Bearer <token>.

Check account status

GET http://127.0.0.1:8180/v1/accounts/EON-HRAEQ-8NZL7-C9LHJ

Reply:

{
    "id": "EON-HRAEQ-8NZL7-C9LHJ",
    "public_key": {
        "algorithm": "ed25519",
        "value": "s6X2I0RzdMIu60CR4B4bJD6gXy2541I+++BjLwpfPGE="
    }
}

Register an account

POST http://127.0.0.1:8180/v1/accounts/

{
    "id": "EON-HRAEQ-8NZL7-C9LHJ",
    "public_key": {
        "algorithm": "ed25519",
        "value": "s6X2I0RzdMIu60CR4B4bJD6gXy2541I+++BjLwpfPGE="
    }
}

Possible reply statuses:

  • 201 Created - account successfully created.

  • 400 Bad Request - account creation error. Reply example: {"code":1,"error":"Public key already exists"}.

  • 500 Internal Server Error - internal server error.

Last updated