Skip to main content

Moonstream: Open source blockchain analytics

Project description

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

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 then 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]

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

moonstream-0.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

moonstream-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file moonstream-0.1.1.tar.gz.

File metadata

  • Download URL: moonstream-0.1.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for moonstream-0.1.1.tar.gz
Algorithm Hash digest
SHA256 90d9a4323fb11a1cb571bc05771b6ed31bc9da68db64ec748faa1522771d4136
MD5 6677135c6b28e37b6c948f49a8cc0011
BLAKE2b-256 f262f663cf2d1cd5ca835e04db014ceb95726b912dfbf1e91380aa6a634000de

See more details on using hashes here.

File details

Details for the file moonstream-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: moonstream-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for moonstream-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0ab17530b2b30ddd98a1d4d2e75ea4f56337d6157457af5b3a29dbc863c9c86
MD5 985b10a2e4c458ea9455077b2612cc3a
BLAKE2b-256 5d364bbbaa5d043392e67aedb0d4470fca7b323a50602fa2790a326f0bf542c0

See more details on using hashes here.

Supported by

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