## Tonapi.io
Python wrapper for [tonapi.io](https://tonapi.io/swagger-ui/).\
You need an api key to use it, get it here [telegram-bot](https://tonapi_bot.t.me/)
### Installation
```bash
pip install tonapi.io
```
### Examples
Get wallet balance:
```python
# Importing required package
from tonapi import Tonapi
from tonapi.utils import nano_to_amount
def main():
# Creating new Tonapi object
tonapi = Tonapi(api_key="Your api key")
address = "EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"
account = tonapi.account.get_info(account=address)
# print account balance (default returned in nanoton)
print(account.balance)
# 1500000000
# print account balance in amount
print(nano_to_amount(account.balance))
# 1.5
if __name__ == '__main__':
main()
```
#### Asynchronous example:
```python
# Importing required package
import asyncio
from tonapi import AsyncTonapi
from tonapi.utils import nano_to_amount
# Declaring asynchronous function for using await
async def main():
# Creating new Tonapi object
tonapi = AsyncTonapi(api_key="Your api key")
address = "EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"
account = await tonapi.account.get_info(account=address)
# print account balance (default returned in nanoton)
print(account.balance)
# 1500000000
# print account balance in amount
print(nano_to_amount(account.balance))
# 1.5
if __name__ == '__main__':
# Running asynchronous function
asyncio.run(main())
```
\
Get transactions by wallet address:
```python
# Importing required package
from tonapi import Tonapi
from tonapi.utils import nano_to_amount
def main():
# Creating new Tonapi object
tonapi = Tonapi(api_key="Your api key")
address = "EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"
search = tonapi.blockchain.get_transactions(
account=address, limit=100
)
for transaction in search.transactions:
# print transaction value (default returned in nanoton)
print(transaction.in_msg.value)
# 1000000000
# print transaction value in amount
print(nano_to_amount(transaction.in_msg.value))
# 1.0
# print transaction comment (if the comment is missing will return the None)
print(transaction.in_msg.msg_data.text)
# Hello, World!
if __name__ == '__main__':
main()
```
\
Search for NFT items in the wallet using filters:
```python
# Importing required package
from tonapi import Tonapi
def main():
# Creating new Tonapi object
tonapi = Tonapi(api_key="Your api key")
address = "EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"
search = tonapi.nft.search_items(
owner=address, include_on_sale=True, limit=10
)
for nft in search.nft_items:
# print nft address (default returned in raw)
print(nft.address)
# 0:5208588c1643b4cef7a673a57ee00a3967e485fcc8418c1581a8120444f199e1
# print nft address to userfriendly
print(nft.address.userfriendly)
# EQBSCFiMFkO0zvemc6V-4Ao5Z-SF_MhBjBWBqBIERPGZ4aYe
if __name__ == '__main__':
main()
```
\
Get all NFT items from collection by collection address:
```python
# Importing required package
from tonapi import Tonapi
def main():
# Creating new Tonapi object
tonapi = Tonapi(api_key="Your api key")
collection_address = "EQAUxYSo-UwoqAGixaD3d7CNLp9PthgmEZfnr6BvsijzJHdA"
search = tonapi.nft.search_items(
collection=collection_address, include_on_sale=True, limit=1000
)
for nft in search.nft_items:
# print nft owner address (default returned in raw)
print(nft.owner.address)
# 0:5208588c1643b4cef7a673a57ee00a3967e485fcc8418c1581a8120444f199e1
# print nft owner address to userfriendly
print(nft.owner.address.userfriendly)
# EQBSCFiMFkO0zvemc6V-4Ao5Z-SF_MhBjBWBqBIERPGZ4aYe
if __name__ == '__main__':
main()
```
And more . . .\
\
\
**Buy Me a Coffee:**\
<a href="https://app.tonkeeper.com/transfer/EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"><img src="https://telegra.ph//file/8e0ac22311be3fa6f772c.png" width="55"/></a>
<a href="https://tonhub.com/transfer/EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"><img src="https://telegra.ph//file/7fa75a1b454a00816d83b.png" width="55"/></a>\
```EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess```
Raw data
{
"_id": null,
"home_page": "https://github.com/nessshon/tonapi.io/",
"name": "tonapi.io",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "",
"author": "nessshon",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/f2/c6/c94d600a9e61c19b169cdfc436658f71f3663ec6a838062bd6b453e584fa/tonapi.io-0.0.10.tar.gz",
"platform": null,
"description": "## Tonapi.io\nPython wrapper for [tonapi.io](https://tonapi.io/swagger-ui/).\\\nYou need an api key to use it, get it here [telegram-bot](https://tonapi_bot.t.me/)\n\n### Installation\n\n```bash\npip install tonapi.io\n```\n\n### Examples\n\nGet wallet balance:\n\n```python\n# Importing required package\nfrom tonapi import Tonapi\nfrom tonapi.utils import nano_to_amount\n\n\ndef main():\n # Creating new Tonapi object\n tonapi = Tonapi(api_key=\"Your api key\")\n\n address = \"EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess\"\n account = tonapi.account.get_info(account=address)\n\n # print account balance (default returned in nanoton)\n print(account.balance)\n # 1500000000\n\n # print account balance in amount\n print(nano_to_amount(account.balance))\n # 1.5\n\n\nif __name__ == '__main__':\n main()\n```\n\n#### Asynchronous example:\n\n```python\n# Importing required package\nimport asyncio\n\nfrom tonapi import AsyncTonapi\nfrom tonapi.utils import nano_to_amount\n\n\n# Declaring asynchronous function for using await\nasync def main():\n # Creating new Tonapi object\n tonapi = AsyncTonapi(api_key=\"Your api key\")\n\n address = \"EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess\"\n account = await tonapi.account.get_info(account=address)\n\n # print account balance (default returned in nanoton)\n print(account.balance)\n # 1500000000\n\n # print account balance in amount\n print(nano_to_amount(account.balance))\n # 1.5\n\n\nif __name__ == '__main__':\n # Running asynchronous function\n asyncio.run(main())\n```\n\n\\\nGet transactions by wallet address:\n\n```python\n# Importing required package\nfrom tonapi import Tonapi\nfrom tonapi.utils import nano_to_amount\n\n\ndef main():\n # Creating new Tonapi object\n tonapi = Tonapi(api_key=\"Your api key\")\n\n address = \"EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess\"\n search = tonapi.blockchain.get_transactions(\n account=address, limit=100\n )\n for transaction in search.transactions:\n # print transaction value (default returned in nanoton)\n print(transaction.in_msg.value)\n # 1000000000\n\n # print transaction value in amount\n print(nano_to_amount(transaction.in_msg.value))\n # 1.0\n\n # print transaction comment (if the comment is missing will return the None)\n print(transaction.in_msg.msg_data.text)\n # Hello, World!\n\n\nif __name__ == '__main__':\n main()\n```\n\n\\\nSearch for NFT items in the wallet using filters:\n\n```python\n# Importing required package\nfrom tonapi import Tonapi\n\n\ndef main():\n # Creating new Tonapi object\n tonapi = Tonapi(api_key=\"Your api key\")\n\n address = \"EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess\"\n search = tonapi.nft.search_items(\n owner=address, include_on_sale=True, limit=10\n )\n for nft in search.nft_items:\n # print nft address (default returned in raw)\n print(nft.address)\n # 0:5208588c1643b4cef7a673a57ee00a3967e485fcc8418c1581a8120444f199e1\n\n # print nft address to userfriendly\n print(nft.address.userfriendly)\n # EQBSCFiMFkO0zvemc6V-4Ao5Z-SF_MhBjBWBqBIERPGZ4aYe\n\n\nif __name__ == '__main__':\n main()\n```\n\n\\\nGet all NFT items from collection by collection address:\n\n```python\n# Importing required package\nfrom tonapi import Tonapi\n\n\ndef main():\n # Creating new Tonapi object\n tonapi = Tonapi(api_key=\"Your api key\")\n\n collection_address = \"EQAUxYSo-UwoqAGixaD3d7CNLp9PthgmEZfnr6BvsijzJHdA\"\n search = tonapi.nft.search_items(\n collection=collection_address, include_on_sale=True, limit=1000\n )\n for nft in search.nft_items:\n # print nft owner address (default returned in raw)\n print(nft.owner.address)\n # 0:5208588c1643b4cef7a673a57ee00a3967e485fcc8418c1581a8120444f199e1\n\n # print nft owner address to userfriendly\n print(nft.owner.address.userfriendly)\n # EQBSCFiMFkO0zvemc6V-4Ao5Z-SF_MhBjBWBqBIERPGZ4aYe\n\n\nif __name__ == '__main__':\n main()\n```\n\nAnd more . . .\\\n\\\n\\\n**Buy Me a Coffee:**\\\n<a href=\"https://app.tonkeeper.com/transfer/EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess\"><img src=\"https://telegra.ph//file/8e0ac22311be3fa6f772c.png\" width=\"55\"/></a>\n<a href=\"https://tonhub.com/transfer/EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess\"><img src=\"https://telegra.ph//file/7fa75a1b454a00816d83b.png\" width=\"55\"/></a>\\\n```EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess```\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "TON API. Provide access to indexed TON blockchain.",
"version": "0.0.10",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d5fcac93f4319043a5ac0b438b09542e69599ca095982b898777e88bf7d859a1",
"md5": "9c03ef330f29e3b23c53566e66e506bc",
"sha256": "a47b9fdd45feeba9feef88839a72d8a98477d325421784f25fe0bb09c26f2c6c"
},
"downloads": -1,
"filename": "tonapi.io-0.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9c03ef330f29e3b23c53566e66e506bc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 25719,
"upload_time": "2023-03-18T05:16:56",
"upload_time_iso_8601": "2023-03-18T05:16:56.166711Z",
"url": "https://files.pythonhosted.org/packages/d5/fc/ac93f4319043a5ac0b438b09542e69599ca095982b898777e88bf7d859a1/tonapi.io-0.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f2c6c94d600a9e61c19b169cdfc436658f71f3663ec6a838062bd6b453e584fa",
"md5": "b6beee544e170e72535156eca5127028",
"sha256": "905e52b304b558bc3fcd82b73280ab6191dcadf4006f291cb67c8e26c9c8010a"
},
"downloads": -1,
"filename": "tonapi.io-0.0.10.tar.gz",
"has_sig": false,
"md5_digest": "b6beee544e170e72535156eca5127028",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 15357,
"upload_time": "2023-03-18T05:16:58",
"upload_time_iso_8601": "2023-03-18T05:16:58.502447Z",
"url": "https://files.pythonhosted.org/packages/f2/c6/c94d600a9e61c19b169cdfc436658f71f3663ec6a838062bd6b453e584fa/tonapi.io-0.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-18 05:16:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "nessshon",
"github_project": "tonapi.io",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "aiohttp",
"specs": [
[
"~=",
"3.8.3"
]
]
},
{
"name": "libscrc",
"specs": [
[
"~=",
"1.8.1"
]
]
},
{
"name": "pydantic",
"specs": [
[
"~=",
"1.10.4"
]
]
},
{
"name": "requests",
"specs": [
[
"~=",
"2.28.2"
]
]
}
],
"lcname": "tonapi.io"
}