OKEx Official API Custom Development Guide: Modifying Pip Websockets to Version 6.0

·

This guide provides step-by-step instructions for customizing OKEx's official API, including upgrading the websockets library to version 6.0 for improved performance and compatibility.


Prerequisites

Before proceeding, ensure you have:


Installation Steps

1. Install Required Libraries

Run these commands in your terminal:

pip install requests
pip install websockets==6.0

Note: If you encounter missing dependencies, install them as prompted.

2. Configure API Credentials

Obtain your API keys from OKEx:

  1. Visit the API management page
  2. Generate new keys if needed
  3. Fill in your credentials:
api_key = "YOUR_API_KEY"
secret_key = "YOUR_SECRET_KEY"
passphrase = "YOUR_PASSPHRASE"

Implementation Guide

Initial Setup

  1. Add your credentials to get_balance.py in the init_basics function
  2. First-time users must run init_account_order to retrieve historical order data (last 3 months)
  3. Subsequent updates can use the update function

Key Functions

Additional Notes


Best Practices for API Development

👉 Advanced API integration techniques


FAQ Section

How often should I update my order data?

We recommend running update daily for active traders, or weekly for casual users.

Why use websockets 6.0?

Version 6.0 offers improved stability and reduced latency compared to older versions, crucial for real-time trading applications.

Can I modify the default USDT price?

Yes, you can implement your own price feed by modifying the relevant functions in the code.

Where can I find example implementations?

👉 Complete API examples repository contains various use cases and implementation samples.

What's the rate limit for OKEx API?

The current limit is 20 requests per 2 seconds - plan your application workflow accordingly.


This guide provides the foundation for building custom trading tools using OKEx's powerful API. For more complex implementations, consider studying their comprehensive documentation and community resources.