Hyperledger Part 3 - REST Server - Video Transcript ### BEGIN ### Hyperledger Composer allows you to quickly build and test Blockchain applications. In this video I'll show you how to install and run composer-rest-server, which you use to generate a Loopback interface to access your blockchain network. Here's what you'll see: * Install composer-rest-server using npm * Create and run the REST interface * Then work with the REST interface in a web browser This video accompanies Part 3 of my Hyperledger Composer Basics tutorial series, which you can find only at IBM Developer. You'll find a link to the series in the video description. Let's get started. Open a Terminal window and enter this command: COMMAND: npm install -g composer-rest-server It may take a few minutes to download the necessary components and compile them for your system. Once composer-rest-server has been installed, verify the version number COMMAND: composer-rest-server -v The REST interface is based on Loopback, and is generated dynamically from your running blockchain network. Before you can generate and run the interface, make sure your network is deployed and running as I showed you in the tutorial. From the Terminal window enter the composer-rest-server command: COMMAND: composer-rest-server When you supply no arguments to composer-rest-server it interviews you for the settings it needs in order to create the Loopback REST interface. composer-rest-server connects to your network, inspects it, generates the Loopback interface and starts a web server on port 3000 on your computer. As a convenience, composer-rest-server shows you the command to enter that will start the Loopback interface with the exact same settings in the future. Next time you launch the REST server, you can use this command, and skip the interview. With the Loopback interface running, open your favorite browser to interact with your network. When composer-rest-server finishes generating the Loopback interface, it starts a web server, and tells you the address. Copy that address and paste it into the browser. When the interface comes up you should see the by now familiar constructs from the IoT Perishable Goods network. Because you chose Always use namespaces when you started composer-rest-server, those are shown in the UI where each component of the namespace is separated by underscores. The final component of each name is the class from the model. Such as the Contract, Grower, and so forth. To see the REST API methods you can invoke on each model construct, click on it, and it expands. And you see GET, POST, and so forth. First instantiate the model by executing the SetupDemo transaction. SetupDemo doesn't take any parameters, so just expand the GET method, and click the Try it out button. An HTTP 200 means the call was successful. There is the Contract. Along with a Grower. An Importer participant. And the Shipment. To invoke the TemperatureReading transaction, navigate to it, select the POST method. Click the example Value JSON, and it appears in the data window. Now modify it with some values you want to submit. I'll just paste these from the tutorial. Click Try it out And there's the HTTP 200 indicating the TemperatureReading transaction succeeded. You can verify that by looking at the Shipment asset, and the temperature reading will have been recorded. And sure enough, there it is. And there you have it: how to install, create, run, and work with composer-rest-interface. Be sure to check out my Hyperledger Composer Basics Tutorial series, available only at IBM Developer. You'll find a link in the video description. I hope you enjoyed the video. I'm Steve Perry. Thanks for watching! I'll see you next time. ### END ###