JSON command reference

(add here complete JSON command reference)


JSON data is encoded with UTF-8.

Binary fields (eg. sig_p field signature from bencoded DHT resources) must be converted to hex representation as strings.

Quick JSON command examples

In order to use JSON-RPC you must set user/password/port by either command line or configuration file. This is the same as in Bitcoin except that twister config file is /home/user/.twister/twister.conf

To create a new (local) user key:

./twisterd createwalletuser myname

This command returns the secret which can be used to recreate the key in a different computer (in order to access the account). The user should be encouraged to make a copy of this information, either by printing, snapshoting or even writing it down to a piece of paper.

The newly created user only exists in the local database (wallet), so before the user is able to fully use the system (post messages), his public key must be propagated to the network:

./twisterd sendnewusertransaction myname

The above command may take a few seconds to run, depending on your CPU. This is normal.

To create the first (1) public post:

./twisterd newpostmsg myname 1 "hello world"

To add some users to the following list:

./twisterd follow myname '["myname","myfriend"]'

To get the last 5 posts from the users we follow:

./twisterd getposts 5 '[{"username":"myname"},{"username":"myfriend"}]'

To send a new (private) direct message:

./twisterd newdirectmsg myname 2 myfriend "secret message"

Notes for `newdirectmsg`:

  • The post number (2) follows the same numbering as `newpostmsg`, make sure they don’t clash.
  • The recipient must be your follower.

To get the last 10 direct messages to/from remote user:

./twisterd getdirectmsgs myname 10 '[{"username":"myfriend"}]'

Notes for `getdirectmsgs`:

  • These direct message IDs (max_id, since_id etc) are not related to post numbers. The numbering is local and specific to this thread.
  • This function will return messages which have been successfully decrypted upon receiving or that have been sent by this same computer. A different computer, sharing the same account, will see the same received, but not the same sent messages.

To setup your profile:

./twisterd dhtput myname profile s '{"fullname":"My Name","bio":"just another user","location":"nowhere","url":"twister.net.co"}' myname 1

Note: increase the revision number (the last parameter) whenever you want to update something using dhtput.

To obtain the profile of another user:

./twisterd dhtget myfriend profile s

To obtain the full list of commands

./twisterd help

3 comments on “JSON command reference
  1. Daniel Naro says:

    we are trying to execute these instructions (we are still at the very beginning trying to add a user). The computer is an Ubuntu 14.04, and we followed strictly the installation instructions provided in the github. Nevertheless, when executing “./twisterd sendnewusertransaction myname”, we are rejected with the following output:
    “error: {“code”:-22,”message”:”TX rejected”}”
    A google query showed us that it could be related to a Bitcoin problem, but we do not have any idea how to solve this.
    Thank you,

    • mfreitas says:

      Are you just trying to use twister as an user? If so you should try twister-html. JSON commands are only used for scripting directly to the daemon or implementing another frontend.

      • Daniel Naro says:

        We tried at first to use the twister-html, but we were blocked at the screen where an alert told us that it would be the last time to wait (the profile remained red). Nevertheless, our intention is later on to use the JSON commands for scripting.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>