Overview
This guide explains how to self-host the TON HTTP API (v2) locally using either:- Docker (recommended for production setups): Works on any x86_64 and arm64 OS with Docker available.
- Python (lightweight, for testing only): Works on Ubuntu Linux (x86_64, arm64), MacOSX (Intel x86_64, Apple M1 arm64) and Windows (x86_64).
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.
Option 1: Run via Docker (recommended)
Prerequisites
Before you begin, make sure the following tools are installed on your system:- Docker
- Docker Compose (preferably version 2 or higher)
- curl
How to install prerequisites
How to install prerequisites
-
macOS and Windows:
Download and install Docker Desktop, which includes both Docker and Docker Compose. -
Ubuntu/Linux:
Navigate to the root of the repository and run the setup script:
1. Clone the repository
2. Download TON config files
3. Generate the .env file
Choose the network you want to use:
- Testnet:
- Mainnet:
The generated
To customize settings or see all available environment variables, check the Configuration section.
.env file includes default configuration options.To customize settings or see all available environment variables, check the Configuration section.
4. Build and run the container
Test your API
Check masterchain info:Switch between Mainnet and Testnet
To switch networks:.env file and restarts the container with the selected network config.
Video Walkthrough
▶️ Watch GuideOption 2: Run with Python (testing only)
Prerequisites
Before you begin, make sure the following tools are installed on your system:- Python 3.8+
- pip
- curl
How to install prerequisites
How to install prerequisites
-
macOS and Windows:
Python is usually pre-installed. If not, download it from python.org.
Then, install the package: -
Ubuntu/Linux:
Install Python and pip if needed:
1. Install the package
2. Run the service
- Default (Mainnet):
- Testnet:
Run
ton-http-api --help to show the list of available options and commands or check the configuration section. 
