Python FTX API Sample Code
FTX is a cryptocurrency derivatives exchange.
This is a wrapper around the FTX API as described on FTX, including all features the API provides using clear and readable objects, both for the REST as the websocket API.
An unofficial Python3 library to interact with FTX.COM and FTX.US.
I am in no way affiliated with FTX, use at your own risk.
If you think something is broken, something is missing or have any questions, please open an Issue
Get Started and Documentation
If you're new to FTX, use the following link to save 5% on all of your trade fees.
Install
pip install python-ftx-api
Usage
If you are using an exchange from the US, or other TLD then make sure pass tld='us' when creating the client. Default tld='com'
Change your API KEY and your SECRET KEY.
Restful Api Sample Code
from pyftx import Client
API = "your-api-key"
SECRET = "your-secret-key"
subaccount_name = "your-subaccount_name"
client = Client(API, SECRET, subaccount=subaccount_name)
info = client.get_markets()
print(info)
Websocket Sample Code
from pyftx import ThreadedWebsocketManager
def on_read(event):
print(event)
API = "your-api-key"
SECRET = "your-secret-key"
subaccount_name = "your-subaccount_name"
wsm = ThreadedWebsocketManager(API, SECRET, subaccount=subaccount_name)
wsm.start()
# Un-auth subscribe - Public Channels
name = 'market_connection'
wsm.start_socket(on_read, socket_name=name)
wsm.subscribe(name, channel="ticker", op="subscribe", market="ETH-PERP")
# Auth subscribe - [filled](https://docs.ftx.com/#fills-2)
name = 'private_connection'
wsm.start_socket(on_read, socket_name=name)
wsm.login(socket_name=name)
wsm.subscribe(
name,
channel="fills",
op="subscribe",
)
# Auth subscribe -[orders](https://docs.ftx.com/#orders-2)
ws_type = 'private_connection'
wsm.start_socket(on_read, socket_name=ws_type)
wsm.login(socket_name=ws_type)
wsm.subscribe(
ws_type,
channel="orders",
op="subscribe",
)
Websocket with arguments
from pyftx import ThreadedWebsocketManager
from functools import partial
API = "your-api-key"
SECRET = "your-secret-key"
subaccount_name = "your-subaccount_name"
def on_message(event, argument):
msg = "{}.event: {}".format(argument, event)
print("on message: ", msg)
wsm = ThreadedWebsocketManager(API, SECRET, subaccount=subaccount_name)
wsm.start()
# Un-auth subscribe - Public Channels
subaccount_name = "Cuongitl"
callback_with_arguments = partial(on_message, argument=subaccount_name)
name = 'market_connection'
wsm.start_socket(callback_with_arguments, socket_name=name)
wsm.subscribe(name, channel="ticker", op="subscribe", market="ETH-PERP")
Donate / Sponsor
I develop and maintain this package on my own for free in my spare time. Donations are greatly appreciated. If you prefer to donate any other currency please contact me.
-
BTC:
3LrqgdMbToh1mAD3sjhbv3oaEppXY7hkae -
BTC:
0x329a9F2b01aDA25F15eAE4C633d3bed8442c7BC6(BSC) -
USDT:
0x329a9F2b01aDA25F15eAE4C633d3bed8442c7BC6(BSC) -
FTT:
0x329a9F2b01aDA25F15eAE4C633d3bed8442c7BC6(ERC-20)
Communities
- Telegram: Python FTX API
Release Notes
The release notes can be found here.
Metadata
Release files for python-ftx-api 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-ftx-api-0.0.6.tar.gz | 13.0 kB | Without provenance | Details for python-ftx-api-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_ftx_api-0.0.6-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for python_ftx_api-0.0.6-py2.py3-none-any.whl |
Total release size: 25.7 kB
Release files / python-ftx-api-0.0.6.tar.gz
| Download URL | python-ftx-api-0.0.6.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c3444a9a97cd229e8bf94b50c294e5b66bb83b2b76e325167b11c2200188e59
|
|
BLAKE2b-256 checksum How to use checksums |
1be132d44948736fc0cc906899b3bf92f181e0f6c1369be3d2c9fa5c415c1819
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.13
|
Release files / python_ftx_api-0.0.6-py2.py3-none-any.whl
| Download URL | python_ftx_api-0.0.6-py2.py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ce1f39b4a7677a3ed13aad05df4b84a47357fbcfede3046174c17f94291d6187
|
|
BLAKE2b-256 checksum How to use checksums |
5b9ff8694d4bdfce53b2952b38004e869e284cf53643f3b58d0e20cb11f58f36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.13
|
Security for python-ftx-api 0.0.6
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.