Coder Social home page Coder Social logo

aleph-message's Introduction

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))

aleph-message's People

Contributors

hoh avatar odesenfans avatar mhhukiewitz avatar 1yam avatar leirbag95 avatar psycojoker avatar olethanh avatar dependabot[bot] avatar nesitor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.