Skip to main content

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


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.4.9.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

aleph_message-0.4.9-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file aleph_message-0.4.9.tar.gz.

File metadata

  • Download URL: aleph_message-0.4.9.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for aleph_message-0.4.9.tar.gz
Algorithm Hash digest
SHA256 09e7c008f8053061b4179973fcb76a91ebeb66c75deda7cc3468d286599217b5
MD5 e43cc1f279bb319d0c9d036e71d6034e
BLAKE2b-256 193d8bb1696cb57dac66a740c9cfc36f564dab8fc67aef91f252b27cd9b95996

See more details on using hashes here.

Provenance

File details

Details for the file aleph_message-0.4.9-py3-none-any.whl.

File metadata

File hashes

Hashes for aleph_message-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5ec0401f383817b1e048cc405f4c1c07f467ea849d86e179aae5368be7b9c85a
MD5 e1f03b95847e2e9f44b1c196d89f07cd
BLAKE2b-256 d9924bf1fa86322f988e193964188aa9b0d3118c2d2a67edd4be59fd823afbb0

See more details on using hashes here.

Provenance

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