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"
Release files for moonstream-entity 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| moonstream-entity-0.0.5.tar.gz | 7.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| moonstream_entity-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / moonstream-entity-0.0.5.tar.gz
| Download URL | moonstream-entity-0.0.5.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
864cf3800742810acb68cbd0da45ca67483a0ee1edeae28dc620af17c109f5f1
|
|
BLAKE2b-256 checksum How to use checksums |
fa9aecd8c3d7ab6ad8f18c8065934a47c87ae7f5b35a15b428d786f733c580a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / moonstream_entity-0.0.5-py3-none-any.whl
| Download URL | moonstream_entity-0.0.5-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ecb77978fe4bc50611466ba88a85aab337b9fa541182174f188ca7e07c524158
|
|
BLAKE2b-256 checksum How to use checksums |
949b0c773486fcf3fbebf964661590afbeb0b1b84c7fbdd99c7995dfb46e6906
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|