Can I access multichain using REST calls?

+1 vote
Hi,

I have an application written in Java.

I want to connect with multichain using REST (HTTP) calls. Is this possible?

If yes, please share the tutorial link.

 

Regards

Anuj
asked May 17, 2017 by anuj

1 Answer

+1 vote
 
Best answer
Yes, of course, the entire MultiChain API uses JSON-RPC which is a REST-like interface.

You can find a ton of information including a Java library on this page:

http://www.multichain.com/developers/
answered May 17, 2017 by MultiChain
selected May 17, 2017 by anuj
As per my understanding it's pretty straight forward to execute JSON-RPC API calls from the command line, but how do we execute it in an HTTP call.

So what should be the HTTP URL say to fetch all the addresses from the node?

http://[HOST]:[PORT]/???

Regards
Anuj
You just need to make an HTTP POST request to the right host and port, using HTTP basic authentication with your RPC username and password, and the POST payload containing the JSON which looks something like this:

{"method":"publish","params":["stream1","key","0A0A"],"id":1,"chain_name":"chain1"}

That's the equivalent of:

multichain-cli chain1 publish stream1 key 0A0A

In general you can see the HTTP POST payload for any request by looking at the first line output by multichain-cli.
This clears my query. Thanks a lot.
...