apllox-connector-python
Binance Futures Public API Connector Python
This is a lightweight library that works as a connector to Apollo Finance public API
Installation
pip install apollox-connector-python
Documentation
RESTful APIs
Usage examples:
from apollox.rest_api import Client
# Get timestamp
client = Client()
print(client.time())
client = Client(key='<api_key>', secret='<api_secret>')
# Get account information
print(client.account())
# Post a new order
params = {
'symbol': 'BTCUSDT',
'side': 'SELL',
'type': 'LIMIT',
'timeInForce': 'GTC',
'quantity': 0.002,
'price': 59808
}
response = client.new_order(**params)
print(response)
Please find examples folder to check for more endpoints.
Base URL
https://fapi.apollox.finance
Optional parameters
PEP8 suggests lowercase with words separated by underscores, but for this connector, the methods' optional parameters should follow their exact naming as in the API documentation.
# Recognised parameter name
response = client.query_order('BTCUSDT', orderListId=1)
# Unrecognised parameter name
response = client.query_order('BTCUSDT', order_list_id=1)
RecvWindow parameter
Additional parameter recvWindow is available for endpoints requiring signature.
It defaults to 5000 (milliseconds) and can be any value lower than 60000(milliseconds).
Anything beyond the limit will result in an error response from Binance server.
from apollox.rest_api import Client
client = Client(key, secret)
response = client.query_order('BTCUSDT', orderId=11, recvWindow=10000)
Timeout
timeout is available to be assigned with the number of seconds you find most appropriate to wait for a server response.
Please remember the value as it won't be shown in error message no bytes have been received on the underlying socket for timeout seconds.
By default, timeout is None. Hence, requests do not time out.
from apollox.rest_api import Client
client= Client(timeout=1)
Proxy
proxy is supported
from bapollo.rest_api import Client
proxies = { 'https': 'http://1.2.3.4:8080' }
client= Client(proxies=proxies)
Response Metadata
The Binance API server provides weight usages in the headers of each response.
You can display them by initializing the client with show_limit_usage=True:
from apollox.rest_api import Client
client = Client(show_limit_usage=True)
print(client.time())
You can also display full response metadata to help in debugging:
client = Client(show_header=True)
print(client.time())
If ClientError is received, it'll display full response meta information.
Display logs
Setting the log level to DEBUG will log the request URL, payload and response text.
Error
There are 2 types of error returned from the library:
apollox.error.ClientError- This is thrown when server returns
4XX, it's an issue from client side. - It has 4 properties:
status_code- HTTP status codeerror_code- Server's error code, e.g.-1102error_message- Server's error message, e.g.Unknown order sent.header- Full response header.
- This is thrown when server returns
apollox.error.ServerError- This is thrown when server returns
5XX, it's an issue from server side.
- This is thrown when server returns
Websocket
from apollox.websocket.client.stream import WebsocketClient as Client
def message_handler(message):
print(message)
ws_client = Client()
ws_client.start()
ws_client.mini_ticker(
symbol='bnbusdt',
id=1,
callback=message_handler,
)
# Combine selected streams
ws_client.instant_subscribe(
stream=['bnbusdt@bookTicker', 'ethusdt@bookTicker'],
callback=message_handler,
)
ws_client.stop()
More websocket examples are available in the examples folder
Heartbeat
Once connected, the websocket server sends a ping frame every 3 minutes and requires a response pong frame back within a 10 minutes period. This package handles the pong responses automatically.
Metadata
Release files for apollox-connector-python 1.1.0
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 | |
|---|---|---|---|---|
| apollox-connector-python-1.1.0.tar.gz | 15.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apollox_connector_python-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.1 kB
Release files / apollox-connector-python-1.1.0.tar.gz
| Download URL | apollox-connector-python-1.1.0.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23a7bb451fde4b98478555090fd6e29253a462562bbd0562a098a080021ab0d3
|
|
BLAKE2b-256 checksum How to use checksums |
89c695570b904ed88877d78e2011b38b7b553bd81b1e58854ad25e6ec0fe5059
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|
Release files / apollox_connector_python-1.1.0-py3-none-any.whl
| Download URL | apollox_connector_python-1.1.0-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4adc014d615049957fb8dfe4c820d1a8080f1fb95d04689e658e88a76b4a4c0
|
|
BLAKE2b-256 checksum How to use checksums |
55e805116cfab7d5f44e16a5b61ccda07c3f8d161e26c16164d6c79f5a2538bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|
Security for apollox-connector-python 1.1.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.