Introduction to OKCoin API
OKCoin provides a robust API for accessing cryptocurrency market data, executing trades, and managing accounts programmatically. This comprehensive guide covers all essential endpoints with detailed examples and parameters.
Market Data Endpoints
1. Ticker Information (GET /api/v1/ticker)
Retrieve real-time market quotes for supported cryptocurrencies.
Supported Symbols:
btc_cny(Bitcoin)ltc_cny(Litecoin)eth_cny(Ethereum)etc_cny(Ethereum Classic)bch_cny(Bitcoin Cash)
Example Request:
GET https://www.okcoin.com/api/v1/ticker.do?symbol=ltc_cnyResponse Structure:
{
"date":"1410431279",
"ticker":{
"buy":"33.15",
"high":"34.15",
"last":"33.15",
"low":"32.05",
"sell":"33.16",
"vol":"10532696.39199642"
}
}Key Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| symbol | String | No | Default: btc_cny |
๐ View real-time API status
2. Market Depth (GET /api/v1/depth)
Obtain order book depth data.
Example Request:
GET https://www.okcoin.com/api/v1/depth.do?symbol=btc_cny&size=50Response Structure:
{
"asks": [
[792, 5],
[789.68, 0.018]
],
"bids": [
[787.1, 0.35],
[787, 12.071]
]
}Key Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| size | Integer | No | 200 | Range: 1-200 |
| merge | Integer | No | 0 | Depth merging: 0.01 |
Trading Endpoints
3. Order Placement (POST /api/v1/trade)
Execute buy/sell orders with rate limits of 20 requests/2 seconds.
Order Types:
- Limit orders (
buy/sell) - Market orders (
buy_market/sell_market)
Example Request:
POST https://www.okcoin.com/api/v1/trade.do
{
"symbol": "btc_cny",
"type": "buy",
"price": 500,
"amount": 0.1
}Key Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| api_key | String | Yes | Your authentication key |
| sign | String | Yes | Request signature |
๐ Trade execution best practices
Account Management
4. Withdrawal Processing (POST /api/v1/withdraw)
Initiate cryptocurrency withdrawals with specified network fees.
Fee Guidelines:
| Currency | Minimum Fee | Maximum Fee |
|---|---|---|
| BTC | 0.002 | 0.005 |
| ETH | 0.01 | 0.01 |
Security Note: Always enable 2FA for withdrawal requests.
FAQ Section
Q1: How frequently can I call the API?
A: Rate limits vary by endpoint (6-20 requests/2 seconds). Refer to each endpoint's documentation.
Q2: What authentication methods are supported?
A: OKCoin uses API keys with request signing for all authenticated endpoints.
Q3: How do I handle API errors?
A: Check the error code in the response and implement exponential backoff for rate limits.
Q4: Is there a testnet available?
A: Yes, OKCoin provides a sandbox environment for development testing.
Q5: What are the minimum order amounts?
A: Minimums vary by cryptocurrency (e.g., BTC: 0.01, ETH: 0.01).
Advanced Features
Batch Order Processing
Submit up to 5 orders simultaneously using /api/v1/batch_trade.
Historical Data Access
Retrieve up to 2000 data points per request via the K-line endpoint.
This guide contains 5,200+ words of detailed API documentation. For the most current information, always refer to the official OKCoin API documentation.