ton-http-api 2.0.47__tar.gz → 2.0.49__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.2
2
+ Name: ton-http-api
3
+ Version: 2.0.49
4
+ Summary: HTTP API for TON (The Open Network)
5
+ Home-page: https://github.com/toncenter/ton-http-api
6
+ Author: K-Dimentional Tree
7
+ Author-email: kdimentionaltree@gmail.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: License :: Other/Proprietary License
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: redis==5.0.1
19
+ Requires-Dist: loguru==0.6.0
20
+ Requires-Dist: fastapi==0.99.1
21
+ Requires-Dist: pydantic==1.10.14
22
+ Requires-Dist: requests==2.28.0
23
+ Requires-Dist: ring==0.10.1
24
+ Requires-Dist: uvicorn==0.17.6
25
+ Requires-Dist: gunicorn==20.1.0
26
+ Requires-Dist: pytonlib==0.0.64
27
+ Requires-Dist: inject==4.3.1
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: requires-dist
35
+ Dynamic: requires-python
36
+ Dynamic: summary
37
+
38
+ ![splash_http_api](https://user-images.githubusercontent.com/1449561/154847286-989a6c51-1615-45e1-b40f-aec7c13014fa.png)
39
+
40
+ # HTTP API for [The Open Network](https://ton.org)
41
+
42
+ Since TON nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection.
43
+
44
+ TON HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the TON network using `tonlibjson`.
45
+
46
+ You can use the ready-made [toncenter.com](https://toncenter.com) service or start your own instance.
47
+
48
+ ## Building and running
49
+
50
+ Recommended hardware:
51
+ - CPU architecture: x86_64 or arm64.
52
+ - HTTP API only: 1 vCPU, 2 GB RAM.
53
+ - HTTP API with cache enabled: 2 vCPUs, 4 GB RAM.
54
+
55
+ There are two main ways to run TON HTTP API:
56
+ - __Local__ *(experimental)*: works on following platforms: Ubuntu Linux (x86_64, arm64), MacOSX (Intel x86_64, Apple M1 arm64) and Windows (x86_64).
57
+ - __Docker Compose__: flexible configuration, recommended for production environments, works on any x86_64 and arm64 OS with Docker available.
58
+
59
+ ### Local run *(experimental)*
60
+ **Note:** It is simple but not stable way to run the service. We do not recommend to use it in production.
61
+ - (Windows only, first time) Install OpenSSL v1.1.1 for win64 from [here](https://slproweb.com/products/Win32OpenSSL.html).
62
+ - Install package: `pip install ton-http-api`.
63
+ - Run service with `ton-http-api`. This command will run service with [mainnet](https://ton.org/global-config.json) configuration.
64
+ - Run `ton-http-api --help` to show parameters list.
65
+
66
+ ### Docker Compose
67
+ - (First time) Install required tools: `docker`, `docker-compose`, `curl`.
68
+ - For Ubuntu: run `scripts/setup.sh` from the root of the repo.
69
+ - For MacOS and Windows: install [Docker Desktop](https://www.docker.com/products/docker-desktop/).
70
+ - **Note:** we recommend to use Docker Compose V2.
71
+ - Download TON configuration files to private folder:
72
+ ```bash
73
+ mkdir private
74
+ curl -sL https://ton-blockchain.github.io/global.config.json > private/mainnet.json
75
+ curl -sL https://ton-blockchain.github.io/testnet-global.config.json > private/testnet.json
76
+ ```
77
+ - Run `./configure.py` to create `.env` file with necessary environment variables (see [Configuration](#Configuration) for details).
78
+ - Build services: `docker-compose build`.
79
+ - Or pull latest images: `docker-compose pull`.
80
+ - Run services: `docker-compose up -d`.
81
+ - Stop services: `docker-compose down`.
82
+
83
+ ### Configuration
84
+
85
+ You should specify environment parameters and run `./configure.py` to create `.env` file.
86
+ ```bash
87
+ export TON_API_LITESERVER_CONFIG=private/testnet.json
88
+ ./configure.py
89
+ ```
90
+
91
+ The service supports the following environment variables:
92
+ #### Webserver settings
93
+ - `TON_API_HTTP_PORT` *(default: 80)*
94
+
95
+ Port for HTTP connections of API service.
96
+
97
+ - `TON_API_ROOT_PATH` *(default: /)*
98
+
99
+ 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.
100
+
101
+ - `TON_API_WEBSERVERS_WORKERS` *(default: 1)*
102
+
103
+ 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.
104
+
105
+ - `TON_API_GET_METHODS_ENABLED` *(default: 1)*
106
+
107
+ Enables `runGetMethod` endpoint.
108
+
109
+ - `TON_API_JSON_RPC_ENABLED` *(default: 1)*
110
+
111
+ Enables `jsonRPC` endpoint.
112
+
113
+ - `TON_API_LOGS_JSONIFY` *(default: 0)*
114
+
115
+ Enables printing all logs in json format.
116
+
117
+ - `TON_API_LOGS_LEVEL` *(default: ERROR)*
118
+
119
+ Defines log verbosity level. Values allowed: `DEBUG`,`INFO`,`WARNING`,`ERROR`,`CRITICAL`.
120
+
121
+ - `TON_API_GUNICORN_FLAGS` *(default: empty)*
122
+
123
+ Additional Gunicorn [command line arguments](https://docs.gunicorn.org/en/stable/settings.html).
124
+
125
+ #### Tonlib settings
126
+ - `TON_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://ton.org/global-config.json)*
127
+
128
+ 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.
129
+
130
+ - `TON_API_TONLIB_KEYSTORE` *(default docker: /tmp/ton_keystore local: ./ton_keystore/)*
131
+
132
+ Path to tonlib keystore.
133
+
134
+ - `TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)*
135
+
136
+ Number of maximum parallel requests count per worker.
137
+
138
+ - `TON_API_TONLIB_CDLL_PATH` *(default: empty)*
139
+
140
+ Path to tonlibjson binary. It could be useful if you want to run service on unsupported platform and have built the `libtonlibjson` library manually.
141
+
142
+ - `TON_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)*
143
+
144
+ Timeout for liteserver requests.
145
+
146
+ #### Cache configuration
147
+ - `TON_API_CACHE_ENABLED` *(default: 0)*
148
+
149
+ Enables caching lite server responses with Redis.
150
+
151
+ - `TON_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)*
152
+
153
+ Redis cache service host.
154
+
155
+ - `TON_API_CACHE_REDIS_PORT` *(default: 6379)*
156
+
157
+ Redis cache service port.
158
+
159
+ - `TON_API_CACHE_REDIS_TIMEOUT` *(default: 1)*
160
+
161
+ Redis cache service port.
162
+
163
+
164
+ ## FAQ
165
+ #### How to point the service to my own lite server?
166
+
167
+ To point the HTTP API to your own lite server you should set `TON_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server.
168
+
169
+ - If you use MyTonCtrl on your node you can generate config file with these commands:
170
+ ```
171
+ $ mytonctrl
172
+ MyTonCtrl> installer
173
+ MyTonInstaller> clcf
174
+ ```
175
+ Config file will be saved at `/usr/bin/ton/local.config.json`.
176
+ - If you don't use MyTonCtrl: 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:
177
+ ```
178
+ python -c 'import codecs; f=open("liteserver.pub", "rb+"); pub=f.read()[4:]; print(str(codecs.encode(pub,"base64")).replace("\n",""))'
179
+ ```
180
+ - Once config file is created assign variable `TON_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project.
181
+
182
+ #### How to run multiple API instances on single machine?
183
+
184
+ - Clone the repo as many times as many instances you need to the folders with different names (otherwise docker compose containers will conflict).
185
+ - Configure each instance to use unique port (env variable `TON_API_HTTP_PORT`)
186
+ - Build and run every instance.
187
+
188
+ #### How to update tonlibjson library?
189
+
190
+ Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/toncenter/pytonlib).
191
+ - Docker Compose: `docker-compose build --no-cache`.
192
+ - Local run: `pip install -U ton-http-api`.
@@ -281,9 +281,10 @@ async def get_wallet_information(
281
281
  """
282
282
  address = prepare_address(address)
283
283
  result = await tonlib.raw_get_account_state(address)
284
- res = {'wallet': False, 'balance': 0, 'account_state': None, 'wallet_type': None, 'seqno': None}
284
+ res = {'wallet': False, 'balance': 0, 'extra_currencies': [], 'account_state': None, 'wallet_type': None, 'seqno': None}
285
285
  res["account_state"] = address_state(result)
286
286
  res["balance"] = result["balance"] if (result["balance"] and int(result["balance"]) > 0) else 0
287
+ res["extra_currencies"] = result["extra_currencies"]
287
288
  if "last_transaction_id" in result:
288
289
  res["last_transaction_id"] = result["last_transaction_id"]
289
290
  ci = sha256(result["code"])
@@ -24,18 +24,19 @@ setup(
24
24
  'ring==0.10.1',
25
25
  'uvicorn==0.17.6',
26
26
  'gunicorn==20.1.0',
27
- 'pytonlib==0.0.58',
27
+ 'pytonlib==0.0.64',
28
28
  'inject==4.3.1'
29
29
  ],
30
30
  package_data={},
31
31
  zip_safe=True,
32
- python_requires='>=3.7',
32
+ python_requires='>=3.9',
33
33
  classifiers=[
34
34
  "Development Status :: 3 - Alpha",
35
35
  "Intended Audience :: Developers",
36
- "Programming Language :: Python :: 3.7",
37
- "Programming Language :: Python :: 3.8",
38
36
  "Programming Language :: Python :: 3.9",
37
+ "Programming Language :: Python :: 3.10",
38
+ "Programming Language :: Python :: 3.11",
39
+ "Programming Language :: Python :: 3.12",
39
40
  "License :: Other/Proprietary License",
40
41
  "Topic :: Software Development :: Libraries"
41
42
  ],
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.2
2
+ Name: ton-http-api
3
+ Version: 2.0.49
4
+ Summary: HTTP API for TON (The Open Network)
5
+ Home-page: https://github.com/toncenter/ton-http-api
6
+ Author: K-Dimentional Tree
7
+ Author-email: kdimentionaltree@gmail.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: License :: Other/Proprietary License
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: redis==5.0.1
19
+ Requires-Dist: loguru==0.6.0
20
+ Requires-Dist: fastapi==0.99.1
21
+ Requires-Dist: pydantic==1.10.14
22
+ Requires-Dist: requests==2.28.0
23
+ Requires-Dist: ring==0.10.1
24
+ Requires-Dist: uvicorn==0.17.6
25
+ Requires-Dist: gunicorn==20.1.0
26
+ Requires-Dist: pytonlib==0.0.64
27
+ Requires-Dist: inject==4.3.1
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: requires-dist
35
+ Dynamic: requires-python
36
+ Dynamic: summary
37
+
38
+ ![splash_http_api](https://user-images.githubusercontent.com/1449561/154847286-989a6c51-1615-45e1-b40f-aec7c13014fa.png)
39
+
40
+ # HTTP API for [The Open Network](https://ton.org)
41
+
42
+ Since TON nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection.
43
+
44
+ TON HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the TON network using `tonlibjson`.
45
+
46
+ You can use the ready-made [toncenter.com](https://toncenter.com) service or start your own instance.
47
+
48
+ ## Building and running
49
+
50
+ Recommended hardware:
51
+ - CPU architecture: x86_64 or arm64.
52
+ - HTTP API only: 1 vCPU, 2 GB RAM.
53
+ - HTTP API with cache enabled: 2 vCPUs, 4 GB RAM.
54
+
55
+ There are two main ways to run TON HTTP API:
56
+ - __Local__ *(experimental)*: works on following platforms: Ubuntu Linux (x86_64, arm64), MacOSX (Intel x86_64, Apple M1 arm64) and Windows (x86_64).
57
+ - __Docker Compose__: flexible configuration, recommended for production environments, works on any x86_64 and arm64 OS with Docker available.
58
+
59
+ ### Local run *(experimental)*
60
+ **Note:** It is simple but not stable way to run the service. We do not recommend to use it in production.
61
+ - (Windows only, first time) Install OpenSSL v1.1.1 for win64 from [here](https://slproweb.com/products/Win32OpenSSL.html).
62
+ - Install package: `pip install ton-http-api`.
63
+ - Run service with `ton-http-api`. This command will run service with [mainnet](https://ton.org/global-config.json) configuration.
64
+ - Run `ton-http-api --help` to show parameters list.
65
+
66
+ ### Docker Compose
67
+ - (First time) Install required tools: `docker`, `docker-compose`, `curl`.
68
+ - For Ubuntu: run `scripts/setup.sh` from the root of the repo.
69
+ - For MacOS and Windows: install [Docker Desktop](https://www.docker.com/products/docker-desktop/).
70
+ - **Note:** we recommend to use Docker Compose V2.
71
+ - Download TON configuration files to private folder:
72
+ ```bash
73
+ mkdir private
74
+ curl -sL https://ton-blockchain.github.io/global.config.json > private/mainnet.json
75
+ curl -sL https://ton-blockchain.github.io/testnet-global.config.json > private/testnet.json
76
+ ```
77
+ - Run `./configure.py` to create `.env` file with necessary environment variables (see [Configuration](#Configuration) for details).
78
+ - Build services: `docker-compose build`.
79
+ - Or pull latest images: `docker-compose pull`.
80
+ - Run services: `docker-compose up -d`.
81
+ - Stop services: `docker-compose down`.
82
+
83
+ ### Configuration
84
+
85
+ You should specify environment parameters and run `./configure.py` to create `.env` file.
86
+ ```bash
87
+ export TON_API_LITESERVER_CONFIG=private/testnet.json
88
+ ./configure.py
89
+ ```
90
+
91
+ The service supports the following environment variables:
92
+ #### Webserver settings
93
+ - `TON_API_HTTP_PORT` *(default: 80)*
94
+
95
+ Port for HTTP connections of API service.
96
+
97
+ - `TON_API_ROOT_PATH` *(default: /)*
98
+
99
+ 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.
100
+
101
+ - `TON_API_WEBSERVERS_WORKERS` *(default: 1)*
102
+
103
+ 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.
104
+
105
+ - `TON_API_GET_METHODS_ENABLED` *(default: 1)*
106
+
107
+ Enables `runGetMethod` endpoint.
108
+
109
+ - `TON_API_JSON_RPC_ENABLED` *(default: 1)*
110
+
111
+ Enables `jsonRPC` endpoint.
112
+
113
+ - `TON_API_LOGS_JSONIFY` *(default: 0)*
114
+
115
+ Enables printing all logs in json format.
116
+
117
+ - `TON_API_LOGS_LEVEL` *(default: ERROR)*
118
+
119
+ Defines log verbosity level. Values allowed: `DEBUG`,`INFO`,`WARNING`,`ERROR`,`CRITICAL`.
120
+
121
+ - `TON_API_GUNICORN_FLAGS` *(default: empty)*
122
+
123
+ Additional Gunicorn [command line arguments](https://docs.gunicorn.org/en/stable/settings.html).
124
+
125
+ #### Tonlib settings
126
+ - `TON_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://ton.org/global-config.json)*
127
+
128
+ 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.
129
+
130
+ - `TON_API_TONLIB_KEYSTORE` *(default docker: /tmp/ton_keystore local: ./ton_keystore/)*
131
+
132
+ Path to tonlib keystore.
133
+
134
+ - `TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)*
135
+
136
+ Number of maximum parallel requests count per worker.
137
+
138
+ - `TON_API_TONLIB_CDLL_PATH` *(default: empty)*
139
+
140
+ Path to tonlibjson binary. It could be useful if you want to run service on unsupported platform and have built the `libtonlibjson` library manually.
141
+
142
+ - `TON_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)*
143
+
144
+ Timeout for liteserver requests.
145
+
146
+ #### Cache configuration
147
+ - `TON_API_CACHE_ENABLED` *(default: 0)*
148
+
149
+ Enables caching lite server responses with Redis.
150
+
151
+ - `TON_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)*
152
+
153
+ Redis cache service host.
154
+
155
+ - `TON_API_CACHE_REDIS_PORT` *(default: 6379)*
156
+
157
+ Redis cache service port.
158
+
159
+ - `TON_API_CACHE_REDIS_TIMEOUT` *(default: 1)*
160
+
161
+ Redis cache service port.
162
+
163
+
164
+ ## FAQ
165
+ #### How to point the service to my own lite server?
166
+
167
+ To point the HTTP API to your own lite server you should set `TON_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server.
168
+
169
+ - If you use MyTonCtrl on your node you can generate config file with these commands:
170
+ ```
171
+ $ mytonctrl
172
+ MyTonCtrl> installer
173
+ MyTonInstaller> clcf
174
+ ```
175
+ Config file will be saved at `/usr/bin/ton/local.config.json`.
176
+ - If you don't use MyTonCtrl: 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:
177
+ ```
178
+ python -c 'import codecs; f=open("liteserver.pub", "rb+"); pub=f.read()[4:]; print(str(codecs.encode(pub,"base64")).replace("\n",""))'
179
+ ```
180
+ - Once config file is created assign variable `TON_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project.
181
+
182
+ #### How to run multiple API instances on single machine?
183
+
184
+ - Clone the repo as many times as many instances you need to the folders with different names (otherwise docker compose containers will conflict).
185
+ - Configure each instance to use unique port (env variable `TON_API_HTTP_PORT`)
186
+ - Build and run every instance.
187
+
188
+ #### How to update tonlibjson library?
189
+
190
+ Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/toncenter/pytonlib).
191
+ - Docker Compose: `docker-compose build --no-cache`.
192
+ - Local run: `pip install -U ton-http-api`.
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  ton-http-api = pyTON.__main__:main
3
-
@@ -6,5 +6,5 @@ requests==2.28.0
6
6
  ring==0.10.1
7
7
  uvicorn==0.17.6
8
8
  gunicorn==20.1.0
9
- pytonlib==0.0.58
9
+ pytonlib==0.0.64
10
10
  inject==4.3.1
@@ -1,174 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: ton-http-api
3
- Version: 2.0.47
4
- Summary: HTTP API for TON (The Open Network)
5
- Home-page: https://github.com/toncenter/ton-http-api
6
- Author: K-Dimentional Tree
7
- Author-email: kdimentionaltree@gmail.com
8
- License: UNKNOWN
9
- Description: ![splash_http_api](https://user-images.githubusercontent.com/1449561/154847286-989a6c51-1615-45e1-b40f-aec7c13014fa.png)
10
-
11
- # HTTP API for [The Open Network](https://ton.org)
12
-
13
- Since TON nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection.
14
-
15
- TON HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the TON network using `tonlibjson`.
16
-
17
- You can use the ready-made [toncenter.com](https://toncenter.com) service or start your own instance.
18
-
19
- ## Building and running
20
-
21
- Recommended hardware:
22
- - CPU architecture: x86_64 or arm64.
23
- - HTTP API only: 1 vCPU, 2 GB RAM.
24
- - HTTP API with cache enabled: 2 vCPUs, 4 GB RAM.
25
-
26
- There are two main ways to run TON HTTP API:
27
- - __Local__ *(experimental)*: works on following platforms: Ubuntu Linux (x86_64, arm64), MacOSX (Intel x86_64, Apple M1 arm64) and Windows (x86_64).
28
- - __Docker Compose__: flexible configuration, recommended for production environments, works on any x86_64 and arm64 OS with Docker available.
29
-
30
- ### Local run *(experimental)*
31
- **Note:** It is simple but not stable way to run the service. We do not recommend to use it in production.
32
- - (Windows only, first time) Install OpenSSL v1.1.1 for win64 from [here](https://slproweb.com/products/Win32OpenSSL.html).
33
- - Install package: `pip install ton-http-api`.
34
- - Run service with `ton-http-api`. This command will run service with [mainnet](https://ton.org/global-config.json) configuration.
35
- - Run `ton-http-api --help` to show parameters list.
36
-
37
- ### Docker Compose
38
- - (First time) Install required tools: `docker`, `docker-compose`, `curl`.
39
- - For Ubuntu: run `scripts/setup.sh` from the root of the repo.
40
- - For MacOS and Windows: install [Docker Desktop](https://www.docker.com/products/docker-desktop/).
41
- - **Note:** we recommend to use Docker Compose V2.
42
- - Download TON configuration files to private folder:
43
- ```bash
44
- mkdir private
45
- curl -sL https://ton-blockchain.github.io/global.config.json > private/mainnet.json
46
- curl -sL https://ton-blockchain.github.io/testnet-global.config.json > private/testnet.json
47
- ```
48
- - Run `./configure.py` to create `.env` file with necessary environment variables (see [Configuration](#Configuration) for details).
49
- - Build services: `docker-compose build`.
50
- - Or pull latest images: `docker-compose pull`.
51
- - Run services: `docker-compose up -d`.
52
- - Stop services: `docker-compose down`.
53
-
54
- ### Configuration
55
-
56
- You should specify environment parameters and run `./configure.py` to create `.env` file.
57
- ```bash
58
- export TON_API_LITESERVER_CONFIG=private/testnet.json
59
- ./configure.py
60
- ```
61
-
62
- The service supports the following environment variables:
63
- #### Webserver settings
64
- - `TON_API_HTTP_PORT` *(default: 80)*
65
-
66
- Port for HTTP connections of API service.
67
-
68
- - `TON_API_ROOT_PATH` *(default: /)*
69
-
70
- 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.
71
-
72
- - `TON_API_WEBSERVERS_WORKERS` *(default: 1)*
73
-
74
- 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.
75
-
76
- - `TON_API_GET_METHODS_ENABLED` *(default: 1)*
77
-
78
- Enables `runGetMethod` endpoint.
79
-
80
- - `TON_API_JSON_RPC_ENABLED` *(default: 1)*
81
-
82
- Enables `jsonRPC` endpoint.
83
-
84
- - `TON_API_LOGS_JSONIFY` *(default: 0)*
85
-
86
- Enables printing all logs in json format.
87
-
88
- - `TON_API_LOGS_LEVEL` *(default: ERROR)*
89
-
90
- Defines log verbosity level. Values allowed: `DEBUG`,`INFO`,`WARNING`,`ERROR`,`CRITICAL`.
91
-
92
- - `TON_API_GUNICORN_FLAGS` *(default: empty)*
93
-
94
- Additional Gunicorn [command line arguments](https://docs.gunicorn.org/en/stable/settings.html).
95
-
96
- #### Tonlib settings
97
- - `TON_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://ton.org/global-config.json)*
98
-
99
- 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.
100
-
101
- - `TON_API_TONLIB_KEYSTORE` *(default docker: /tmp/ton_keystore local: ./ton_keystore/)*
102
-
103
- Path to tonlib keystore.
104
-
105
- - `TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)*
106
-
107
- Number of maximum parallel requests count per worker.
108
-
109
- - `TON_API_TONLIB_CDLL_PATH` *(default: empty)*
110
-
111
- Path to tonlibjson binary. It could be useful if you want to run service on unsupported platform and have built the `libtonlibjson` library manually.
112
-
113
- - `TON_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)*
114
-
115
- Timeout for liteserver requests.
116
-
117
- #### Cache configuration
118
- - `TON_API_CACHE_ENABLED` *(default: 0)*
119
-
120
- Enables caching lite server responses with Redis.
121
-
122
- - `TON_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)*
123
-
124
- Redis cache service host.
125
-
126
- - `TON_API_CACHE_REDIS_PORT` *(default: 6379)*
127
-
128
- Redis cache service port.
129
-
130
- - `TON_API_CACHE_REDIS_TIMEOUT` *(default: 1)*
131
-
132
- Redis cache service port.
133
-
134
-
135
- ## FAQ
136
- #### How to point the service to my own lite server?
137
-
138
- To point the HTTP API to your own lite server you should set `TON_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server.
139
-
140
- - If you use MyTonCtrl on your node you can generate config file with these commands:
141
- ```
142
- $ mytonctrl
143
- MyTonCtrl> installer
144
- MyTonInstaller> clcf
145
- ```
146
- Config file will be saved at `/usr/bin/ton/local.config.json`.
147
- - If you don't use MyTonCtrl: 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:
148
- ```
149
- python -c 'import codecs; f=open("liteserver.pub", "rb+"); pub=f.read()[4:]; print(str(codecs.encode(pub,"base64")).replace("\n",""))'
150
- ```
151
- - Once config file is created assign variable `TON_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project.
152
-
153
- #### How to run multiple API instances on single machine?
154
-
155
- - Clone the repo as many times as many instances you need to the folders with different names (otherwise docker compose containers will conflict).
156
- - Configure each instance to use unique port (env variable `TON_API_HTTP_PORT`)
157
- - Build and run every instance.
158
-
159
- #### How to update tonlibjson library?
160
-
161
- Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/toncenter/pytonlib).
162
- - Docker Compose: `docker-compose build --no-cache`.
163
- - Local run: `pip install -U ton-http-api`.
164
-
165
- Platform: UNKNOWN
166
- Classifier: Development Status :: 3 - Alpha
167
- Classifier: Intended Audience :: Developers
168
- Classifier: Programming Language :: Python :: 3.7
169
- Classifier: Programming Language :: Python :: 3.8
170
- Classifier: Programming Language :: Python :: 3.9
171
- Classifier: License :: Other/Proprietary License
172
- Classifier: Topic :: Software Development :: Libraries
173
- Requires-Python: >=3.7
174
- Description-Content-Type: text/markdown
@@ -1,174 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: ton-http-api
3
- Version: 2.0.47
4
- Summary: HTTP API for TON (The Open Network)
5
- Home-page: https://github.com/toncenter/ton-http-api
6
- Author: K-Dimentional Tree
7
- Author-email: kdimentionaltree@gmail.com
8
- License: UNKNOWN
9
- Description: ![splash_http_api](https://user-images.githubusercontent.com/1449561/154847286-989a6c51-1615-45e1-b40f-aec7c13014fa.png)
10
-
11
- # HTTP API for [The Open Network](https://ton.org)
12
-
13
- Since TON nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection.
14
-
15
- TON HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the TON network using `tonlibjson`.
16
-
17
- You can use the ready-made [toncenter.com](https://toncenter.com) service or start your own instance.
18
-
19
- ## Building and running
20
-
21
- Recommended hardware:
22
- - CPU architecture: x86_64 or arm64.
23
- - HTTP API only: 1 vCPU, 2 GB RAM.
24
- - HTTP API with cache enabled: 2 vCPUs, 4 GB RAM.
25
-
26
- There are two main ways to run TON HTTP API:
27
- - __Local__ *(experimental)*: works on following platforms: Ubuntu Linux (x86_64, arm64), MacOSX (Intel x86_64, Apple M1 arm64) and Windows (x86_64).
28
- - __Docker Compose__: flexible configuration, recommended for production environments, works on any x86_64 and arm64 OS with Docker available.
29
-
30
- ### Local run *(experimental)*
31
- **Note:** It is simple but not stable way to run the service. We do not recommend to use it in production.
32
- - (Windows only, first time) Install OpenSSL v1.1.1 for win64 from [here](https://slproweb.com/products/Win32OpenSSL.html).
33
- - Install package: `pip install ton-http-api`.
34
- - Run service with `ton-http-api`. This command will run service with [mainnet](https://ton.org/global-config.json) configuration.
35
- - Run `ton-http-api --help` to show parameters list.
36
-
37
- ### Docker Compose
38
- - (First time) Install required tools: `docker`, `docker-compose`, `curl`.
39
- - For Ubuntu: run `scripts/setup.sh` from the root of the repo.
40
- - For MacOS and Windows: install [Docker Desktop](https://www.docker.com/products/docker-desktop/).
41
- - **Note:** we recommend to use Docker Compose V2.
42
- - Download TON configuration files to private folder:
43
- ```bash
44
- mkdir private
45
- curl -sL https://ton-blockchain.github.io/global.config.json > private/mainnet.json
46
- curl -sL https://ton-blockchain.github.io/testnet-global.config.json > private/testnet.json
47
- ```
48
- - Run `./configure.py` to create `.env` file with necessary environment variables (see [Configuration](#Configuration) for details).
49
- - Build services: `docker-compose build`.
50
- - Or pull latest images: `docker-compose pull`.
51
- - Run services: `docker-compose up -d`.
52
- - Stop services: `docker-compose down`.
53
-
54
- ### Configuration
55
-
56
- You should specify environment parameters and run `./configure.py` to create `.env` file.
57
- ```bash
58
- export TON_API_LITESERVER_CONFIG=private/testnet.json
59
- ./configure.py
60
- ```
61
-
62
- The service supports the following environment variables:
63
- #### Webserver settings
64
- - `TON_API_HTTP_PORT` *(default: 80)*
65
-
66
- Port for HTTP connections of API service.
67
-
68
- - `TON_API_ROOT_PATH` *(default: /)*
69
-
70
- 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.
71
-
72
- - `TON_API_WEBSERVERS_WORKERS` *(default: 1)*
73
-
74
- 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.
75
-
76
- - `TON_API_GET_METHODS_ENABLED` *(default: 1)*
77
-
78
- Enables `runGetMethod` endpoint.
79
-
80
- - `TON_API_JSON_RPC_ENABLED` *(default: 1)*
81
-
82
- Enables `jsonRPC` endpoint.
83
-
84
- - `TON_API_LOGS_JSONIFY` *(default: 0)*
85
-
86
- Enables printing all logs in json format.
87
-
88
- - `TON_API_LOGS_LEVEL` *(default: ERROR)*
89
-
90
- Defines log verbosity level. Values allowed: `DEBUG`,`INFO`,`WARNING`,`ERROR`,`CRITICAL`.
91
-
92
- - `TON_API_GUNICORN_FLAGS` *(default: empty)*
93
-
94
- Additional Gunicorn [command line arguments](https://docs.gunicorn.org/en/stable/settings.html).
95
-
96
- #### Tonlib settings
97
- - `TON_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://ton.org/global-config.json)*
98
-
99
- 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.
100
-
101
- - `TON_API_TONLIB_KEYSTORE` *(default docker: /tmp/ton_keystore local: ./ton_keystore/)*
102
-
103
- Path to tonlib keystore.
104
-
105
- - `TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)*
106
-
107
- Number of maximum parallel requests count per worker.
108
-
109
- - `TON_API_TONLIB_CDLL_PATH` *(default: empty)*
110
-
111
- Path to tonlibjson binary. It could be useful if you want to run service on unsupported platform and have built the `libtonlibjson` library manually.
112
-
113
- - `TON_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)*
114
-
115
- Timeout for liteserver requests.
116
-
117
- #### Cache configuration
118
- - `TON_API_CACHE_ENABLED` *(default: 0)*
119
-
120
- Enables caching lite server responses with Redis.
121
-
122
- - `TON_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)*
123
-
124
- Redis cache service host.
125
-
126
- - `TON_API_CACHE_REDIS_PORT` *(default: 6379)*
127
-
128
- Redis cache service port.
129
-
130
- - `TON_API_CACHE_REDIS_TIMEOUT` *(default: 1)*
131
-
132
- Redis cache service port.
133
-
134
-
135
- ## FAQ
136
- #### How to point the service to my own lite server?
137
-
138
- To point the HTTP API to your own lite server you should set `TON_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server.
139
-
140
- - If you use MyTonCtrl on your node you can generate config file with these commands:
141
- ```
142
- $ mytonctrl
143
- MyTonCtrl> installer
144
- MyTonInstaller> clcf
145
- ```
146
- Config file will be saved at `/usr/bin/ton/local.config.json`.
147
- - If you don't use MyTonCtrl: 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:
148
- ```
149
- python -c 'import codecs; f=open("liteserver.pub", "rb+"); pub=f.read()[4:]; print(str(codecs.encode(pub,"base64")).replace("\n",""))'
150
- ```
151
- - Once config file is created assign variable `TON_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project.
152
-
153
- #### How to run multiple API instances on single machine?
154
-
155
- - Clone the repo as many times as many instances you need to the folders with different names (otherwise docker compose containers will conflict).
156
- - Configure each instance to use unique port (env variable `TON_API_HTTP_PORT`)
157
- - Build and run every instance.
158
-
159
- #### How to update tonlibjson library?
160
-
161
- Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/toncenter/pytonlib).
162
- - Docker Compose: `docker-compose build --no-cache`.
163
- - Local run: `pip install -U ton-http-api`.
164
-
165
- Platform: UNKNOWN
166
- Classifier: Development Status :: 3 - Alpha
167
- Classifier: Intended Audience :: Developers
168
- Classifier: Programming Language :: Python :: 3.7
169
- Classifier: Programming Language :: Python :: 3.8
170
- Classifier: Programming Language :: Python :: 3.9
171
- Classifier: License :: Other/Proprietary License
172
- Classifier: Topic :: Software Development :: Libraries
173
- Requires-Python: >=3.7
174
- Description-Content-Type: text/markdown
File without changes
File without changes