aleph-message


Namealeph-message JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://github.com/aleph-im/aleph-message
SummaryAleph.im message specification
upload_time2024-11-04 15:29:56
maintainerNone
docs_urlNone
authorHugo Herter
requires_pythonNone
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": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "aleph.im message validation specification",
    "author": "Hugo Herter",
    "author_email": "git@hugoherter.com",
    "download_url": "https://files.pythonhosted.org/packages/b1/e4/af17d774c84ff04c62a77809e01d86cb91486d84e12661f5df1ababa96eb/aleph_message-0.5.0.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.5.0",
    "project_urls": {
        "Homepage": "https://github.com/aleph-im/aleph-message"
    },
    "split_keywords": [
        "aleph.im",
        "message",
        "validation",
        "specification"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8f9e4f0bcfe3e38e830a01066a53a5d73acea434bdbc643a055ee9e65d236818",
                "md5": "b4d6f5b87dc32c888d09a45c7b9e5521",
                "sha256": "6ded0a2f065fba5e6394bb22e0f8639f6137c25dac76c78b853612cca40c3ab1"
            },
            "downloads": -1,
            "filename": "aleph_message-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b4d6f5b87dc32c888d09a45c7b9e5521",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16805,
            "upload_time": "2024-11-04T15:29:54",
            "upload_time_iso_8601": "2024-11-04T15:29:54.726056Z",
            "url": "https://files.pythonhosted.org/packages/8f/9e/4f0bcfe3e38e830a01066a53a5d73acea434bdbc643a055ee9e65d236818/aleph_message-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b1e4af17d774c84ff04c62a77809e01d86cb91486d84e12661f5df1ababa96eb",
                "md5": "ec6055f740932fd94bdf23e89f3d599d",
                "sha256": "07855aff9f383997f58246afd368246bd04ec2a8ce058807081b6ccc211cd60f"
            },
            "downloads": -1,
            "filename": "aleph_message-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ec6055f740932fd94bdf23e89f3d599d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 21066,
            "upload_time": "2024-11-04T15:29:56",
            "upload_time_iso_8601": "2024-11-04T15:29:56.413795Z",
            "url": "https://files.pythonhosted.org/packages/b1/e4/af17d774c84ff04c62a77809e01d86cb91486d84e12661f5df1ababa96eb/aleph_message-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-04 15:29:56",
    "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.39963s