Skip to content

API Request Response Examples

Aaron Cox edited this page Nov 19, 2018 · 5 revisions

API Request/Response Examples


/v1/chain (chain api extensions)

get_accounts

Wrapper for multiple get_account method calls, default limited to 20 accounts at a time.

Request

curl https://eos.greymass.com/v1/chain/get_accounts -d '{"accounts": ["developjesta","solveforanyx"]}'

Response

[
  {"account_name": "developjesta", "head_block_num": 27820743, "head_block_time": "2018-11-19T21:35:11.500", "privileged": false, "last_code_update": "1970-01-01T00:00:00.000", "created": "2018-07-26T04:04:21.500", "core_liquid_balance": "0.5537 EOS", "ram_quota": 13992, "net_weight": 2501, "cpu_weight": 30000, "net_limit": {"used": 121, "available": 188478, "max": 188599}, "cpu_limit": {"used": 379, "available": 182783, "max": 183162}, "ram_usage": 4559, "permissions": [{"perm_name": "active", "parent": "owner", "required_auth": {"threshold": 1, "keys": [{"key": "EOS7yiU4RkY2vUb2pvHxP7B1qcVv9NRbjy4fRmiGUNXQ8iG91R7qN", "weight": 1}], "accounts": [], "waits": []}}, {"perm_name": "owner", "parent": "", "required_auth": {"threshold": 1, "keys": [{"key": "EOS6RWZ1CmDL4B6LdixuertnzxcRuUDac3NQspJEvMnebGcUwhvfX", "weight": 1}], "accounts": [], "waits": []}}], "total_resources": {"owner": "developjesta", "net_weight": "0.2501 EOS", "cpu_weight": "3.0000 EOS", "ram_bytes": 12592}, "self_delegated_bandwidth": {"from": "developjesta", "to": "developjesta", "net_weight": "0.2501 EOS", "cpu_weight": "3.0000 EOS"}, "refund_request": null, "voter_info": {"owner": "developjesta", "proxy": "lukeeosproxy", "producers": [], "staked": 32501, "last_vote_weight": "15730133593.31420135498046875", "proxied_vote_weight": "0.00000000000000000", "is_proxy": 0}}, 
  {"account_name": "solveforanyx", "head_block_num": 27820743, "head_block_time": "2018-11-19T21:35:11.500", "privileged": false, "last_code_update": "1970-01-01T00:00:00.000", "created": "2018-06-11T08:22:08.000", "core_liquid_balance": "0.0036 EOS", "ram_quota": 9550, "net_weight": 10101, "cpu_weight": 10251, "net_limit": {"used": 129, "available": 761582, "max": 761711}, "cpu_limit": {"used": 247, "available": 62339, "max": 62586}, "ram_usage": 5856, "permissions": [{"perm_name": "active", "parent": "owner", "required_auth": {"threshold": 1, "keys": [{"key": "EOS669xxGK5myYajDGq7qGmwsvPpbEFj17bevyC2pWCU6RGxhxL8W", "weight": 1}], "accounts": [], "waits": []}}, {"perm_name": "owner", "parent": "", "required_auth": {"threshold": 1, "keys": [{"key": "EOS5BSogfopbfp1mWpHkVGHrr82weHWH2o6P8EhxPHKqv5VqT1Vce", "weight": 1}], "accounts": [], "waits": []}}], "total_resources": {"owner": "solveforanyx", "net_weight": "1.0101 EOS", "cpu_weight": "1.0251 EOS", "ram_bytes": 8150}, "self_delegated_bandwidth": {"from": "solveforanyx", "to": "solveforanyx", "net_weight": "0.0001 EOS", "cpu_weight": "0.0001 EOS"}, "refund_request": null, "voter_info": {"owner": "solveforanyx", "proxy": "", "producers": ["teamgreymass"], "staked": 2, "last_vote_weight": "187394749398.19927978515625000", "proxied_vote_weight": "187393755266.87161254882812500", "is_proxy": 1}}
]

get_blocks

Wrapper for multiple get_block method calls, default limited to 20 blocks at a time.

Request

curl https://eos.greymass.com/v1/chain/get_blocks -d '{"blocks": [1,2,3,4]}'

Response

[
  {"timestamp": "2018-06-08T08:08:08.500", "producer": "", "confirmed": 1, "previous": "0000000000000000000000000000000000000000000000000000000000000000", "transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000", "action_mroot": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906", "schedule_version": 0, "new_producers": null, "header_extensions": [], "producer_signature": "SIG_K1_111111111111111111111111111111111111111111111111111111111111111116uk5ne", "transactions": [], "block_extensions": [], "id": "00000001405147477ab2f5f51cda427b638191c66d2c59aa392d5c2c98076cb0", "block_num": 1, "ref_block_prefix": 4126519930}, 
  {"timestamp": "2018-06-09T11:56:30.000", "producer": "eosio", "confirmed": 0, "previous": "00000001405147477ab2f5f51cda427b638191c66d2c59aa392d5c2c98076cb0", "transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000", "action_mroot": "e0244db4c02d68ae64dec160310e247bb04e5cb599afb7c14710fbf3f4576c0e", "schedule_version": 0, "new_producers": null, "header_extensions": [], "producer_signature": "SIG_K1_KhKRMeFHa59AzBaqNvq89Mye9uTNsRsY4koYZk4GBxb4UfSEakj4LwxxP5xQVK4q9N32JFhMpjnHa8pgTKNLwP1vXpU6eg", "transactions": [], "block_extensions": [], "id": "0000000267f3e2284b482f3afc2e724be1d6cbc1804532ec62d4e7af47c30693", "block_num": 2, "ref_block_prefix": 976177227}, 
  {"timestamp": "2018-06-09T11:56:30.500", "producer": "eosio", "confirmed": 0, "previous": "0000000267f3e2284b482f3afc2e724be1d6cbc1804532ec62d4e7af47c30693", "transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000", "action_mroot": "1fb815fab36fcb7abda71a209c804db4d7d5c20c164035344f7efecb608d6b53", "schedule_version": 0, "new_producers": null, "header_extensions": [], "producer_signature": "SIG_K1_JvfMecYTVzaXZVWHGbrdBf3Sb19WJuyhM5vUzzt974dJHoZdPuip1Mm45WYMxx7RMjkSrBNz5tj2Ao9d4Bzp7z5tdaZvDt", "transactions": [], "block_extensions": [], "id": "00000003d93442ea55d07be4d515700e2b9737c1f485e8a13ebb3550c1a8bb44", "block_num": 3, "ref_block_prefix": 3833319509}, 
  {"timestamp": "2018-06-09T11:56:31.000", "producer": "eosio", "confirmed": 0, "previous": "00000003d93442ea55d07be4d515700e2b9737c1f485e8a13ebb3550c1a8bb44", "transaction_mroot": "0000000000000000000000000000000000000000000000000000000000000000", "action_mroot": "764d1a85194a5abc6f263ba484028f2d1a2c36c9e2caa68acee68a6081302d76", "schedule_version": 0, "new_producers": null, "header_extensions": [], "producer_signature": "SIG_K1_KYiF3AsSdbuiMuGAiguioH2miPVLro1XaZeWbhGm5zzKBujVUNFsQUJZTnTZGRcKT93B6oy58F6HSiNiga2ebrHjT11BhX", "transactions": [], "block_extensions": [], "id": "00000004faa09f2b6f59515121772032f080c12120d7e4b42c3b9569fb2a9a58", "block_num": 4, "ref_block_prefix": 1364285807}
]

get_currency_balances

Retrieves a set of token balances for an account, based on the tokens contained within the customtokens smart contract.

Request

curl https://eos.greymass.com/v1/chain/get_currency_balances -d '{"account":"developjesta"}'

Response

[{"amount": "0.5537", "code": "eosio.token", "symbol": "EOS"}, {"amount": "0.5006", "code": "ednazztokens", "symbol": "EDNA"}, {"amount": "99.9998", "code": "trybenetwork", "symbol": "TRYBE"}, {"amount": "0.8510", "code": "hirevibeshvt", "symbol": "HVT"}, {"amount": "0.0000", "code": "infinicoinio", "symbol": "INF"}, {"amount": "550.0000", "code": "oo1122334455", "symbol": "IPOS"}, {"amount": "8.9904", "code": "publytoken11", "symbol": "PUB"}, {"amount": "31", "code": "zkstokensr4u", "symbol": "ZKS"}]

Optional Secondary Parameter: tokens

Specifying a secondary parameter of tokens will allow the retrieval of a set list of tokens. These tokens must be formatted as contract_account:token_symbol.

Request

curl https://eos.greymass.com/v1/chain/get_currency_balances -d '{"account":"developjesta", "tokens": ["eosio.token:EOS", "trybenetwork:TRYBE"]}'

Response

[{"amount": "0.5537", "code": "eosio.token", "symbol": "EOS"}, {"amount": "99.9998", "code": "trybenetwork", "symbol": "TRYBE"}]

/v1/api (api metadata)

A series of API methods to retrieve information about the API itself.

get_available_endpoints

Retrieves the API methods that are responding from this endpoint.

Request

curl https://eos.greymass.com/v1/api/get_available_endpoints

Response

{
  "/v1/chain/abi_bin_to_json": true,
  "/v1/chain/abi_json_to_bin": true,
  "/v1/chain/get_abi": true,
  "/v1/chain/get_account": true,
  "/v1/chain/get_accounts": true,
  "/v1/chain/get_block": true,
  "/v1/chain/get_block_header_state": true,
  "/v1/chain/get_blocks": true,
  "/v1/chain/get_code": false,
  "/v1/chain/get_currency_balance": true,
  "/v1/chain/get_currency_balances": true,
  "/v1/chain/get_currency_stats": true,
  "/v1/chain/get_info": true,
  "/v1/chain/get_producers": true,
  "/v1/chain/get_raw_code_and_abi": true,
  "/v1/chain/get_required_keys": true,
  "/v1/chain/get_table_rows": true,
  "/v1/history/get_actions": true,
  "/v1/history/get_controlled_accounts": true,
  "/v1/history/get_key_accounts": true,
  "/v1/history/get_transaction": true
}