Aleph.im message specification
Project description
Aleph.im Message Specification
This library aims to provide an easy way to create, update and manipulate messages from Aleph.im.
It mainly consists in pydantic models that provide field type validation and IDE autocompletion for messages.
This library provides:
- schema validation when parsing messages.
- cryptographic hash validation that the
item_hash
matches the content of the message. - type validation using type checkers such as mypy in development environments.
- autocompletion support in development editors.
The item_hash
is commonly used as unique message identifier on Aleph.im.
Cryptographic signatures are out of scope of this library and part of the aleph-sdk-python
project, due to their extended scope and dependency on cryptographic libraries.
This library is used in both client and node software of Aleph.im.
Usage
pip install aleph-message
import requests
from aleph_message import parse_message
from pydantic import ValidationError
ALEPH_API_SERVER = "https://official.aleph.cloud"
MESSAGE_ITEM_HASH = "9b21eb870d01bf64d23e1d4475e342c8f958fcd544adc37db07d8281da070b00"
message_dict = requests.get(ALEPH_API_SERVER + "/api/v0/messages.json?hashes=" + MESSAGE_ITEM_HASH).json()
try:
message = parse_message(message_dict["messages"][0])
print(message.sender)
except ValidationError as e:
print(e.json(indent=4))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aleph_message-0.5.0.tar.gz
(21.1 kB
view hashes)
Built Distribution
Close
Hashes for aleph_message-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ded0a2f065fba5e6394bb22e0f8639f6137c25dac76c78b853612cca40c3ab1 |
|
MD5 | b4d6f5b87dc32c888d09a45c7b9e5521 |
|
BLAKE2b-256 | 8f9e4f0bcfe3e38e830a01066a53a5d73acea434bdbc643a055ee9e65d236818 |