Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Ubidots Python API Client

The Ubidots Python API Client makes calls to the Ubidots Api The module is available on PyPi as ubidots

To follow this quickstart you’ll need to install python 2.7 in your machine (either be it a computer or an python-capable device), you can find more details in http://www.python.org/download/.

Installing the Python library

Ubidots for python is available in Pypi and you can install it from the comand line:

$ pip install ubidots

Don’t forget to use sudo if necessary.

You can install pip in Linux and Mac using this command:

$ easy_install pip

If you are using Microsoft Windows you can install pip from here.

Connecting to the API

Before playing with the API you must be able to connect to it using your private API key, which can be found in your profile.

If you don’t have an account yet, you can create one here.

Once you have your API key, you can connect to the API by creating an ApiClient instance. Let’s assume your API key is: “7fj39fk3044045k89fbh34rsd9823jkfs8323” then your code would look like this:

from ubidots import ApiClient

api = ApiClient('7fj39fk3044045k89fbh34rsd9823jkfs8323')

Now you have an instance of the apiclient (“api”) which can be used to connect to the API service.

Creating a DataSource

As you might know by now, a data source representes a device or a virtual source.

This line creates a new data source:

new_datasource = api.create_datasource({"name":"myNewDs"})

This new data source can be used to track different variables, so let’s create one.

Creating a Variable

A variable is a time-series containing different values over time. Let’s create one:

new_variable = new_datasource.create_variable({"name":"myNewVar"})

Now you have a new variable, so let’s create a new value for this variable.

Saving a new Value to a Variable

Given the instantiated variable, you can save a new value with the following line:

new_value = new_variable.save_value({'value':10})

You can also specify a timestamp (optional)

new_value = new_variable.save_value({'value':10, 'timestamp':1376061804407})

If no timestamp is specified, the API server will asign the current time to it. We think it’s always better that you specify the timestamp so that it reflects the exact time when the value was captures, and not the time when it got to our servers.

Getting Values

To get the values for a variable, use the method get_values in an instance of the class Variable.

all_values = new_variable.get_values()

You may also want to get the last value of certain variable with this purpose, first you need to update the variable:

new_variable = api.get_variable(new_variable.id)
last_value = new_variable.last_value

Getting all the Data sources

If you want to get all your data sources you can use the instance of the api directly:

all_my_datasources = api.get_datasources()

Getting a specific Data source

Each data source has a unique id that tells the server which one to retrieve.

For example, if a data source has the id 51c99cfdf91b28459f976414, it can be retrieved using the method get_datasource of the ApiClient instance:

my_specific_datasource = api.get_datasource(id = '51c99cfdf91b28459f976414')

Getting All Variables from a Data source

You can also retrieve all the variables of a data source:

all_datasource_variables = datasource.get_get_variables()

Getting a specific Variable

As with data sources, use your variable’s id to retrieve the details about a variable:

my_specific_variable = api.get_variable(id = '56799cf1231b28459f976417')

Metadata

Release files for ubidots 0.1.3-alpha

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ubidots 0.1.3-alpha
File Size Uploaded Provenance Actions
ubidots-0.1.3-alpha.tar.gz 4.7 kB Without provenance Details for ubidots-0.1.3-alpha.tar.gz

Release files / ubidots-0.1.3-alpha.tar.gz

Download URL ubidots-0.1.3-alpha.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
17198235d7606fd2a0bc4fe3742e8a88fc3d1bae55a81cf0f26daf97806c11ac
BLAKE2b-256 checksum
How to use checksums
dcd1fab06e42d46987c1a7beaf54d29fd86bc3b1df3baec2c5f7d77a6bf0217b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for ubidots 0.1.3-alpha

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page