Node API

The node provides REST API to access the current blockchain status.

Get the Events Generated by Program

You can get the generated events by name and the address of the program where they were generated.

Request

GET api/public/events

Parameters

Parameter Optional Type
program Yes hex
name Yes string
transactionId Yes hex
offset Yes integer
count Yes integer

Response

The list of event offsets, transactionIds, addresses, names and datas:

[
    {
        "offset": 0,
        "transactionId": "0123456789abcdef",
        "timestamp": <unix-timestamp (long) like 1565618724247>,
        "address" : "<address of the program emited event>",
        "name": "event-name",
        "data": "<some data from the first event>"                
    },    
    {
        "offset": 1,       
        "transactionId": "fedcba9876543210",
        "timestamp": <unix-timestamp (long) like 1565618724247>,
        "address" : "<address of the program emited event>",
        "name": "another-name"
        "data": "<some data from the second event>"               
    }
    ...
]

Examples

curl <api url>/api/public/events?program=e1941077e00b3cf81a8275788334292d9b2e2f0002bd622444cb37fa5e4d08a0

will return all events for the given program's address in chronological order

curl <api url>/api/public/events?program=e1941077e00b3cf81a8275788334292d9b2e2f0002bd622444cb37fa5e4d08a0&name=myevent

will return all events for the given program's address and name

curl <api url>/api/public/events?program=e1941077e00b3cf81a8275788334292d9b2e2f0002bd622444cb37fa5e4d08a0&name=myevent&offset=10

will return all events starting from offset 10

curl <api url>/api/public/events?program=e1941077e00b3cf81a8275788334292d9b2e2f0002bd622444cb37fa5e4d08a0&name=myevent&offset=10&count=20

will return only the first 20 events from offset 10

curl <api url>/api/public/events?transactionId=07c3271089cc86b21058d50cb72b82bf45c548b2

will return all events for the given transactionId

curl <api url>/api/public/events?transactionId=07c3271089cc86b21058d50cb72b82bf45c548b2

will return all events for the given transactionId

Filtering by Name

When the name is specified, the result is formed in the same manner as when getting events without a name and then filtering these events by name in the memory. This means that offsets can be inconsistent, some of the offsets can be skipped, for example, we can get 1, 2, 5, 10, 100 series of offsets for a certain request.