Skip to main content

Moonstream Entity Python Client and CLI

In order to use this client, you will need a Moonstream access token. You can generate one at https://moonstream.to/account/tokens.

Detailed documentation you can find at https://docs.moonstream.to/engine/entity

The client library reads this token from the MOONSTREAM_ACCESS_TOKEN environment variable. To set it:

export MOONSTREAM_ACCESS_TOKEN="<your_access_token>"

Install package from PyPI:

pip install moonstream-entity

Import and initialize client in your code:

import os

from entity.client import Entity

MOONSTREAM_ACCESS_TOKEN = os.environ.get("MOONSTREAM_ACCESS_TOKEN")

ec = Entity()
response = ec.list_collections(
    token=MOONSTREAM_ACCESS_TOKEN,
    timeout=10,
)

print(response.json())

Work with collections via CLI

Create collection:

entity --token "$MOONSTREAM_ACCESS_TOKEN" collections create --name "My Ethereum addresses"

List collections:

entity --token "$MOONSTREAM_ACCESS_TOKEN" collections list

Delete collection:

export MOONSTREAM_ENTITY_COLLECTION_ID="<your_collection_id>"

entity --token "$MOONSTREAM_ACCESS_TOKEN" collections delete --collection_id "$MOONSTREAM_ENTITY_COLLECTION_ID"

Work with entities via CLI

export MOONSTREAM_ENTITY_COLLECTION_ID="<your_collection_id>"

Create entity:

entity --token "$MOONSTREAM_ACCESS_TOKEN" entities create --collection_id "$MOONSTREAM_ENTITY_COLLECTION_ID" --address "0x000000000000000000000000000000000000dEaD" --blockchain ethereum --name "Dead address" --required_field '{"dead": true}' --required_field '{"owner": "unknown"}' --secondary_field '{"description": "Dangerous address for tokens burning mechanism."}'

Create entity bulk from csv:

Input file addresses.csv contains list of addresses:

address,name
0xe1991fFb1f2271Bc645293cCDf4e38a3f1b7a13c,Address 1
0x37309157eC7863b04c66B6fB2bf7b21EE8B03bA1,Address 2
entity --token "$MOONSTREAM_ACCESS_TOKEN" entities bulk --blockchain ethereum --collection_id "$MOONSTREAM_ENTITY_COLLECTION_ID" --input addresses.csv --required_field '{"owner": "me"}' --secondary_field '{"description": "My bot address"}'

List entities in collection:

entity --token "$MOONSTREAM_ACCESS_TOKEN" entities list --collection_id "$MOONSTREAM_ENTITY_COLLECTION_ID"

Delete entity:

export MOONSTREAM_ENTITY_ID="<your_entity_id>"

entity --token "$MOONSTREAM_ACCESS_TOKEN" entities delete --collection_id "$MOONSTREAM_ENTITY_COLLECTION_ID" --entity_id "$MOONSTREAM_ENTITY_ID"

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moonstream-entity-0.0.3.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moonstream_entity-0.0.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file moonstream-entity-0.0.3.tar.gz.

File metadata

  • Download URL: moonstream-entity-0.0.3.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for moonstream-entity-0.0.3.tar.gz
Algorithm Hash digest
SHA256 aad631442903c79abb10ca7485a1141745208f3eb60c40436b8d8a53aea0153c
MD5 ea6a47eec2085580857c63a3a60044be
BLAKE2b-256 30435224357bb3dfa283316f8333af886ed2997f38b94cdc05580626033de9a5

See more details on using hashes here.

File details

Details for the file moonstream_entity-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for moonstream_entity-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4f4f90d0f23fe55a8d4aa50e310e1474152fecc00675e7d7c7f464b90ceb28f7
MD5 89d9233d78f510c77dffbdc1d6f9f2a4
BLAKE2b-256 3e6c4016022e29e63b30e33e8ff2633cd2471b611ceda549072beb96fff2cac2

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.5

2 files

0.0.4

2 files

This release

0.0.3 This release

2 files

0.0.2

2 files

0.0.1

2 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