Home

Awesome

micropython-cryptodweet

PayPal Donate PyPI version Downloads

A python module for very basic APIs of the free dweet service with encryption. Dweet is a simple machine-to-machine (M2M) service from dweet.io.

This module only supports these dweet APIs of the free dweet service:

This module works under MicroPython and it is tested with MicroPython V1.18. It requires micropython-basicdweet and micropython-cryptomsg.

For a compatible CPython version, please find Python package cryptodweet.

Installation

>>> import upip
>>> upip.install('micropython-cryptodweet')

Alternatively just copy cryptodweet.py and its dependency to the MicroPython device.

Usage

>>> from cryptodweet import CryptoDweet
>>> cd = CryptoDweet('YOUR KEY')
>>> cd.dweet_for('YOUR THING', {'YOUR DATA': 'YOUR VALUE'})
{'content': {'8c94428bc640de621c7c3ceea1d00b96': '05d6f2dbc1ce3afa7e6072c0c4c6f6a7'}, 'created': '2022-05-30T00:13:24.215Z', 'thing': '9ee9b47833d5a13043c5f47e8802596a', 'transaction': 'ae80796e-4c3e-4237-bd2f-c5e040ff4b68'}
>>> cd.get_latest_dweet_for('YOUR THING')
[{'content': {'YOUR DATA': 'YOUR VALUE'}, 'created': '2022-05-30T00:13:24.215Z', 'thing': 'YOUR THING'}]
>>> cd.dweet_for('YOUR THING', {'YOUR DATA': 'YOUR VALUE 2'})
{'content': {'8c94428bc640de621c7c3ceea1d00b96': 'b9ed6b3c229ae62ea30f134f9332b5bf'}, 'created': '2022-05-30T00:16:20.835Z', 'thing': '9ee9b47833d5a13043c5f47e8802596a', 'transaction': 'b1f22bfc-8571-4798-a600-56c36288344e'}
>>> cd.get_latest_dweet_for('YOUR THING')
[{'content': {'YOUR DATA': 'YOUR VALUE 2'}, 'created': '2022-05-30T00:16:20.835Z', 'thing': 'YOUR THING'}]
>>> cd.get_dweets_for('YOUR THING')
[{'content': {'YOUR DATA': 'YOUR VALUE 2'}, 'created': '2022-05-30T00:16:20.835Z', 'thing': 'YOUR THING'}, {'content': {'YOUR DATA': 'YOUR VALUE'}, 'created': '2022-05-30T00:13:24.215Z', 'thing': 'YOUR THING'}]