This will authenticate the account with RainMachine Remote Access Service and return a JSON response. Check the errorType field:

- If 0 then get the access_token field and proceed to step (4)

- If -1 then user has multiple sprinklers, get the access_token and proceed to step (2)

- (2) POSThttps://my.rainmachine.com/devices/get-sprinklers?access_token="obtained in step 1" with body as above. This will get a list of sprinklers associated with the account including their sprinklerId and sprinklerUrl.

- (2) You can now call the RainMachine API with the access_token obtained from above call:

GET https://rainmachine_ip:8080/api/4/provision?access_token=....

Important: When doing POST requests make sure you include "Content-type: application/json" header and POST call has a body. If you are performing a POST without a body make sure you sent "Content-length: 0" header.

Here apiVer means the version of the API available on device, hwVer is the hardware version of the device and swVer is the rainmachine app version.Notice that this API call didn’t require any authentification with the device, but except this call and auth/login call all other calls must use a OAuth token otherwise an error 401 Unauthorized will be returned.

Authenticating with the device:

The first step on working with API calls that require authentification is obtaining a OAuth token. Once you have this token you should add it to all your requests like this:https://192.168.12.175:8080/api/4/program?access_token=YOUR_ACCESS_TOKEN.If you don’t have a token you must login to the device first. This is accomplished by a POST request with /auth/login as URL and with json body containing the password:

You can parse this json to extract the required data, using your favorite language. More information about the API and JSON responses can be found here: http://docs.rainmachine.apiary.io/

A more complex example:In this example we’ll use information provided by an API call to perform another call. The task that we want to perform is to activate another weather parser on device that uses Met.no weather service. Once activated this parser will run periodically and fetch data from internet.

Step 1.List all parsers installed on your system and retrieve the ID of the parser that you want to activate. For this /api/4/parser/ API call is used