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 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 = 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.3.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

aleph_message-0.3.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file aleph-message-0.3.1.tar.gz.

File metadata

  • Download URL: aleph-message-0.3.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for aleph-message-0.3.1.tar.gz
Algorithm Hash digest
SHA256 fd6dc80cef44a5a59551468683cb02fa8452456e759d04cbe31cfcb30966a93e
MD5 23aee1ca26c4217e547f7dc56819c0cd
BLAKE2b-256 4c30baf250ab84f898a607700380a7e9deb1de2164b53e42c26b4c440ee3a38f

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for aleph_message-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 90b30356dc014b3836a1c6e8d28831fde7eb06b3fba1e3bfe3196063764d533d
MD5 57a94bc306be720da9452c8d1a635740
BLAKE2b-256 a2a6e28dbd548d8fa492002096cdcfa137dd0fa2f477af039e9026a66185be80

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