An Introduction to steemd API Calls, Functions and Usage.

in #steem8 years ago (edited)

The STEEM Network runs on decentralized steemd server nodes which allow for numerous complex functions to be called depending on which API module is referenced.

This page lists various API calls for the steemd binary which acts as a backbone for the entire STEEM network. It should be noted that steemd is different than the STEEM wallet which is cli_wallet which is a completely different program that can be run alongside or independently of a steemd node. STEEM is pretty complex and a number of API call rules apply.

Most bots and other automated scripts accomplish their goal by using the cli_wallet program. You can visit our current documentation on it here: cli_wallet API <-- Under Construction!

 

Before Attempting steemd RPC Calls


In order to access steemd calls you MUST have a full node running and listening to port 8092, on a local machine (or other server you have access to). If you would like more information on setting up your own full STEEM node please check out the following information: EZSTEEM or STEEM-in-a-box

Make sure to set the rpc-endpoint in your STEEM nodes config.ini file.

Or can start your steemd client with the following to run it listening on port 8092:

./steemd --rpc-endpoint=127.0.0.1:8092

This allows our steemd server an RPC endpoint so that we can make calls to the node via RPC-JSON and have the program respond properly.

 

Call Format for steemd


The STEEM network is built off of Graphene architecture meaning that RPC calls are state-less and can be accessed through regular JSON formatted RPC-HTTP.

The following structure should be used when calling the steemd client: { "jsonrpc": "2.0", "method": "get_accounts", "params": [["klye"]], "id": 1 }

Or like

{
"jsonrpc": "2.0",
"method": "get_accounts",
"params": [["klye"]],
"id": 1
}

In the example above the "get_accounts" function calls to the database_api module and would returns information pertaining to the @klye account.

 

Using curl


A simple way to pass command to the same command to the steemd client is by with curl using the following format:

curl --data '{"jsonrpc": "2.0", "method": "get_accounts", "params": [["klye"]], "id": 1 }' http://127.0.0.1:8090/rpc

Calls That Are a Success


When an API call is successful it will return a response JSON formatted. The returned response should also have a similar id number indicating it's from the call you've just put out:

{ "id":1, "result": "data" }

The output of the above curl call invoking the get_accounts function with the id of 1 & the klye username in the only parameter yields a response of:

{"id":1,"result":[{"id":"2.2.9852","name":"klye","owner":{"weight_threshold":1,"account_auths":[],
"key_auths":[["STM7wBNbebQLUi8ayUqSCFHnJRHewrPdD1CCTjJeH2C2ym4gsyeiL",1]]},
"active":{"weight_threshold":1,"account_auths":[],"key_auths":[["STM5pMzmpjvcUnwwt5TJvzWhH6z4Ku5nzcUFA1NGHHJ7RnjFAnxT3",1]]},
"posting":{"weight_threshold":1,"account_auths":[],"key_auths":[["STM8f9jATn1kYzVhuLA7xKMZXS4zDBpJph5qNfMsRFb3iL4raoAYe",1]]},
"memo_key":"STM8XCEUv4bPbXTsHRQctHf2UASzsevoeV8tBYfb6D7btuTt5bzuz",
"json_metadata":"","proxy":"","last_owner_update":"1970-01-01T00:00:00","last_account_update":"1970-01-01T00:00:00","created":"2016-05-25T23:34:03","mined":false,"owner_challenged":false,"active_challenged":false,"last_owner_proved":"1970-01-01T00:00:00","last_active_proved":"1970-01-01T00:00:00","recovery_account":"steem","last_account_recovery":"1970-01-01T00:00:00","comment_count":0,"lifetime_vote_count":0,"post_count":1417,"voting_power":9714,"last_vote_time":"2016-09-18T03:03:09","balance":"0.000 STEEM","sbd_balance":"0.089 SBD","sbd_seconds":"195301723950","sbd_seconds_last_update":"2016-09-16T14:41:15","sbd_last_interest_payment":"2016-09-02T11:15:03","vesting_shares":"8673602.167564 VESTS","vesting_withdraw_rate":"0.000000 VESTS","next_vesting_withdrawal":"1969-12-31T23:59:59","withdrawn":0,"to_withdraw":0,"withdraw_routes":0,"curation_rewards":12180,"posting_rewards":4896836,"proxied_vsf_votes":[0,0,0,0],"witnesses_voted_for":12,"average_bandwidth":236760191,"lifetime_bandwidth":"1827138000000","last_bandwidth_update":"2016-09-18T05:44:51","average_market_bandwidth":122097987,"last_market_bandwidth_update":"2016-09-16T14:41:15","last_post":"2016-09-17T20:57:39","last_root_post":"2016-09-13T16:00:36","post_bandwidth":10000,"last_active":"2016-09-18T05:44:51","activity_shares":"20803969092513102456","last_activity_payout":"1970-01-01T00:00:00","vesting_balance":"0.000 STEEM","reputation":0,"transfer_history":[],"market_history":[],"post_history":[],"vote_history":[],"other_history":[],"witness_votes":["anyx","dantheman","jesta","liondani","pfunk","pharesim","proctologic","riverhead","roadscape","royaltiffany","smooth.witness","someguy123"],"blog_category":{}}]}

As you can see a fair amount of data is given off by some of these calls which can easily be parsed or scraped for whatever intention a coder had for the information.

Calls That Fail


If an API doesn't return a successful call the return output will show some details as shown below:


{
"id": 0
"error": {
"data": {
"code": error-code,
"name": " .. name of exception .."
"message": " .. message of exception ..",
"stack": [ .. stack trace .. ],
},
"code": 1,
},
}

Error handling will spit out some information pertaining to what went wrong. I've included an actual example of a response from a failed call below:

{"id": 177,"error": {"code": 1,"message": "7 bad_cast_exception: Bad Cast\nInvalid cast from string_type to Array\n {"type":"string_type"}\n th_a variant.cpp:537 get_array","data": {"code": 7,"name": "bad_cast_exception","message": "Bad Cast","stack": [{"context": {"level": "error","file": "variant.cpp","line": 537,"method": "get_array","hostname": "","thread_name": "th_a","timestamp": "2016-09-18T06:41:36"},"format": "Invalid cast from ${type} to Array","data" :{"type": "string_type"}}]}}}

As clearly seen above the failure response is in depth however hard for most humans to decypher. I'll be going into further details of how this is broken down in the future.

 

login_api functions


 

login


Call example: { "id": 1, "method": "login", "params": [["username", "password"]]}
Usage: Allows login to accounts on the STEEM network

get_api_by_name


Call example: { "id": 2, "method": "get_api_by_name", "params": [["apiname"]]}
Usage: Returns ??? (more info needed)

 

database_api functions


 

Accounts


 

get_accounts


JSON example: {"id":3,"method":"get_accounts","params":[["username"]]}
Usage: Return displays a large amount of data pertaining to accounts included in call. Call multiples simply by adding a comma between the names.
Example: "params":[["usernamehere", "steem-global"]]

get_account_references


Call example: {"id":4,"method":"get_account_references","params":[["accountid"]]}
Usage: Currently returns an error. Will update in future when more info on this is found.

lookup_account_names


Call example: {"id":5,"method":"lookup_account_names","params":[["username", "callback"]]}
Usage: Returns information about the accounts. Call multiples simply by adding a comma between the names. example: "usernamehere", "steem-global"

lookup_accounts


Call example: {"id":6,"method":"lookup_accounts","params":[["username", "limit"]]}
Usage: Acts as a search function to display usernames containing letters given in the first parameter.

get_account_count


Call example: {"id":7,"method":"get_account_count","params":[]}
Usage: Shows the number of STEEM accounts on the network currently.

get_conversion_requests


Call example: {"id":8,"method":"get_conversion_requests","params":[["username"]]}
Usage: Displays current conversion requests of the given account.

get_account_history


Call example: {"id": 9, method: 'get_account_history', 'params': [["username", "from", "limit"]]}
Usage: Allows you to recall the history of given account on the STEEM network.

get_owner_history


Call example: {"id": 10, method: 'get_owner_history', 'params': [["username"]]}
Usage: Goes back and display if the given account has changed ownership on the blockchain.

get_recovery_request


Call example: {"id": 11, method: 'get_recovery_request', 'params': [["username"]]}
Usage: If the status of the account is currently flagged as wanting recovered will return true, returns "null" otherwise.

 

Voting


 

get_active_votes


Call example: {"id": 12, method: 'get_active_votes', 'params': [[ "username", "permalink"]]}
Usage: Check and see if a post currently has any active votes on it.

get_account_votes


Call example: {"id": 13, method: 'get_account_votes', 'params': [[ "username"]]}
Usage: Lists the last 100+ votes on the given account.

 

Market

 

get_order_book


Call example: {"id":14,"method":"get_order_book","params":["limit"]}
Usage: Returns a list of orders on the internal STEEM market.

get_open_orders


Call example: {"id":15,"method":"get_open_orders","params":["username"]}
Usage: If specified username has orders open on the internal STEEM market it will return them.

get_liquidity_queue


Call example: {"id":16,"method":"get_liquidity_queue","params":["startusername", "limit"]}
Usage: When there are users in the liquidity queue it will return them.

get_current_median_history_price


Call example: {"id":17,"method":"get_current_median_history_price","params":[]}
Usage: Grabs the current median conversion price of SBD / STEEM.

get_feed_history


Call example: {"id":18,"method":"get_chain_properties","params":[]}
Usage: Fetches the conversion history of SBD / STEEM.

 

Content


 

get_content


Call example: {"id":19,"method":"get_content","params":["username","permalink"]}
Usage: Grabs information about the post given in second parameter.

get_content_replies


Call example: {"id":20,"method":"get_content_replies","params":["username","permalink"]}
Usage: Lists all replies on the post given in second parameter.

get_discussions_by_author_before_date


Call example: {"id":21,"method":"get_content_replies","params":[["username", "startpermalink", "beforedate", "limit"]]}
Usage: Grabs discussions from the username given from a starting permalink or start date.

get_replies_by_last_update


Call example: {"id":22,"method":"get_content_replies","params":[["username", "startpermalink", "limit"]]}
Usage: Grabs replies from the username given from a starting permalink.

 

Block Info


 

get_block


Call example: {"id":23,"method":"get_block","params":["blocknumber"]}
Usage: Displays various information about the particular block number given.

get_block_header


Call example: {"id":24,"method":"get_block_header","params":["blocknumber"]}
Usage: Shows the header and other brief info about the given block number.

get_state


Call example: {"id":25,"method":"get_block_header","params":["path"]}
Usage: Gets the current state of the STEEM network. Leave path blank for current info.

get_trending_categories


Call example: {"id":26,"method":"get_trending_categories","params":[["searchafter","limit"]]}
Usage: Allows for the searching of trending categories both current and past.

get_best_categories


Call example: {"id":27,"method":"get_best_categories","params":[["after","limit"]]}
Usage: To be 100% honest I wasn't able to figure this call out yet.

get_active_categories


Call example: {"id":28,"method":"get_active_categories","params":[["after","limit"]]}
Usage: To be 100% honest I wasn't able to figure this call out yet.

get_discussions_in_category_by_total_pending_payout


Call example: Unknown. I couldn't get it to work.
Usage: To be 100% honest I wasn't able to figure this call out yet.

get_discussions_in_category_by_last_update


Call example: Unknown. I couldn't get it to work.
Usage: To be 100% honest I wasn't able to figure this call out yet.

get_discussions_by_last_update


Call example: Unknown. I couldn't get it to work.
Usage: To be 100% honest I wasn't able to figure this call out yet.

 

Transactions / Authority / Validation


 

get_transaction_hex


Call example: {"id":32,"method":"get_transaction_hex","params":["trx"]}
Usage: Fetches the transaction hex digits from the given transaction.

get_transaction


Call example: {"id":33,"method":"get_transaction","params":["txid"]}
Usage: Grabs the details a transaction from a given transactionID.

get_potential_signatures


Call example: {"id":34,"method":"get_potential_signatures","params":["trx"]}
Usage: To be 100% honest I haven't attempted to figure out call out yet.

get_required_signatures


Call example: {"id":35,"method":"get_required_signatures","params":[["trx", "availablekeys"]]}
Usage: To be 100% honest I haven't attempted to figure out call out yet.

verify_authority


Call example: {"id":36,"method":"verify_authority","params":["trx"]}
Usage: To be 100% honest I haven't attempted to figure out call out yet.

verify_account_authority


Call example: {"id":37,"method":"verify_account_authority","params":[["userid/username", "signer"]]}
Usage: To be 100% honest I haven't attempted to figure out call out yet.

 

Globals


 

get_config


Call example: {"id":38,"method":"get_config","params":[]}
Usage: Displays the current configuration of the steemd node.

get_dynamic_global_properties


Call example: {"id":39,"method":"get_dynamic_global_properties","params":[]}
Usage: Shows an overview of various information regarding the current state of the STEEM network.

get_chain_properties


Call example: {"id":40,"method":"get_chain_properties","params":[]}
Usage: Returns current account creation fee, maximum block size and SBD(Steem Dollar) interest rate.

get_hardfork_version


Call example: {"id":40,"method":"get_hardfork_version","params":[]}
Usage: The current version of STEEM hardfork will be displayed.

get_next_scheduled_hardfork


Call example: {"id":42,"method":"get_hardfork_version","params":[]}
Usage: Gives a date and version as to when the next version of STEEM is expected.

 

Witnesses


 

get_witnesses


Call example: {"id":43,"method":"get_witnesses","params":["witnessid"]}
Usage: I've not looked into what this call does yet, will shortly.

get_witness_by_account


Call example: {"id":44,"method":"get_witness_by_account","params":["username"]}
Usage: When invoked answers true if the username given is a witness or "result": null if not.

get_witnesses_by_vote


Call example: {"id":45,"method":"get_witnesses_by_vote","params":[["username/blank", "limit"]]}
Usage: Displays a list of the top witnesses by order of witness votes.

lookup_witness_accounts


Call example: {"id":46,"method":"lookup_witness_accounts","params":[["searchusername", "limit"]]}
Usage: Returns a list of every user that has declared their intent to run as witness.

get_witness_count


Call example: {"id":47,"method":"get_witness_count","params":[]}
Usage: Calculates and displays the total number of accounts that have shown intent to run for witness.

get_active_witnesses


Call example: {"id":48,"method":"get_active_witnesses","params":[]}
Usage: Shows the current active witnesses (Top 21 last I checked, might be wrong).

get_miner_queue


Call example: {"id":49,"method":"get_miner_queue","params":[]}
Usage: Creates a list of miners waiting to get into the DPOW line to create a block.

 

Subscriptions


 

set_subscribe_callback


Call example: {"id":50,"method":"set_subscribe_callback","params":[["cb", "clearfilter"]]}
Usage: I've not yet looked into how this function works, sorry. Will update soon.

set_pending_transaction_callback


Call example: {"id":51,"method":"set_pending_transaction_callback","params":["cb"]}
Usage: I've not yet looked into how this function works, sorry. Will update soon.

set_block_applied_callback


Call example: {"id":52,"method":"set_block_applied_callback","params":["cb"]}
Usage: I've not yet looked into how this function works, sorry. Will update soon.

cancel_all_subscriptions


Call example: {"id":53,"method":"cancel_all_subscriptions","params":["cb"]}
Usage: I've not yet looked into how this function works, but it seemingly appears to cancel subscriptions.

 

Tags


 

get_trending_tags


Call example: {"id":54,"method":"get_trending_tags","params":[["aftertag", "limit"]]}
Usage: Displays a list of tags containing the first parameter (almost as if parent and "spin-off" tags).

get_discussions_by_trending


Call example: {"id":55,"method":"get_discussions_by_trending","params":[{"tag":"tagnamehere", "limit":"10"}]}
Usage: Displays a list of tags containing the first parameter (almost as if parent and "spin-off" tags).

get_discussions_by_created


Call example: {"id":56,"method":"get_discussions_by_created","params":[{"tag":"tagnamehere","limit":"10"}]}
Usage: Displays a list of post from the start of the tags containing the first parameter.

get_discussions_by_active


Call example: {"id":57,"method":"get_discussions_by_active","params":[{"tag":"tagnamehere","limit":"10"}]}
Usage: Displays a list of active posts from tag contained the first parameter.

get_discussions_by_cashout


Call example: {"id":58,"method":"get_discussions_by_cashout","params":[{"tag":"tagnamehere","limit":"10"}]}
Usage: Displays a list of posts with outstanding payouts from the tag contained the first parameter.

get_discussions_by_payout


Call example: {"id":59,"method":"get_discussions_by_payout","params":[{"tag":"tagnamehere","limit":"10"}]}
Usage: Couldn't seem to get this one to work properly, will look at it more closely soon.

get_discussions_by_votes


Call example: {"id":60,"method":"get_discussions_by_votes","params":[{"tag":"tagnamehere","limit":"10"}]}
Usage: Returns a list of posts sorted by votes from the tag contained the first parameter.

get_discussions_by_children


Call example: {"id":61,"method":"get_discussions_by_children","params":[{"tag":"tagnamehere","limit":"10"}]}
Usage: Calls forth a list of child posts from the tag contained the first parameter.

get_discussions_by_hot


Call example: {"id":62,"method":"get_discussions_by_hot","params":[{"tag":"tagnamehere","limit":"10"}]}
Usage: Conjures up a list of the hottest posts from the tag contained the first parameter.

get_discussions_by_total_pending_payout


Call example: {"id":63,"method":"get_discussions_by_total_pending_payout","params":[{"tag":"tagnamehere","limit":"10"}]}
Usage: I haven't checked out this one yet but I imagine it does something similar to its siblings above.

 

Keys


 

get_key_references


Call example: {"id":64,"method":"get_key_references","params":["key"]}
Usage: Not had the chance to look into this yet.


This is a work in progress

I'd like to ask the community in aide in helping me explain the calls and functions I was unable to figure out in the comments section below. This information is being mirrored on my site steem.global STEEM Network News & Node and hopefully once I'm done filling in the gaps here and making a more comprehensive write-up as well as start the cli_wallet write up it will allow for enough documentation for coinpayments.net to want to have a whack at integrating our currency and token into their payment gateway platform allowing for EASY woocommerce integrations of SBD/ STEEM.

Thanks for reading. I hope you find this info useful!

Sort:  

Thanks for a nice summary.
Sadly, I have a feeling it is a bit outdated by now - which may be why the Python steemd interface seems to only partially work.

Do you know if there is a newer description of it?

Damn that's some comprehensive work you are doing man!!

This is just the groundwork sir. I'll go into greater detail when I have the time. The goal now is to get the basics down in a readable format so people can start experimenting themselves while I shift over to starting to document the cli_wallet before coming back to this information to finish it off.

I've got things I need to accomplish and this is how to do it.

This is excellent information. I can't wait to get in front of a computer running a node and start playing with it.

I had to set one up in order to get this document done up!

You may be able to pass curl commands and steemd JSON calls to my Full Steem Node located at global.steem:8090

This is going to help many users for sure. This is part of your mission to get documented for coinpayments.com aswell correct?..from what I have read in your other post it is. I know many merchants are hoping for a simple payment solution and you are making this possible. ..Great stuff mate.

Yes this is all part of the bigger mission of getting coinpayments to accept SBD / STEEM on their platform.

Sometimes it takes one guy to do the work. If I happen to be the guy I'm ok with that because I know it will help plenty of others be successful with their lives.

Yeah, very generous of you to take it on. Mate, I wish I could help out, my coding skills etc is nonexsistent, but if there is anything else you need help with let me know in steemit.chat and i will.

No worries. I admit I'm not the strongest coder either but I do possess enough understanding to be able to parse some of it and spit it out in easily digestible formats for others.

Is there any way to check for total amount of votes per account?

Or is this not possible because many only vote a certain % so they don't count the amount.

I'll look into it for you.

Thanks. This will be very useful for reference.

This is only the start of reference documentation. I'll get a better version done here in the near future.

Really nice job writing all this out @klye

It did in fact take me hours to write this.. as well as it took me setting up a full node to check some of the calls myself. Labour intensive. :P

Really cool info man! Thanks!

No worries! I'll do a more comprehensive write up when time allows.

Thank you because I was looking for informarion on the API.

Tons of people have been. It wasn't really documented at all before this other than a few examples here or there.

This isn't the final version by any means either. I'll be going into more detail later when I have time. :)

It's worth mentioning that some calls return different data for the same parameters depending on the age of the data.

For example, get_content returns the votes in the active_votes field, but this is cleared after each payout. After the last payout, this will be empty so you cannot see (via this call) the votes for that post.

The API has a lot of idiosyncrasies like this and I hope they get included in the documentation, too.

Awesome! thank you for sharing your info. I did notice a few naunces like this but will have to go back and include them in the final version. Today I'm working on getting some cli_wallet instructions written for the accessing the API.

Coin Marketplace

STEEM 0.15
TRX 0.15
JST 0.028
BTC 53807.82
ETH 2237.98
USDT 1.00
SBD 2.30