CloudPlugs REST Library  1.0.0
for Python
CloudPlugs Python Client Library

CloudPlugs REST Client for Python is a library to perform HTTP requests to CloudPlugs servers. The official repository is: https://github.com/cloudplugs/rest-python

The Cloudplugs IoT Platform

Cloudplugs is a cloud based IoT platform to enable the fast prototyping, connection, deployment and management of smart "Things" (sensors, smartphones, home appliances, etc.). Different objects can interact with each other by publishing and/or reading any type of data on shared channels through simple communication protocols. You can learn more at http://www.cloudplugs.com/how-it-works/ and you can sign-up on http://www.cloudplugs.com/register to start connecting your Things.

Library Guide

Installation

Just include dependencies and the library in your Python script

import time
import json
from cloudplugs import CloudPlugs

Usage

Create a new instance:

cps = CloudPlugs()

Now you are ready to configure the library and invoke functions to perform REST requests to the server!

Configuration

After you have a new istance of the class, there are a few configuration parameters you can customize (if needed) before invoking any request. This parameters are:

  • "timeout": to set the timeout value for HTTP requests
  • "id": to set the authentication user
  • "auth": to set the authentication password
  • "isMaster": to run the script as a master user
  • "baseUrl": to set a new base URL for HTTP requests

You can set these options using the proper functions, like the following example:

cps.set_timeout(2)
cps.set_auth("youremail@yourdomain.com", "yourpassword", True)

Execute Rest HTTP requests

When you have your istance of the library ready, you can finally execute HTTP requests to the server by invoking any of the request functions. All the requests are synchronous and are performed according to Cloudplugs Rest API documentation. Example:

# read all device properties and information
cp_res = cps.get_device(None)
# set a custom property
cp_res = cps.set_device_prop(None, "myPropertyName", 123)