Postman is a powerful GUI platform to make API development faster & easier, from building API requests through testing, documentation and sharing.
To be able to control RainMachine API through Postman application follow this easy steps:
1. Download and install Postman application or Chrome add-on: https://www.getpostman.com/
Note: You can choose the standalone application depending of your desktop operating system, or Google Chrome browser version.
2. Create a free account or skip this and just simply click the link: "Take me straight to app"
3. Automatically add RainMachine API Postman collection by clicking the button below
Alternatively you can manually add RainMachine API Postman collection:
- Click on upper left "Import" button and choose the option "Import from link"
- Either use this link: https://www.getpostman.com/collections/84ad2fb427ff8f068ef4 or right click on this github RainMachine API Postman collection and chose "Copy Link Address"
- Paste the link and click on "Import" button
4. Create a Postman environment for the RainMachine.
To be able to use Postman with RainMachine an environment containing HOST and PASSWORD must be created.
There are 2 ways to access RainMachine: through local LAN (using RainMachine IP) and through RainMachine Remote Access service (using https://my.rainmachine.com)
4.1 Using Remote Access service:
- - Click on the upper right wheel icon and then on "Manage Environments"
- - Click "Add" button
- - Name the environment, eg: "RainMachine Remote"
- - Add key HOST with
value
: https://my.rainmachine.com - - Add key EMAIL_ACCOUNT with your RainMachine remote access email address as value
- - Add key PASSWORD with your RainMachine password as value
- - Close window
4.2 Using Local LAN Access:
- - Click on the upper right wheel icon and then on "Manage Environments"
- - Click "Add" button
- - Name the environment, eg: "RainMachine Local"
- - Add key HOST with
value
: https://<your rainmachine ip address>:8080/api/4 - - Add key PASSWORD with your RainMachine password as value
- - Close window
IMPORTANT: Go to Postman application menu - Preferences/Settings and make sure that the "SSL certificate verification
" option is OFF. This will help to bypass any auth certification errors.
5. Performing API Calls
Select your newly created environment: "RainMachine Local" or "RainMachine Remote".
To be able to execute API calls with the device the first step is to authenticate with the device. Depending on environment you created there are 2 different ways of performing authentication:
For Local LAN access select:
- (1) POST /auth/login and click on SEND button
- (2) With the access_token obtained from above call perform other API calls eg: GET /api/4/provision?access_token=.... (access_token is automatically appended to calls by Postman)
For Remote Access service (my.rainmachine.com):
- (1) Click POST /login/auth
- If you have a single RainMachine on your account proceed to step (4)
- If you have multiple sprinklers proceed to step (2)
- (2) Click POST /devices/get-sprinklers
This will get a list of sprinklers associated with the account including their sprinklerId and sprinklerUrl. Postman will automatically use the first RainMachine in the list for next call.
- (3) Click POST login-sprinkler
This will authenticate the first RainMachine in the list obtained in step 2 and return a new access_token that will be used in step (4)
- (4) You can now call the RainMachine API by using other Postman links in the collection.
NOTE 1: For certain API calls (especially POST requests) the body of the request should be modified to suit your needs.
NOTE 2: When using the Remote Access authentication the POST /login/auth will automatically change the HOST variable to include your RainMachine ID for further calls. If you intend use Remote Access in another application the https://my.rainmachine.com URL used for authentication will become https://my.rainmachine.com/s/<rainmachine id>/api/4 for future API calls. You can check the Tests tab on Postman call window to see how this variables are being set.
Comments
0 comments
Article is closed for comments.