How to use and explore the cardano api from postman via the swagger.json on Debian/Sid 64bit GNU/Linux
Cardano API
The api is described in detail here via the swagger generated HTML
https://cardanodocs.com/technical/wallet/api/
Postman
What is postman?
https://www.getpostman.com/ Postman is a user friendly GUI to manage API calls. It can be used to run rest api calls and inspect results.
Setup postman
Download the postman app from here
https://app.getpostman.com/app/download/linux64
Untar it
tar -xzf Postman-linux-x64-5.5.0.tar.gz
and run it
cd Postman/
./Postman
Now first you want to turn off your ssl check for now
Go to menu File/Settings
Now turn off the SSL certificate verification
So that it looks like this
Swagger
What is swagger
https://swagger.io/ Swagger claims to be the most popular API framework. It allows you to describe your API in json manner and then generate HTML pages from that to invoke operations. Postman can consume it.
Where is the swagger URI for cardano?
The url is located here https://localhost:8090/swagger.json
but postman cannot import it directly.
Here is how I import it
First I use the jq
tool https://stedolan.github.io/jq/ to make the json pretty
curl -k https://localhost:8090/swagger.json | jq . > pretty.json
And then I replace the raw paths like "/api" with https://localhost:8090/api
sed -e's!\"/api!\"https://localhost:8090/api!g' pretty.json > localized.json
Note I could use jq to do this replacement but that is more work.
Then finally the parameters in postman can be sent via variables which you can specify with {{variablename}} but the swagger specifies them with {variable} name.
You first import the localized.json into postman
And then select the file localized.json
you then want to save to postman v1 and edit the paths to change the ::variable name to {{variablename}} in the paths.
My resulting json file
My updated postman.json is here
https://github.com/h4ck3rm1k3/cardano-sl/blob/master/wallet-new/spec/Cardano%20SL%20Wallet%20Web%20API.postman_collection.json
Variables
Here are the variables you can find the api calls
walletId
The wallet id, get your list from https://localhost:8090/api/walletsaccountId
the account idamount
How much to send
There are three variables where the ADA address is sent
from
From ADA addressto
ADA address to send toaddress
an ADA address you want to send money totransaction
a transaction- passphrase your wallets passphrase
Setting variables
So next you want to setup an environment
Click on Manage environments.
Then add
Then name it my wallet, you can add in the variable names as empty above, or click on bulk edit
Then enter in these
walletId:
accountId:
amount:
from:
to:
address:
transaction:
passphrase:
It will look like this after saving
Now to fill out the variables, lets start by selecting the environment
And then lets start with this api call
https://localhost:8090/api/wallets
When you run that you will see the wallet ids and now you can select that to put into a variable like this
You select the text and then right click, you can store the value in a variable
In
this case select Mywallet.Walletid
Now confirm the values
You can then use variables to call the next api call
https://localhost:8090/api/wallets/{{walletId}}
So this shows you how to use postman to explore and use the cardano API.
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Very informative tutorials. Detailed and precise, that's what I like. It will come in handy when I look into Cardano. I as well as many here do appreciate your contribution.
JGV
Hey @h4ck3rm1k3st33m I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
good job dear @h4ck3rm1k3st33m
@resteemator is a new bot casting votes for its followers. Follow @resteemator and vote this comment to increase your chance to be voted in the future!
Your contribution cannot be approved yet. See the Utopian Rules.
Your objective is "use postman to explore and use the cardano API". However, this is not reflected in the title. Please change the title.
Please edit your contribution to reapply for approval.
You may edit your post here, as shown below:
![](https://steemitimages.com/640x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1509788371/nbgbomithszxs3nxq6gx.png)
You can contact us on Discord.
[utopian-moderator]
Ok, I have edited it!