Skip to main content

Python3 HTTP/WebSocket API Connector

Project description

ABfinance Python API

PyPI version Python License: MIT

Official Python3 API connector for ABFinance's HTTP and WebSocket APIs.

Installation

pip install abfinance-python-api

Requires Python 3.9+

Quick Start

HTTP API

from abfinance_api.unified_trading import HTTP

# Public endpoints (no authentication required)
session = HTTP(testnet=True)
print(session.get_server_time())
print(session.get_orderbook(category="linear", symbol="BTCUSDT"))

# Private endpoints (authentication required)
session = HTTP(
    testnet=True,
    api_key="your_api_key",
    api_secret="your_api_secret",
)

# Get wallet balance
print(session.get_wallet_balance(accountType="UNIFIED"))

# Place an order
print(session.place_order(
    category="linear",
    symbol="BTCUSDT",
    side="Buy",
    orderType="Limit",
    qty="0.01",
    price="30000",
))

WebSocket API

from abfinance_api.unified_trading import WebSocket

def handle_message(message):
    print(message)

# Public WebSocket
ws = WebSocket(testnet=True, channel_type="linear")
ws.orderbook_stream(depth=50, symbol="BTCUSDT", callback=handle_message)

# Private WebSocket
ws_private = WebSocket(
    testnet=True,
    channel_type="private",
    api_key="your_api_key",
    api_secret="your_api_secret",
)
ws_private.order_stream(callback=handle_message)

Features

  • HTTP API support for all endpoints
  • WebSocket API for real-time data
  • HMAC and RSA authentication
  • Testnet and mainnet support

Examples

See the examples directory for more usage examples.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abfinance_python_api-1.0.5.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abfinance_python_api-1.0.5-py2.py3-none-any.whl (25.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file abfinance_python_api-1.0.5.tar.gz.

File metadata

  • Download URL: abfinance_python_api-1.0.5.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for abfinance_python_api-1.0.5.tar.gz
Algorithm Hash digest
SHA256 f4a64656f6e1267a594b9cbc65b7e51d34f8c80e53b9e4117acb277319ba7331
MD5 364b19d4564c98b6d25744146fcae4ac
BLAKE2b-256 fb7f1fd89d6710641bacd5b1a8b312ebee1e51324a3f189632eb9f565d5c2f5d

See more details on using hashes here.

File details

Details for the file abfinance_python_api-1.0.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for abfinance_python_api-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 207bdb03154f7049c538b639d0bc7de4e781cf929ceab345ea97c68abcdbd4db
MD5 2598c3e19ea6e780a0dba51e8553ce69
BLAKE2b-256 a603ecc7cd36a8c0b4e13b90d09db7785fb1a0ef33db8ee52b98ce37a6d00dcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page