The Wiring Cloud provides multiple ways to interconnect hardware devices, rules and mobile applications. The API provided by the Wiring Cloud is very easy to implement with minimal hardware requirements.
All projects we have included on the website were created around minimalist hardware. We use extensively the Arduino platform for our samples to demonstrate its capability. We also encourage the usage of all Open Source / Open Hardware platforms: Raspberry Pi, MBed.
The interaction with the wiring server is done using a series of API calls. Each API call will process actions for a single virtual device. If you want to handle multiple devices either aggregate them under the same device id or make multiple calls to write or read signals. There are two ways to handle signals. One is similar to a simple line or to use software terms it is like a variable. If a new value is set then it will override the old one. The other alternative is similar to a buffer or in software terms, a queue. The signal queues we implement are FIFO. The queues are limited in size. The size of the queue is 200 values. If you try to push in a full queue it will push out the oldest value.
|set||Set the values for a set of signals|
|push||Push in queues the values for a set of signals.|
|get||Get the values for a set of signals|
|pop||Pop from queues the values for a set of signals|
|peek||Peek from queues the values for a set of signals. Same values returned as 'pop' method but without extracting the values from queues|
|popall||Pop from queues all the values for a set of signals. This will unload the queue.|
|peekall||Peek from queues all the values for a set of signals. Same values returned as 'popall' method but without extracting the values from queues.|
|time/get||Get the values for a set of signals and the time they were set.|
|time/pop||Pop from queues the values for a set of signals and the time they were pushed in the queue.|
|time/peek||Peek from queues the values for a set of signals and the time they were pushed in the queue. Same values returned as 'pop' method but without extracting the values from queues|
|time/popall||Pop from queues all the values for a set of signals and the time they were pushed in the queue. This will unload the queue.|
|time/peekall||Peek from queues all the values for a set of signals and the time they were pushed in the queue. Same values returned as 'popall' method but without extracting the values from queues.|
All API calls have to be authenticated. The Wiring Cloud requires basic authentication. Basically you have to submit a user name and a password with each call. This information is set in the http header of the API call.
The Authorization header is constructed as follows:
- Username and password are combined into a string "username:password"
- The resulting string is then encoded using the RFC2045-MIME variant of Base64
- The authorization method and a space i.e. "Basic " is then put before the encoded string.
For example, if the user agent uses 'Aladdin' as the username and 'open sesame' as the password then the header is formed as follows:
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
More information here: https://en.wikipedia.org/wiki/Basic_access_authentication.
The user necessary for authentication is the email you used to register your account.
The password is not the one you use to login. You have to create a special password for your API calls. In order to do that you have to follow next steps:
1. Click the button on the upper right corner of your screen (where your name is)
2. Select "My Account"
3. In the window that pops-up select "Custom Fields"
4. Enter the password you want for your API authentication in the "API Password" field.
5. Press the "Save" button on the right side.
Now that the password is set for your API you can start making API calls.
The Wiring Cloud supports secured (HTTPS) and unsecured (HTTP) communication. In order for the API calls to be secure you have to use HTTPS. HTTP API calls are provided to allow experimentation and for educational purpose. If you make HTTP calls the user and password can be hijacked very easy by potential intruders.