Skip to main content

Iot API

Project description

Arduino iot-api Python client

Requirements

  • Python 3.7+

Installation

You can install the package directly from Github (you may need to run pip with sudo):

pip install arduino-iot-api

Getting Started

Authentication

The client requires a valid access token, you can use requests-oauthlib to get one, to install the library do:

pip install requests-oauthlib

After installing the library you can use this Python code to get a token:

from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session

oauth_client = BackendApplicationClient(client_id=YOUR_CLIENT_ID)
token_url = "https://login.arduino.cc/oauth/token"

oauth = OAuth2Session(client=oauth_client)
token = oauth.fetch_token(
    token_url=token_url,
    client_id=YOUR_CLIENT_ID,
    client_secret=YOUR_CLIENT_SECRET,
    audience="https://api2.arduino.cc/iot",
)

print(token.get("access_token"))

Once you get a token, you can create an instance of the iot-api client:

import iot_api_client as iot
from iot_api_client.rest import ApiException
from iot_api_client.configuration import Configuration

# configure and instance the API client
client_config = Configuration(host="http://api2.arduino.cc/iot")
client_config.access_token = YOUR_ACCESS_TOKEN
client = iot.ApiClient(client_config)

# as an example, interact with the devices API
devices_api = iot.DevicesV2Api(client)

try:
    resp = devices_api.devices_v2_list()
    print(resp)
except ApiException as e:
    print("Got an exception: {}".format(e))

For a working example, see the example folder in this repo.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arduino_iot_client-1.1.0-py3-none-any.whl (197.8 kB view details)

Uploaded Python 3

File details

Details for the file arduino_iot_client-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: arduino_iot_client-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 197.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for arduino_iot_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0e684d9096962493a2cf5bada7ea143dee59645108e4de2b194d1be635c4ea0
MD5 a90d1ded211167e19d4cce09777f661e
BLAKE2b-256 c1e8e71817f92a1544f8f2cb261b168320062bd925b2e0486310bebe3055bc36

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page