Blockchain REST API
Blockchain REST API is an easy way how to automate blockchain processes, it does not implement the full functionality of the blockchain. It is designed for beginners willing to easily connect their software with the blockchain. It is supposed that advanced users will use BIX API for a full featured and fast API connection.
You can access REST api by sending POST requests to the address "/restapi" of the wallet server (the server running GUI).
In the following chapters we presents the features available on REST API. Each chapter contains a link to a simple HTML page with a form allowing to send the vorresponding request. Those pages are self explaining. At each page, you can look at the source code and to see the names of fields to be send as request parameters. The main parameter "action" is sent according to the action required. A parameter "account" usually refers to your account number. All fields are pre-filled with an example value.
Results are in JSON format. Results are generaly an array of records, each record having two fields "hrs" a human readable answer and "dat" an answer designed for automated processing. The "dat" answer is usualy in a simplified "BIX" form with 3 letters tag and information followed.
Upload File to the Blockchain
To upload a file, you have to send its content in a base64 encoded form. If you send a string which is not a valid base64 encoding, the file will not be inserted.
Similarly to the GUI, the file can be stored encrypted in the blockchain. If you want to encrypt it, you shall insert an ancrypt/decrypt key as "uploadskey" parameter. It can be any arbitrary string.
Example form: api/upload.html
Download File from the Blockchain
Downloading a file require the message id under which the file was inserted into the blockchain. If the file is encrypted, the same key must be provided to decrypt the file. The content of the file is returned in base64 encoded form.
Example form: api/download.html
Send Money
To send money you have to enter your account number, destination account, the amount to send and the token type.
Example form: api/send.html
Get the Block Containing a Message
This api function allows to find the block storing a particular message.
Example form: api/getmsgblock.html
Insert New Order to the Exchange
When inserting a new order you have to pick up an order
identification under which you will refer the order. This
orderid shall be a number which can be stored in a 64-bit integer.
The orderid must be unique for your account! I.e. you can not submit two orders with the same orderid.
Parameters "baseToken"/"quoteToken" define the pair you are
going to trade. Side can be either "Buy" aor "Sell". Only the
"Limit" order type is supported at the moment.
Example form: api/exchangeNewOrder.html
Cancel an Order on the Exchange
Orderid is the id of the order to cancel.
Example form: api/exchangeCancelOrder.html