SDK Guide
Only available for Node.js and Python. (To be supported language : Java)
1. Setup Import
- Import ProBit SDK module into the project.
- Node :
npm install probit-socket-sdk
- Python :
pip install probit_socket_sdk
- Node :
2. Basic Information
- Get
client ID
andSecret Key
value from ProBit API Credentials Website.
(https://www.probit.com/en-us/my-page/api-management/api-credential) - These informations are needed for authentication
3. Create Instance / Class
- Create new instance of ProBitSdk using
client ID
andSecret Key
as arguments.
4. Connect to WebSocket
Market Data
- Subscribe Request-
connectMarketData(market_id, filter)
/connect_market_data(market_id, filter)
type | string | must be 'subscribe' |
---|---|---|
market_id | string | Market ID that you want subscribe. |
filter | string[] | Required parameters are one or more of the values below. ticker, |
- Responses (When subscribe, and on going)
param | type | description |
---|---|---|
ticker | Object | Returns if you put 'ticker' in your "filter" parameter. TICKER Object:
|
recent_trades | RECENT_TRADES[] | Returns if you put 'recent_trades' in your "filter" parameter. RECENT_TRADES:
|
order_books_l0 | ORDER_BOOK[] | Returns if you put 'order_books_l0' or 'order_books_l1' or 'order_books_l2' or 'order_books_l3' or 'order_books_l4' in your "filter" parameter. It sends differ of order_book. order_books_l0 |
My Balance
- Subscribe Request-
connectMyBalance()
/connect_my_balance()
- Responses (When subscribe, and on going)
param | type | description |
---|---|---|
BALANCE | object[] | See below. |
column | type | description |
---|---|---|
currency_id | string | Currency ID |
available | string | Available amount of currency. |
total | string | Total amount of currency. |
Open Order
- Subscribe Request-
connectOpenOrder()
/connect_open_order()
- Responses (When subscribe, and on going)
param | type | description |
---|---|---|
OPEN_ORDER | object[] | See below. |
column | type | meaning |
---|---|---|
id | string | specific id for the new order |
user_id | string | user id of the user who makes the order |
market_id | string | requested market_id |
type | string | "limit" or "market" |
side | string | "buy" or "sell" |
quantity | string | quantity |
limit_price | string | If type is limit, then order's price. |
time_in_force | string | selected time_in_force. |
filled_cost | string | The amount of filled cost. It is for market. |
filled_quantity | string | The amount of filled quantity. |
open_quantity | string | The amount of open quantity. |
cancelled_quantity | string | The amount of cancelled quantity. |
status | string | should be 'open'. |
time | Date | Order time. |
client_order_id | string | client_order_id. |
5. Read Data
- Use
getCachedData(channel, market_id?, filter?)
/get_cached_data(channel, market_id?, filter?)
to read the received data from the server.
channel | argument | value |
---|---|---|
Market Data | channel |
|
market_id |
| |
filter | Pick one from below. | |
My Balance | channel |
|
Open Order | channel |
|
Example)
// 1.Setup Import
import { ProBitSDK } from "probit-socket-sdk";
async function main() {
// 2.Basic Information
const id = 'YOUR_CLIENT_ID_VALUE';
const key = 'YOUR_SECRET_KEY_VALUE';
// 3.Create Instance / Class
const sdk = await ProBitSDK.createInstance(id, key);
// 4.Connect WebSocket
const connect = await sdk.connect();
console.log(`connect: ${connect}`);
await sdk.connectMarketData("BTC-USDT", ["order_books_l0", "order_books_l4", "recent_trades", "ticker"]);
await sdk.connectMyBalance();
await sdk.connectOpenOrder();
// 5.Read Data
console.log("\nMarketData-order_books_l0: " + JSON.stringify(sdk.getCachedData("marketdata", "BTC-USDT", "order_books_l0")));
console.log("\nMarketData-order_books_l4: " + JSON.stringify(sdk.getCachedData("marketdata", "BTC-USDT", "order_books_l4")));
console.log("\nMarketData-recent_trades: " + JSON.stringify(sdk.getCachedData("marketdata", "BTC-USDT", "recent_trades")));
console.log("\nMarketData-ticker: " + JSON.stringify(sdk.getCachedData("marketdata", "BTC-USDT", "ticker")));
console.log("\nBalance : " + JSON.stringify(sdk.getCachedData("balance")));
console.log("\nOpenOrder : " + JSON.stringify(sdk.getCachedData("open_order")));
}
main().catch((e) => {
console.log(e);
});
# Setup Import
from probit_socket_sdk import ProBitSdk
from probit_socket_sdk.constant.channel_type import CHANNEL_TYPE
from probit_socket_sdk.constant.filter_type import FILTER_TYPE
# Basic Information
id = "YOUR_CLIENT_ID_VALUE"
secret = "YOUR_SECRET_KEY_VALUE"
# Create Instance / Class
sdk = ProBitSdk(id, secret)
# Connect to WebSocket
sdk.connect_market_data("BTC-USDT", [FILTER_TYPE.order_books_l0.name, FILTER_TYPE.order_books_l4.name,
FILTER_TYPE.recent_trades.name, FILTER_TYPE.ticker.name])
sdk.connect_my_balance()
sdk.connect_open_order()
# Read Data
print(f"order_books_l0: {sdk.get_cached_data(CHANNEL_TYPE.MARKET_DATA.value, "BTC-USDT", FILTER_TYPE.order_books_l0.name)}")
print(f"order_books_l0: {sdk.get_cached_data(CHANNEL_TYPE.MARKET_DATA.value, "BTC-USDT", FILTER_TYPE.order_books_l4.name)}")
print(f"ticker: {sdk.get_cached_data(CHANNEL_TYPE.MARKET_DATA.value, "BTC-USDT", FILTER_TYPE.ticker.name)}")
print(f"recent_trade: {sdk.get_cached_data(CHANNEL_TYPE.MARKET_DATA.value, "BTC-USDT", FILTER_TYPE.recent_trades.name)}")
print(f"balance: {sdk.get_cached_data(CHANNEL_TYPE.BALANCE.value)}")
print(f"open_order: {sdk.get_cached_data(CHANNEL_TYPE.OPEN_ORDER.value)}")
Updated 3 days ago