Moonstream Python client
This is the Python client library for the Moonstream API.
Installation
This library assumes you are using Python 3.6 or greater.
Install using pip:
pip install moonstream
Usage
- Source environment variable with access token to Moonstream, you can create one on page https://moonstream.to/account/tokens/
access_token = os.environ.get("MOONSTREAM_ACCESS_TOKEN")
- Create an object of Moonstream client and authorize
mc = Moonstream()
mc.authorize(access_token)
create_stream method
Return a stream of event for time range.
From timestamp to None, from bottom to top
When end_time is not set.
for events in mc.create_stream(
start_time=1637834400, end_time=None, q="type:ethereum_blockchain"
):
event_timestamp_list = [e["event_timestamp"] for e in events["events"]]
print(event_timestamp_list)
In this case we will be receiving events from bottom of history to recent time in next order:
[1637836177, ..., 1637834440]
[1637837980, ..., 1637836226]
# Until we will get latest event,
# then we will be receiving empty lists
[]
[]
# Until new events will be available
[1637839306, 1637839306, 1637839306, 1637839306]
[]
# Continuing...
From timestamp to timestamp, from top to bottom
When start_time is greater then end_time.
for events in mc.create_stream(
start_time=1637839281, end_time=1637830890, q="type:ethereum_blockchain"
):
event_timestamp_list = [e["event_timestamp"] for e in events["events"]]
print(event_timestamp_list)
Stream of event packs will be generating from recent timestamp to older and inner list of transactions for each pack will be in most recent to older event timestamp range:
[1637839280, ..., 1637838094]
[1637838086, ..., 1637836340]
...
[1637834488, ..., 1637832699]
[1637832676, ..., 1637830903]
From timestamp to timestamp, from bottom to top
When start_time is less than end_time.
for events in mc.create_stream(
start_time=1637830890, end_time=1637839281, q="type:ethereum_blockchain"
):
event_timestamp_list = [e["event_timestamp"] for e in events["events"]]
print(event_timestamp_list)
You start receiving list of older events from bottom of history to newest:
[1637832676, ..., 1637830903]
[1637834488, ..., 1637832699]
...
[1637838086, ..., 1637836340]
[1637839280, ..., 1637838094]
Metadata
Release files for moonstream 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| moonstream-0.1.2.tar.gz | 6.8 kB | Without provenance | Details for moonstream-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moonstream-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for moonstream-0.1.2-py3-none-any.whl |
Total release size: 13.9 kB
Release files / moonstream-0.1.2.tar.gz
| Download URL | moonstream-0.1.2.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e59810ad2f1657ea044d5a960baa49da061d06121c6dca536daaaca5d1d9dabf
|
|
BLAKE2b-256 checksum How to use checksums |
3bed6d9c74d0ba0b2506e4b676d598a8ec63f2779dddd40b8fe7918d595e8fc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.20
|
Release files / moonstream-0.1.2-py3-none-any.whl
| Download URL | moonstream-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8a8c89ba06861cdf9793adabd430a94299a8e24d6fee0461299ac0c89911379
|
|
BLAKE2b-256 checksum How to use checksums |
225008327cfec403367c14a8eb54d6b3f73facac5f441c971420ff68880e87a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.20
|
Security for moonstream 0.1.2
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.