Skip to main content

Basic Dweet

PyPI version Downloads

Documentation

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

Metadata

Release files for basicdweet 0.4.0

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

Source distribution (sdist)

Source distribution for basicdweet 0.4.0
File Size Uploaded
basicdweet-0.4.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for basicdweet 0.4.0
File Interpreter ABI Platform
basicdweet-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / basicdweet-0.4.0.tar.gz

Download URL basicdweet-0.4.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
49f6a816fec1ae718f2cc78ed5e861eb20a549eddd0045688f073bf0a05ab1dd
BLAKE2b-256 checksum
How to use checksums
9dffc068a4eb27b5547d98383f3f2fb27fc28da465e36d5bbb46c707107e792f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release files / basicdweet-0.4.0-py3-none-any.whl

Download URL basicdweet-0.4.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
24d7386262dedf28cd165c5f8c93b101df70cd6feb0bf72dd1f0b58f8c4a05de
BLAKE2b-256 checksum
How to use checksums
1aff19db5fd07ac0e8b4c24543940730753250096770b7b88b9b04a2288c1ebf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

1 release file

0.2.0

1 release file

0.1.0

2 release files

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