Skip to content

Bitexen/bitexen-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bitexen Logo

Official Python Client for Bitexen Cryptocurrency Exchange

PyPI version Python 3.7+ License

API Documentation | Examples


πŸ“‹ Table of Contents


🎯 Overview

bitexen-python is the official Python client library for Bitexen Cryptocurrency Exchange. It provides a simple, intuitive interface for interacting with the exchange's API endpoints, including market data, order management, and account operations.

πŸ“¦ Installation

From PyPI

pip install bitexen-client

From Source

git clone https://github.com/Bitexen/bitexen-python.git
cd bitexen-python
pip install -e .

Requirements

  • Python 3.7 or higher
  • requests library (automatically installed)

πŸš€ Quick Start

Public Endpoints (No Authentication)

from bitexen_client import API

# Initialize client
api = API()

# Get market information
market_info = api.get_market_info("BTCTRY")
print(market_info)

# Get ticker data
ticker = api.get_ticker("BTCTRY")
print(f"Last Price: {ticker.last_price}")

# Get order book
order_book = api.get_order_book("BTCTRY")
print(f"Bids: {order_book.buyers}")
print(f"Asks: {order_book.sellers}")

Private Endpoints (Authentication Required)

from bitexen_client import API

# Initialize with credentials
api = API(
    uri="https://www.bitexen.com/",
    key="your_api_key",
    secret="your_api_secret",
    username="your_username",
    pass_phrase="your_passphrase"
)

# Get account balance
balance = api.get_balance()
print(balance.data)

# Get open orders
orders = api.get_open_orders(account_name="Main", market_code="BTCTRY")
print(orders.data.orders)

# Create a limit buy order
order = api.create_order(
    account_name="Main",
    market_code="BTCTRY",
    buy_sell="B",  # "B" for buy, "S" for sell
    order_type="limit",
    volume=0.001,
    price=50000
)
print(f"Order created: {order.data.order_number}")

# Cancel an order
result = api.cancel_order(order_number="123456")
print(result)

βš™οΈ Configuration

Option 1: Settings File (Recommended)

Create a bitexen_client_settings.py file in your project root:

key = "your_api_key"
secret = "your_api_secret"
api_uri = "https://www.bitexen.com"
pass_phrase = "your_passphrase"
username = "your_username"
LOG_LEVEL = 10  # Optional: logging level

Then use the client without passing credentials:

from bitexen_client import API
api = API()  # Automatically loads from settings file

Option 2: Constructor Parameters

from bitexen_client import API

api = API(
    uri="https://www.bitexen.com/",
    key="your_api_key",
    secret="your_api_secret",
    username="your_username",
    pass_phrase="your_passphrase",
    timeout=5  # Optional: request timeout in seconds
)

Configuration Priority

Constructor parameters > Settings file

πŸ“š API Reference

Public Endpoints

Method Description Parameters
get_market_info(market_code) Get market information market_code: e.g., "BTCTRY"
get_ticker(market_code) Get ticker data market_code: e.g., "BTCTRY"
get_order_book(market_code) Get order book (bids/asks) market_code: e.g., "BTCTRY"

Private Endpoints (Authentication Required)

Method Description Parameters
get_balance(account_name) Get account balance account_name: default "Main"
get_open_orders(account_name, market_code) Get open orders account_name, market_code
get_closed_orders(account_name, market_code) Get closed orders account_name, market_code
get_order_status(order_number) Get specific order status order_number: order ID
create_order(...) Create new order See Order Creation
cancel_order(order_number) Cancel an order order_number: order ID
withdraw_request(currency_code, amount, alias) Request withdrawal currency_code, amount, alias

Order Creation

api.create_order(
    account_name="Main",       # Account name (default: "Main")
    market_code="BTCTRY",      # Market pair
    buy_sell="B",              # "B" for buy, "S" for sell
    order_type="limit",        # "limit", "market", "stop"
    volume=0.001,              # Order volume
    price=50000,               # Order price (required for limit orders)
    stop_price=None            # Stop price (for stop orders)
)

Response Format

All methods return a dotdict object with dot-notation access:

result = api.get_ticker("BTCTRY")

# Access with dot notation
print(result.status)      # "success" or "error"
print(result.data.last)   # Last price
print(result.data.high)   # 24h high

# Or dictionary access
print(result['data']['last'])

Error Handling

from bitexen_client import APIException

try:
    order = api.create_order(...)
except APIException as e:
    print(f"Error code: {e.code}")
    print(f"Error message: {e.value}")

πŸ’‘ Examples

Check the examples/ directory for complete working examples:

python examples/example.py

Available example functions:

  • order_book() - Fetch order book data
  • ticker() - Get ticker information
  • market_info() - Market details
  • balance() - Account balance (requires auth)
  • open_orders() - List open orders (requires auth)
  • closed_orders() - List order history (requires auth)
  • create_order() - Place an order (requires auth)
  • cancel_order() - Cancel an order (requires auth)

πŸ” Security

Best Practices

  • βœ… Never commit credentials - Use environment variables or settings files
  • βœ… Add to .gitignore - Exclude bitexen_client_settings.py
  • βœ… Use HTTPS - Always use https://www.bitexen.com/
  • βœ… Rotate API keys - Regularly update your API credentials
  • βœ… Limit permissions - Only grant necessary API permissions

Authentication Flow

The client uses HMAC-SHA256 signature-based authentication:

Signature = HMAC-SHA256(
    apikey + username + passphrase + timestamp + request_body,
    secret_key
)

Headers sent with each private request:

  • ACCESS-KEY: Your API key
  • ACCESS-USER: Your username
  • ACCESS-PASSPHRASE: Your passphrase
  • ACCESS-TIMESTAMP: Request timestamp
  • ACCESS-SIGN: HMAC signature

Rate Limiting

The client includes automatic rate limit handling:

  • Detects 429 Too Many Requests responses
  • Waits 5 seconds before retrying
  • Automatically retries once

πŸ†˜ Support

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Client for connecting to Bitexen Trading API

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •