Skip to main content

Python TON.sh Public API

Project description

PyPi Package Version Supported Python versions PyPi downloads

pyTONPublicAPI

Python implementation of TON Public API for The Open Network (TON).

Supported API servers

Installation

Installation using pip (a Python package manager):

$ pip install pyTONPublicAPI

Usage

Everything is as simple as the API itself.

  1. Create pyTONPublicAPI instance
  2. Access API methods in pythonic notation (getAddressInformation -> get_address_information)
from pyTONPublicAPI import pyTONPublicAPI
client = pyTONPublicAPI()
print(client.get_address_balance(address = "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N"))

If you want to work with a single address - you can pre-set it on init and avoid in functions.

from pyTONPublicAPI import pyTONPublicAPI
client = pyTONPublicAPI(address = "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N")
print(client.get_address_balance())
print(client.get_transactions())

You can also check tests.py.

Exceptions

Exceptions are rised using pyTONException class.

API servers

By default all calls are sent to TON.sh server. To select API server you should:

  1. Create server object
  2. Pass it to pyTONPublicAPI constructor via api_server parameter
from pyTONPublicAPI import pyTONPublicAPI, pyTONAPIServerTonCenter
api_server=pyTONAPIServerTonCenter()
client = pyTONPublicAPI(api_server=api_server)

Ton.sh

Class

  • pyTONAPIServerTonSh

Additional constructor paramters:

  • blockchain_id - Identifier of target blockchain ID, either "mainnet" or "test". Default is "None", so default begaviour is up to API server.

Ton Center

Class

  • pyTONAPIServerTonCenter

Additional constructor paramters:

  • api_key - Authentication key. Using API without API key is limited to 1 request per second. Default is "None", so API is used without API key.

Testnet Ton Center

Class

  • pyTONAPIServerTonCenterTest

Additional constructor paramters:

  • api_key - Authentication key. Using API without API key is limited to 1 request per second. Default is "None", so API is used without API key.

Notes

  1. API servers support different subset of commands. Check correspondent API specification before use.
  2. API servers have different reply formats! Currently it's up to you to deal with it. May be once there will be a reply parser for unification.

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

pyTONPublicAPI-0.0.5.tar.gz (8.1 kB view details)

Uploaded Source

File details

Details for the file pyTONPublicAPI-0.0.5.tar.gz.

File metadata

  • Download URL: pyTONPublicAPI-0.0.5.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.6

File hashes

Hashes for pyTONPublicAPI-0.0.5.tar.gz
Algorithm Hash digest
SHA256 cc8e1566262afb8e7d569eb820cab824e2abe4870828d19f2c8718d6f3ed93b6
MD5 a1eaac417578e1531a887860e57c0361
BLAKE2b-256 383917d174122d682b3e86e2c12be77fe77e48727b2f54095fe91acb0c6660aa

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