Skip to main content

splash_http_api

HTTP API for Ice Open Network

Since ION nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection.

ION HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the ION network using tonlibjson.

You can use the ready-made ice-blockchain.com service or start your own instance.

Building and running

Recommended hardware:

  • CPU architecture: x86_64 or arm64.
  • HTTP API only: 1 vCPU, 2 GB RAM.
  • HTTP API with cache enabled: 2 vCPUs, 4 GB RAM.

There are two main ways to run ION HTTP API:

  • Local (experimental): works on following platforms: Ubuntu Linux (x86_64, arm64), MacOSX (Intel x86_64, Apple M1 arm64) and Windows (x86_64).
  • Docker Compose: flexible configuration, recommended for production environments, works on any x86_64 and arm64 OS with Docker available.

Local run (experimental)

Note: It is simple but not stable way to run the service. We do not recommend to use it in production.

  • (Windows only, first time) Install OpenSSL v1.1.1 for win64 from here.
  • Install package: pip install ion-http-api.
  • Run service with ion-http-api. This command will run service with mainnet configuration.
    • Run ion-http-api --help to show parameters list.

Docker Compose

  • (First time) Install required tools: docker, docker-compose, curl.
    • For Ubuntu: run scripts/setup.sh from the root of the repo.
    • For MacOS and Windows: install Docker Desktop.
    • Note: we recommend to use Docker Compose V2.
  • Download ION configuration files to private folder:
    mkdir private
    curl -sL https://cdn.ice.io/mainnet/global.config.json > private/mainnet.json
    curl -sL https://cdn.ice.io/testnet/testnet-global.config.json > private/testnet.json
    
  • Run ./configure.py to create .env file with necessary environment variables (see Configuration for details).
  • Build services: docker-compose build.
    • Or pull latest images: docker-compose pull.
  • Run services: docker-compose up -d.
  • Stop services: docker-compose down.

Configuration

You should specify environment parameters and run ./configure.py to create .env file. bash export ION_API_LITESERVER_CONFIG=private/testnet.json ./configure.py

The service supports the following environment variables:

Webserver settings

  • ION_API_HTTP_PORT (default: 80)

    Port for HTTP connections of API service.

  • ION_API_ROOT_PATH (default: /)

    If you use a proxy server such as Nginx or Traefik you might change the default API path prefix (e.g. /api/v2). If so you have to pass the path prefix to the API service in this variable.

  • ION_API_WEBSERVERS_WORKERS (default: 1)

    Number of webserver processes. If your server is under high load try increase this value to increase RPS. We recommend setting it to number of CPU cores / 2.

  • ION_API_GET_METHODS_ENABLED (default: 1)

    Enables runGetMethod endpoint.

  • ION_API_JSON_RPC_ENABLED (default: 1)

    Enables jsonRPC endpoint.

  • ION_API_LOGS_JSONIFY (default: 0)

    Enables printing all logs in json format.

  • ION_API_LOGS_LEVEL (default: ERROR)

    Defines log verbosity level. Values allowed: DEBUG,INFO,WARNING,ERROR,CRITICAL.

  • ION_API_GUNICORN_FLAGS (default: empty)

    Additional Gunicorn command line arguments.

Tonlib settings

  • ION_API_TONLIB_LITESERVER_CONFIG (default docker: private/mainnet.json local: https://cdn.ice.io/mainnet/global.config.json)

    Path to config file with lite servers information. In case of native run you can pass URL to download config. Docker support only path to file.

  • ION_API_TONLIB_KEYSTORE (default docker: /tmp/ion_keystore local: ./ion_keystore/)

    Path to tonlib keystore.

  • ION_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER (default: 50)

    Number of maximum parallel requests count per worker.

  • ION_API_TONLIB_CDLL_PATH (default: empty)

    Path to tonlibjson binary. It could be useful if you want to run service on unsupported platform and have built the libtonlibjson library manually.

  • ION_API_TONLIB_REQUEST_TIMEOUT (default: 10)

    Timeout for liteserver requests.

Cache configuration

  • ION_API_CACHE_ENABLED (default: 0)

    Enables caching lite server responses with Redis.

  • ION_API_CACHE_REDIS_ENDPOINT (default: localhost, docker: cache_redis)

    Redis cache service host.

  • ION_API_CACHE_REDIS_PORT (default: 6379)

    Redis cache service port.

  • ION_API_CACHE_REDIS_TIMEOUT (default: 1)

    Redis cache service port.

FAQ

How to point the service to my own lite server?

To point the HTTP API to your own lite server you should set ION_API_TONLIB_LITESERVER_CONFIG to config file with your only lite server.

  • If you use MyIonCtrl on your node you can generate config file with these commands:
    $ myionctrl
    MyIonCtrl> installer
    MyIonInstaller> clcf
    
    Config file will be saved at /usr/bin/ion/local.config.json.
  • If you don't use MyIonCtrl: copy private/mainnet.json and overwrite section liteservers with your liteservers ip, port and public key. To get public key from liteserver.pub file use the following script:
    python -c 'import codecs; f=open("liteserver.pub", "rb+"); pub=f.read()[4:]; print(str(codecs.encode(pub,"base64")).replace("\n",""))'
    
  • Once config file is created assign variable ION_API_TONLIB_LITESERVER_CONFIG to its path, run ./configure.py and rebuild the project.

How to run multiple API instances on single machine?

  • Clone the repo as many times as many instances you need to the folders with different names (otherwise docker compose containers will conflict).
  • Configure each instance to use unique port (env variable ION_API_HTTP_PORT)
  • Build and run every instance.

How to update tonlibjson library?

Binary file libtonlibjson now moved to pytonlib.

  • Docker Compose: docker-compose build --no-cache.
  • Local run: pip install -U ion-http-api.

Metadata

Release files for ion-http-api 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ion-http-api 0.0.0
File Size Uploaded Provenance Actions
ion_http_api-0.0.0.tar.gz 19.9 kB Without provenance Details for ion_http_api-0.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ion-http-api 0.0.0
File Interpreter ABI Platform Actions
ion_http_api-0.0.0-py3-none-any.whl Python 3 none any Details for ion_http_api-0.0.0-py3-none-any.whl

Total release size: 41.9 kB

Release files / ion_http_api-0.0.0.tar.gz

Download URL ion_http_api-0.0.0.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
99a9bfaca961935c9f51771677bc0596a6785ff24618dbd89370d3ad587dda7f
BLAKE2b-256 checksum
How to use checksums
d93f35cab702540ed65b65019610361aa7301d045282113d2eb64f65ad57d79b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / ion_http_api-0.0.0-py3-none-any.whl

Download URL ion_http_api-0.0.0-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccc5b9ccf8408d90c6211edd8391bc92025ebe13fc72d5fb043778b9cc34e5f5
BLAKE2b-256 checksum
How to use checksums
ee5256c0c70f9b3585f806881e2c18131fdda59e916a5d6dbed18abef7e099cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Security for ion-http-api 0.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page