# 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/13/0c/d9b4d7b23bf0db1888cb49c4f5122a190c3cd79cd7d48d161f662efb6208/aleph_message-0.6.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.6.0",
"project_urls": {
"Homepage": "https://github.com/aleph-im/aleph-message"
},
"split_keywords": [
"aleph.im",
"message",
"validation",
"specification"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "27faf8da98946c42704c86f949c2fa2d70e0ae5f16bf88851c1affad2bfab56b",
"md5": "042e4945b374591ef32a8b90e4dc4d07",
"sha256": "d548c2a497c83b13f50bf69cefcb48bd919c189072b97739469348d800a33152"
},
"downloads": -1,
"filename": "aleph_message-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "042e4945b374591ef32a8b90e4dc4d07",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 17398,
"upload_time": "2024-12-09T16:50:27",
"upload_time_iso_8601": "2024-12-09T16:50:27.274206Z",
"url": "https://files.pythonhosted.org/packages/27/fa/f8da98946c42704c86f949c2fa2d70e0ae5f16bf88851c1affad2bfab56b/aleph_message-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "130cd9b4d7b23bf0db1888cb49c4f5122a190c3cd79cd7d48d161f662efb6208",
"md5": "73efae42485ffba9371a7fed40066948",
"sha256": "6f3933555470ccf4b4ab4d97f167d884a7e8a4692937919a8a60374d1926e768"
},
"downloads": -1,
"filename": "aleph_message-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "73efae42485ffba9371a7fed40066948",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23893,
"upload_time": "2024-12-09T16:50:29",
"upload_time_iso_8601": "2024-12-09T16:50:29.189994Z",
"url": "https://files.pythonhosted.org/packages/13/0c/d9b4d7b23bf0db1888cb49c4f5122a190c3cd79cd7d48d161f662efb6208/aleph_message-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-09 16:50:29",
"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"
}