Skip to content

Latest commit

 

History

History
314 lines (256 loc) · 5.36 KB

provider_api.adoc

File metadata and controls

314 lines (256 loc) · 5.36 KB

Producer service JSON-RPC APIs

Note
This is not supposed to be the public APIs which is called directly by users.
If you want to provide such APIs to the public, you should use this API as the private service which feeds data to your public facing REST APIs server.

Producer default endpoint: http://localhost:5530

HTTP POST request format for all APIs

{
    "method": "_call",
    "params": {
        "call_id": "api_call",
        "api_id": <API_ID: str>,
        "api_params": <API_PARAMS: dict>
    },
    "id": <REQUEST_ID: int>,
  	"jsonrpc": "2.0"
}

Response result format

{
    'status': bool,
    'result': Any
}

Example

Call last_block_height of transform stake_history

{
    "method": "_call",
    "params": {
        "call_id": "api_call",
        "api_id": "last_block_height",
        "api_params": {"transform_id": "stake_history"}
    },
    "id": 123,
  	"jsonrpc": "2.0"
}

Response

{
    "jsonrpc": "2.0",
    "result": {
        "status": 1,
        "result": 12000000
    },
    "id": 123
}

API Reference

For convenience, API reference contains only api_id and api_params

In response return, it covers only format of response['result']['result']

Zone public-icon

List of TRANSFORM_ID:

stake_history
stake_top100
recent_stake_wallets
abstention_stake
funded_wallets
passive_stake_wallets

List of calls

last_block_height

Ask for the last block height value of latest aggregated block of one specific transform

Params

"api_id": "last_block_height"

"api_params": {"transform_id": <TRANSFORM_ID: str>}

Return

int

get_staking_info_last_block

Basic stake metrics of the chain at latest block

Params

"api_id": "get_staking_info_last_block"

Return

{
    'execution_time': '{time_in_seconds}s',
    'height': <BLOCK_HEIGHT: int>,
    'timestamp': <UNIX_TIMESTAMP: int>,
    'total_staking': float,
    'total_staking_wallets': int,
    'total_unstaking': float,
    'total_unstaking_wallets': int
}

get_staking_info

Basic stake metrics of the chain at one specific block in the past

Params

"api_id": "get_staking_info"

"api_params": {"height": <BLOCK_HEIGHT: int>}

Return

{
    'execution_time': '{time_in_seconds}s',
    'height': <BLOCK_HEIGHT: int>,
    'timestamp': <UNIX_TIMESTAMP: int>,
    'total_staking': float,
    'total_staking_wallets': int,
    'total_unstaking': float,
    'total_unstaking_wallets': int
}

latest_unstake_state

List of wallets being in unlock period ( unstaking )

Params

"api_id": "latest_unstake_state"

Return

{
    'height': int,
    'wallets': {
        <ADDRESS: str>: '{staking_amount}:{unlocking_amount}:{request_height}:{unlock_height}',
        ...
    }
}

latest_stake_top100

Latest sorted list of top 100 staking wallets

Params

"api_id": "latest_stake_top100"

Return

{
    'height': int,
    'wallets': {
        <ADDRESS: str>: <STAKE_AMOUNT: float>,
        ...
    }
}

recent_stake_wallets

List of recently stake wallets, ordered by block height

Limited to 200 wallets at max

Params

"api_id": "recent_stake_wallets"

Return

{
    'height': int,
    'wallets': {
        <ADDRESS: str>: '{block_height}:{stake_amount}',
        ...
    }
}

abstention_stake

Latest sorted list of wallets that already staked but not voting all staked ICX

Limited to 200 wallets at max

Params

"api_id": "abstention_stake"

Return

{
    'height': int,
    'wallets': {
        <ADDRESS: str>: '{stake_amount}:{delegation_amount}:{undelegated_amount}',
        ...
    }
}

funded_wallets

Latest sorted list of wallets that hold a minimum amount of ICX

The size of returned wallets is limited to top 10000 wallets despite of the total value

Params

"api_id": "funded_wallets"

"api_params": {"min_balance": <MIN_BALANCE: float>}

Return

{
    'height': int,
    'wallets': {
        <ADDRESS: str>: <BALANCE: float>,
        ...
    },
    'total': int  # The true total number of wallets satisfy minimum balance
}

passive_stake_wallets

Latest list of wallets that have been inactive since the last delegation activity, sorted by longest inactive duration in blocks

The size of returned wallets is limited to top 1000 wallets despite of the total value

Params

"api_id": "passive_stake_wallets"

"api_params": {"max_inactive_duration": <MAX_INACTIVE_DURATION: int>}

Return

{
    'height': int,
    'wallets': {
        <ADDRESS: str>: '{block_height_of_last_delegation}:{inactive_duration_in_blocks}',
        ...
    },
    'total': int  # The true total number of wallets satisfy maximum inactive duration
}