.. raw:: html
.. raw:: html
.. _rpc_changes_june_2018:
RPC API changes, pre-Betanet (June 2018)
########################################
This document describes the changes made to RPC services provided by the Tezos node in June 2018.
Summary
*******
* Usage of GET requests and query-string parameters when possible
* Easy access to the protocol-specific part of block headers and of operations
* New metadata for block headers (e.g. baker, ...) and for operations (e.g. internal transfers, ...)
* Easy access to delegate's data (list of delegating contracts, frozen balance, ...)
* Prefixed `/blocks` by `/chains/` for easier testing of protocol updates
* Explicit distinction between the listing RPCs and the monitoring RPCs
* Homogeneous error handling
Detailled changes
*****************
Modified RPCs
=============
Some RPCs were simply renamed but some has significant changes in the expected arguments or the returned JSON object. See the notes for details.
In the follwing table:
* `chain_id` is a symbolic chain identifier, e.g. `main` or `test`, or their equivalent Base58-encoded hash, e. g. `NetXzGDuYoAawjv`.
* `block_id` is a symbolic block identifier, e.g. `head` of `genesis`, or any Base58-encoded block hash, e.g. `BKicMfwtgtAL28iD2uZk12PpuS6i2pFysC3syVT44nMNLkGb4QA`. It might also be `head~n` or `~n` to denotes the `n`-th predecessor of `head` or ``.
* `contract_id` is either a implicit contract identifier, i.e. a Base58-encoded public jye hash `tz1btz2tcu8dTwPrtMpyzh1irGdGkAaSE4bY`, or an originated contract identifier, e.g. `KT1fyLSGZ7n2QRynStXUf9ihQtH7k4t4vTLe`.
* `peer_id` is a cryptographic peer identifier, e.g. `idtpXYaRSBXe6KJU6rk1X9ninWt8Bz`.
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| Old path | Notes | New path |
+=========================================================================+==================+==========================================================================+
| | [#blocks_list]_ | GET /chains//blocks |
+ +------------------+--------------------------------------------------------------------------+
| /blocks | [#blocks_mon]_ | GET /monitor/valid_blocks |
+ +------------------+--------------------------------------------------------------------------+
| | [#heads_mon]_ | GET /monitor/heads/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks/ | [#blocks]_ | GET /chains//blocks/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//chain_id | | GET /chains//chain_id |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//complete/ | | GET /chains//blocks//helpers/complete/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//fitness | | GET /chains//blocks//header/shell/fitness |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//hash | | GET /chains//blocks//hash |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//level | | GET /chains//blocks//header/shell/level |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//operations | [#operations]_ | GET /chains//blocks//operations |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//preapply | [#preapply]_ | POST /chains//blocks//helpers/preapply/block |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//predecessor | | GET /chains//blocks//header/shell/predecessor |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//predecessors | [#predecessors]_ | GET /chains//blocks |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| | | GET /chains//blocks//metadata/protocol_hash |
+ /blocks//protocol + [#protocol]_ +--------------------------------------------------------------------------+
| | | GET /chains//blocks//metadata/next_protocol_hash |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/constants | | GET /chains//blocks//context/constants |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/context/contracts | | GET /chains//blocks//context/contracts |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/context/contracts/ | | GET /chains//blocks//context/contracts/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/context/level | [#level]_ | GET /chains//blocks//metadata/protocol_data |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/context/next_level | [#next_level]_ | GET /chains//blocks//helpers/current_level |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/context/nonce/ | | GET /chains//blocks//context/nonces/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/context/voting_period_kind | [#level]_ | GET /chains//blocks//metadata/protocol_data |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/header | | GET /chains//blocks//header/protocol_data |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/apply_operation | [#apply_op]_ | POST /chains//blocks//helpers/preapply/operations |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/forge/operations | | POST /chains//blocks//helpers/forge/operations |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/forge/protocol_data | | POST /chains//blocks//helpers/forge/protocol_data |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/hash_data | | POST /chains//blocks//helpers/scripts/hash_data |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/level/ | [#proto_level]_ | GET /chains//blocks//helpers/current_level |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/levels/ | [#proto_levels]_ | GET /chains//blocks//helpers/levels_in_current_cycle |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/minimal_timestamp | [#rights_bake]_ | GET /chains//blocks//helpers/baking_rights |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/parse/block | | POST /chains//blocks//helpers/parse/block |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/parse/operations | | POST /chains//blocks//helpers/parse/operations |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/rights/baking | [#rights_bake]_ | GET /chains//blocks//helpers/baking_rights |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/rights/baking/delegate/ | [#rights_bake]_ | GET /chains//blocks//helpers/baking_rights |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/rights/baking/level/ | [#rights_bake]_ | GET /chains//blocks//helpers/baking_rights |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/rights/endorsement | [#rights_end]_ | GET /chains//blocks//helpers/endorsing_rights |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/rights/endorsement/delegate/ | [#rights_end]_ | GET /chains//blocks//helpers/endorsing_rights |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/rights/endorsement/level/ | [#rights_end]_ | GET /chains//blocks//helpers/endorsing_rights |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/run_code | | POST /chains//blocks//helpers/scripts/run_code |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/trace_code | | POST /chains//blocks//helpers/scripts/trace_code |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/typecheck_code | | POST /chains//blocks//helpers/scripts/typecheck_code |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/helpers/typecheck_data | | POST /chains//blocks//helpers/scripts/typecheck_data |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//proto/operations | [#operations]_ | GET /chains//blocks//operations |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//raw_context | | GET /chains//blocks//context/raw |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//test_chain | | GET /chains//blocks//metadata/test_chain_status |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /blocks//timestamp | | GET /chains//blocks//header/shell/timestamp |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /bootstrapped | | GET /monitor/bootstrapped |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /complete/ | | GET /chains/main/blocks/head/helpers/complete/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /describe | | GET /describe |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /errors | | GET /errors |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /forge_block_header | | POST /chains/main/blocks/head/helpers/forge/block_header |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /inject_block | | POST /injection/block |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /inject_operation | | POST /injection/operation |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /inject_protocol | | POST /injection/protocol |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /invalid_blocks | | GET /chains//invalid_blocks |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /invalid_blocks/ | | GET /chains//invalid_blocks/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /invalid_blocks//unmark | | DELETE /chains//invalid_blocks/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /mempool/pending_operations | | GET /chains//mempool/pending_operations |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/connections | | GET /network/connections |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/connections/ | | GET /network/connections/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/connections//kick | | DELETE /network/connections/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/connect/ | | PUT /network/points/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/log | | GET /network/log |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/peers | | GET /network/peers/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/peers/ | | GET /network/peers/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/peers//log | | GET /network/peers//log |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /networks/point | | GET /network/points |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/points/ | | GET /network/points/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/points//log | | GET /network/points//log |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/stat | | GET /network/stat |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /p2p/versions | | GET /network/versions |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /protocols | | GET /protocols |
+ + [#protocols]_ +--------------------------------------------------------------------------+
| | | GET /monitor/protocols |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /protocols/ | | GET /protocols/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /workers/block_validator | | GET /workers/block_validator |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /workers/chain_validators | | GET /workers/chain_validators |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /workers/chain_validators/ | | GET /workers/chain_validators/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /workers/peer_validators/ | | GET /workers/chain_validators//peers_validators |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /workers/peer_validators// | | GET /workers/chain_validators//peers_validators/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /workers/prevalidators | | GET /workers/prevalidators |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
| /workers/prevalidators/ | | GET /workers/prevalidators/ |
+-------------------------------------------------------------------------+------------------+--------------------------------------------------------------------------+
.. [#blocks] The return type of `/chain//blocks/` has changed. It now returns more informations:
* the protocol-specific part of the block header is now fully parsed, instead of being returned as hex-encoded bytes. This allows for instance direct access to the block priority.
* some metadata is also added: the baker, the current cycle, the current voting period, ...
* the operations are also fully parsed, in the same way than the previous RPC `/blocks//proto/operations`
* some metadata is also added to the operations. For instance, the list of created contracts, the list of internal transfers, the delegate associated to a endorsement, etc.
The returned JSON being more detailled than previously, new RPCs for fetching partial information are added:
* `/chain//blocks//header`
* `/chain//blocks//metadata`
* `/chain//blocks//operations//`
* `/chain//blocks//operation_hashes//`
.. [#operations] Like the operations listed in `/chain//blocks/` [#blocks]_, the protocol-specific part of operations is now fully-parsed, instead of being returned as hex-encoded bytes.
The same metadata is added: the list of created contracts, the list of internal transfers, the delegate associated to a endorsement, etc.
.. [#blocks_list] The old RPC `/blocks` has been splitted in three: one RPCs for listing heads and blocks, and two RPCs for monitoring new blocks.
The new list RPCs only returns the hash of the current head.
.. [#blocks_mon] This new RPCs allows to monitor all valid blocks. It only returns the hash of the new blocks.
.. [#heads_mon] This new RPCs allows to only monitor the head changes in a given chain. It only returns the hash of the new heads.
.. [#level] The detailled level of a block (i.e. with the cycle and voting period details) is now included in the block metadata.
.. [#next_level] For the same behaviour, this RPC should be called with the `offset` query parameter: e.g. `/chains/main/blocks/head/helpers/current_level?offset=1`.
.. [#preapply] This function now expects a readable JSON object for the block header and the operations, instead of the hex-encoded sequence of bytes it was previously expecting.
.. [#apply_op] This function now expects a readable JSON object for the operation instead of the hex-encoded sequence of bytes it was previously expecting. It also accepts to apply a list of operation in sequence instead of a single operations.
When the operations apply succesfully, this RPC now returns all the metadata associated to operation (the list of created contracts, the list of internal operations, ...) instead of just "success".
.. [#predecessors] For the same behaviour, this RPC should be called with the `length` query parameter: e.g. `/chains/main/blocks?head=&length=12`.
.. [#proto_level] Instead of taking a level as parameter, this RPCs now expects the difference between the expected level and the current level. For instance, for querying the level details for the next block: `/chains/main/blocks/head/helpers/current_level?offset=1`.
.. [#proto_levels] Instead of taking a cycle as parameter, this RPCs now expects the difference between the expected cycle and the current cycle. For instance, for querying the levels in the previous cycle: `/chains/main/blocks/head/helpers/levels_in_current_cycle?offset=-1`.
.. [#protocol] To avoid confusion `protocol_hash` is the hash of protocol used to bake and validate the current block. And `next_protocol_hash` is the hash of the protocol that should be used to bake the next block. The previous RPC `protocol` was returning the `next_protocol_hash`.
.. [#protocols] The old RPC `/protocols` has been splitted in two: one RPCs for listing the known economic protocols, and one RPCs for monitoring new economic protocols. In both cases the new RPCs only returns hash of protocols instead of the protocol sources.
.. [#rights_bake] All the three RPCs used to query baking rights are now grouped in one RPCs. By default, this RPCs returns the first allowed bakers for the next block, in their priority order and with the time at which they are allowed to bake.
Some additional query arguments allow to filter the answer with a given list of delegates, or to query informations for other levels or cycles (in that case the provided timestamp will only be an estimation).
.. [#rights_end] All the three RPCs used to query endorsing rights are now grouped in one RPCs. By default, this RPCs returns the list of allowed endorsers for the next block.
Some additional query arguments allow to filter the answer with a limited list of delegates, or to query informations for others level or cycles.
New RPCs
========
* **GET /chains//blocks//context/delegates**
List all registered delegates.
* **GET /chains//blocks//context/delegates/**
List all information about a given delegate. This includes:
* **GET /chains//blocks//context/delegates//balance**
The full balance of a delegate: i.e. the balance of its delegate account plus the total amount of frozen deposits/rewards/fees.
* **GET /chains//blocks//context/delegates//frozen_balance**
The total amount of frozen deposits/rewards/fees.
* **GET /chains//blocks//context/delegates//frozen_balance_by_cycle**
The details of frozen deposits/rewards/fees indexed by the cycle at the end of which they will be unfrozen.
* **GET /chains//blocks//context/delegates//staking_balance**
The total amount of tokens the delegate stakes for. This includes the balance of all contracts delegated to , but also the delegate own account and the frozen deposits and fees. This does not include the frozen rewards.
* **GET /chains//blocks//context/delegates//delegated_contracts**
The list of contracts that are delegated to .
* **GET /chains//blocks//context/delegates//delegated_balance**
The total balance of all the contracts that delegates to . This excludes the delegate own balance and its frozen balances.
* **GET /chains//blocks//context/delegates//deactivated**
Tells whether the delegate has been tagged as inactive by the system or not, i.e. a delegate is inactive when she did not baked or endorsed any block in the last 5 cycles.
A deactivated delegate won't receive any baking or endorsing rights until she registers itself again as a delegate. No rolls were lost in the process, except if delegating contracts changed their delegate in the meantime of course.
* **GET /chains//blocks//context/delegates//grace_period**
The cycle by the end of which the delegate will be tagged as deactivated if she did not bake or endorse until then.
* **GET /chains//blocks//header**
Simple accessor to a block header, or to its shell-specific or version-specific fragments.
* **GET /chains//blocks//header/shell**
* **GET /chains//blocks//header/protocol_data**
* **GET /chains//blocks//metadata**
Simple accessor to the metadata associated to a block header.
* **GET /chains//blocks//metadata/protocol_data**
The version-specific part of the metadata. For the protocol Alpha this includes, for instance, the baker of the block.
* **GET /chains//blocks//metadata/protocol_hash**
The hash of the protocol used to bake the block.
* **GET /chains//blocks//metadata/next_protocol_hash**
The hash of the protocol that should be used to bake the next block.
* **GET /chains//blocks//operation_hashes**
The list of the hash of the operations included in the block.
Also direct accessor to the `n-th` hash in the `m-th` validation pass.
* **GET /chains//blocks//operation_hashes/**
* **GET /chains//blocks//operation_hashes//**
* **GET /chains//blocks//operations**
The list of the operations included in the block, with their metadata.
Also direct accessor to the `n-th` operation in the `m-th` validation pass.
* **GET /chains/