Basic APIs of the free dweet service.
Project description
Basic Dweet
Basic APIs of the free dweet service. Dweet is a simple machine-to-machine (M2M) service from dweet.io.
This module only supports these dweet APIs of the free dweet service:
dweet for
get latest dweet for
get dweets for
It also can be used in MicroPython.
Installation
Synchronous Programming
pip install basicdweet
Asynchronous Programming
pip install basicdweet[aiohttp]
Usage
Synchronous Programming
Code
import time
import basicdweet
print(basicdweet.dweet_for("YOUR_THING", {"YOUR_DATA": "YOUR_VALUE"}))
time.sleep(2)
print(basicdweet.get_latest_dweet_for("YOUR_THING"))
time.sleep(2)
print(basicdweet.dweet_for("YOUR_THING", {"YOUR_DATA": "YOUR_VALUE_2"}))
time.sleep(2)
print(basicdweet.get_latest_dweet_for("YOUR_THING"))
time.sleep(2)
print(basicdweet.get_dweets_for("YOUR_THING"))
Output
{'thing': 'YOUR_THING', 'created': '2024-07-05T04:53:36.896Z', 'content': {'YOUR_DATA': 'YOUR_VALUE'}, 'transaction': '9cd0b361-05fc-451d-be7b-280172242f25'}
[{'thing': 'YOUR_THING', 'created': '2024-07-05T04:53:36.896Z', 'content': {'YOUR_DATA': 'YOUR_VALUE'}}]
{'thing': 'YOUR_THING', 'created': '2024-07-05T04:53:42.697Z', 'content': {'YOUR_DATA': 'YOUR_VALUE_2'}, 'transaction': '926d396d-cf41-4feb-89c3-46ffb0960053'}
[{'thing': 'YOUR_THING', 'created': '2024-07-05T04:53:42.697Z', 'content': {'YOUR_DATA': 'YOUR_VALUE_2'}}]
[{'thing': 'YOUR_THING', 'created': '2024-07-05T04:53:42.697Z', 'content': {'YOUR_DATA': 'YOUR_VALUE_2'}}, {'thing': 'YOUR_THING', 'created': '2024-07-05T04:53:36.896Z', 'content': {'YOUR_DATA': 'YOUR_VALUE'}}]
Asynchronous Programming
Code
import asyncio
import basicdweet
async def async_test():
print(await basicdweet.async_dweet_for("YOUR_THING", {"YOUR_DATA": "YOUR_VALUE"}))
await asyncio.sleep(2)
print(await basicdweet.async_get_latest_dweet_for("YOUR_THING"))
await asyncio.sleep(2)
print(await basicdweet.async_dweet_for("YOUR_THING", {"YOUR_DATA": "YOUR_VALUE_2"}))
await asyncio.sleep(2)
print(await basicdweet.async_get_latest_dweet_for("YOUR_THING"))
await asyncio.sleep(2)
print(await basicdweet.async_get_dweets_for("YOUR_THING"))
asyncio.run(async_test())
Output
{'thing': 'YOUR_THING', 'created': '2024-07-05T04:58:08.829Z', 'content': {'YOUR_DATA': 'YOUR_VALUE'}, 'transaction': '12d7e422-e8ce-408c-be0c-d61cc5d3d730'}
[{'thing': 'YOUR_THING', 'created': '2024-07-05T04:58:08.829Z', 'content': {'YOUR_DATA': 'YOUR_VALUE'}}]
{'thing': 'YOUR_THING', 'created': '2024-07-05T04:58:14.650Z', 'content': {'YOUR_DATA': 'YOUR_VALUE_2'}, 'transaction': 'ffbb2f4e-f954-4b4c-887e-7a492c0ce0ba'}
[{'thing': 'YOUR_THING', 'created': '2024-07-05T04:58:14.650Z', 'content': {'YOUR_DATA': 'YOUR_VALUE_2'}}]
[{'thing': 'YOUR_THING', 'created': '2024-07-05T04:58:14.650Z', 'content': {'YOUR_DATA': 'YOUR_VALUE_2'}}, {'thing': 'YOUR_THING', 'created': '2024-07-05T04:58:08.829Z', 'content': {'YOUR_DATA': 'YOUR_VALUE'}}]
Test
python -m pytest
Build documentation
mkdocs build
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
basicdweet-0.4.0.tar.gz
(4.7 kB
view details)
Built Distribution
File details
Details for the file basicdweet-0.4.0.tar.gz
.
File metadata
- Download URL: basicdweet-0.4.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49f6a816fec1ae718f2cc78ed5e861eb20a549eddd0045688f073bf0a05ab1dd |
|
MD5 | 2e1213f57fa8c0ad10e44d7e03fb52e5 |
|
BLAKE2b-256 | 9dffc068a4eb27b5547d98383f3f2fb27fc28da465e36d5bbb46c707107e792f |
File details
Details for the file basicdweet-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: basicdweet-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24d7386262dedf28cd165c5f8c93b101df70cd6feb0bf72dd1f0b58f8c4a05de |
|
MD5 | e204ef28976425c5a4ddd6fc4733ca32 |
|
BLAKE2b-256 | 1aff19db5fd07ac0e8b4c24543940730753250096770b7b88b9b04a2288c1ebf |