Skip to main content

Provide access to indexed TON blockchain.

Project description

📦 PyTONAPI

TON PyPI Python Versions License

Image

Downloads Downloads Downloads

Python SDK for tonapi.io.
Information about the API can be found in the documentation.
To use the API you need an API key, you can get it here tonconsole.com.

For creating wallets, transferring TON, Jetton, NFTs, and other operations, recommend using tonutils in combination with TonapiClient. For more information, refer to the library documentation.

Usage

Installation

pip install pytonapi

Examples

  • Asynchronous

    from pytonapi import AsyncTonapi
    
    
    # Declare an asynchronous function for using await
    async def main():
        # Create a new Tonapi object with the provided API key
        tonapi = AsyncTonapi(api_key="Your API key")
    
        # Specify the account ID
        account_id = "EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"  # noqa
    
        # Retrieve account information asynchronously
        account = await tonapi.accounts.get_info(account_id=account_id)
    
        # Print account details
        print(f"Account Address (raw): {account.address.to_raw()}")
        print(f"Account Address (userfriendly): {account.address.to_userfriendly(is_bounceable=True)}")
        print(f"Account Balance (nanoton): {account.balance.to_nano()}")
        print(f"Account Balance (amount): {account.balance.to_amount()}")
    
    
    if __name__ == '__main__':
        import asyncio
    
        # Run the asynchronous function
        asyncio.run(main())
    
  • Synchronous

    from pytonapi import Tonapi
    
    
    def main():
        # Create a new Tonapi object with the provided API key
        tonapi = Tonapi(api_key="Your API key")
    
        # Specify the account ID
        account_id = "EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"  # noqa
    
        # Retrieve account information
        account = tonapi.accounts.get_info(account_id=account_id)
    
        # Print account details
        print(f"Account Address (raw): {account.address.to_raw()}")
        print(f"Account Address (userfriendly): {account.address.to_userfriendly(is_bounceable=True)}")
        print(f"Account Balance (nanoton): {account.balance.to_nano()}")
        print(f"Account Balance (amount): {account.balance.to_amount()}")
    
    
    if __name__ == '__main__':
        main()
    
  • Additional examples can be found examples folder.

Donations

TON - EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess

USDT (TRC-20) - TGKmm9H3FApFw8xcgRcZDHSku68vozAjo9

Contribution

We welcome your contributions! If you have ideas for improvement or have identified a bug, please create an issue or submit a pull request.

Support

Supported by TONAPI and TON Society (Grants and Bounties program).

License

This repository is distributed under the MIT License. Feel free to use, modify, and distribute the code in accordance with the terms of the license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytonapi-0.4.2.tar.gz (54.0 kB view details)

Uploaded Source

Built Distribution

pytonapi-0.4.2-py3-none-any.whl (89.4 kB view details)

Uploaded Python 3

File details

Details for the file pytonapi-0.4.2.tar.gz.

File metadata

  • Download URL: pytonapi-0.4.2.tar.gz
  • Upload date:
  • Size: 54.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pytonapi-0.4.2.tar.gz
Algorithm Hash digest
SHA256 504fccde99947a53b5ab13231414004a3345e260a2f3dc5e018bb357b235bccb
MD5 96eec79fdc8e511d29771fc2f4b234f9
BLAKE2b-256 cea4527bdaf1540e01ad0b4e54e6a76b184c063d4b64ba739cf1cbd2a55c73ad

See more details on using hashes here.

File details

Details for the file pytonapi-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: pytonapi-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 89.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pytonapi-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c6a578bba7fc34c7e45170b58bcb52500157ac217d4d069f6183a15b9b2bd7cb
MD5 d617a21d1b7451ef101b1542f2d1561b
BLAKE2b-256 3dec0e48d25d4bf97420fe96786f5735775054a2ccd2f4db416661e25485a9b0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page