aleph-message


Namealeph-message JSON
Version 0.4.4 PyPI version JSON
download
home_pagehttps://github.com/aleph-im/aleph-message
SummaryAleph.im message specification
upload_time2024-02-24 12:36:32
maintainer
docs_urlNone
authorHugo Herter
requires_python
licenseMIT
keywords aleph.im message validation specification
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://pydantic-docs.helpmanual.io/) 
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](https://www.mypy-lang.org/) 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

```shell
pip install aleph-message
```

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aleph-im/aleph-message",
    "name": "aleph-message",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "aleph.im message validation specification",
    "author": "Hugo Herter",
    "author_email": "git@hugoherter.com",
    "download_url": "https://files.pythonhosted.org/packages/60/82/b3004cd0d86ee1bba9c62e162849c26d926afad5114d10328f55223af093/aleph-message-0.4.4.tar.gz",
    "platform": null,
    "description": "# Aleph.im Message Specification\n\nThis library aims to provide an easy way to create, update and manipulate \nmessages from Aleph.im.\n\nIt mainly consists in [pydantic](https://pydantic-docs.helpmanual.io/) \nmodels that provide field type validation and IDE autocompletion for messages.\n\nThis library provides:\n* schema validation when parsing messages.\n* cryptographic hash validation that the `item_hash` matches the content of the message.\n* type validation using type checkers such as [mypy](https://www.mypy-lang.org/) in development environments.\n* autocompletion support in development editors.\n\nThe `item_hash` is commonly used as unique message identifier on Aleph.im.\n\nCryptographic signatures are out of scope of this library and part of the `aleph-sdk-python`\nproject, due to their extended scope and dependency on cryptographic libraries.\n\nThis library is used in both client and node software of Aleph.im.\n\n## Usage\n\n```shell\npip install aleph-message\n```\n\n```python\nimport requests\nfrom aleph_message import parse_message\nfrom pydantic import ValidationError\n\nALEPH_API_SERVER = \"https://official.aleph.cloud\"\nMESSAGE_ITEM_HASH = \"9b21eb870d01bf64d23e1d4475e342c8f958fcd544adc37db07d8281da070b00\"\n\nmessage_dict = requests.get(ALEPH_API_SERVER + \"/api/v0/messages.json?hashes=\" + MESSAGE_ITEM_HASH).json()\n\ntry:\n    message = parse_message(message_dict[\"messages\"][0])\n    print(message.sender)\nexcept ValidationError as e:\n    print(e.json(indent=4))\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Aleph.im message specification",
    "version": "0.4.4",
    "project_urls": {
        "Homepage": "https://github.com/aleph-im/aleph-message"
    },
    "split_keywords": [
        "aleph.im",
        "message",
        "validation",
        "specification"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "83fa745dd80be1b1954a2b76e005a055624d1aea66f009a3f5e51c61f834ad26",
                "md5": "445141d13d77abf69bd7a6713805c913",
                "sha256": "0cd87a304b10cd947cae261303ad745b765a1d2bae6cbb57a4d612c2227cd436"
            },
            "downloads": -1,
            "filename": "aleph_message-0.4.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "445141d13d77abf69bd7a6713805c913",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 15353,
            "upload_time": "2024-02-24T12:36:30",
            "upload_time_iso_8601": "2024-02-24T12:36:30.264681Z",
            "url": "https://files.pythonhosted.org/packages/83/fa/745dd80be1b1954a2b76e005a055624d1aea66f009a3f5e51c61f834ad26/aleph_message-0.4.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6082b3004cd0d86ee1bba9c62e162849c26d926afad5114d10328f55223af093",
                "md5": "e16da670fb3afe2dbd89f2fd080a034c",
                "sha256": "d162af42955df2159ece4b3e7dd798a4cb730aa0adb18b4fd9a553890725b508"
            },
            "downloads": -1,
            "filename": "aleph-message-0.4.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e16da670fb3afe2dbd89f2fd080a034c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12560,
            "upload_time": "2024-02-24T12:36:32",
            "upload_time_iso_8601": "2024-02-24T12:36:32.619784Z",
            "url": "https://files.pythonhosted.org/packages/60/82/b3004cd0d86ee1bba9c62e162849c26d926afad5114d10328f55223af093/aleph-message-0.4.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-24 12:36:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aleph-im",
    "github_project": "aleph-message",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aleph-message"
}
        
Elapsed time: 0.18439s