@coinex-org/coinex
Version:
A lightweight, type-safe TypeScript HTTP client for the official CoinEx API v2, covering all major modules including Spot, Futures, Account, and Assets.
1,940 lines (1,930 loc) • 210 kB
TypeScript
import { Options } from 'ky';
/**
* @enum MarketType
* @description Enumeration of market types.
*/
declare enum MarketType {
SPOT = "SPOT",
MARGIN = "MARGIN",
FUTURES = "FUTURES"
}
/**
* @enum MarketStatus
* @description Enumeration of market statuses.
*/
declare enum MarketStatus {
BIDDING = "bidding",
COUNTING_DOWN = "counting_down",
ONLINE = "online"
}
/**
* @enum OrderSide
* @description Enumeration of order sides.
*/
declare enum OrderSide {
BUY = "buy",
SELL = "sell"
}
/**
* @enum OrderType
* @description Enumeration of order types.
*/
declare enum OrderType {
LIMIT = "limit",
MARKET = "market",
MAKER_ONLY = "maker_only",
IOC = "ioc",
FOK = "fok"
}
/**
* @enum StpMode
* @description Enumeration of STP (Self-Trade Prevention) modes.
*/
declare enum StpMode {
CANCEL_TAKER = "ct",
CANCEL_MAKER = "cm",
CANCEL_BOTH = "both"
}
/**
* @enum OrderEvent
* @description Enumeration of order events.
*/
declare enum OrderEvent {
PUT = "put",
UPDATE = "update",
MODIFY = "modify",
FINISH = "finish"
}
/**
* @enum StopOrderEvent
* @description Enumeration of stop order events.
*/
declare enum StopOrderEvent {
PUT = "put",
ACTIVE = "active",
CANCEL = "cancel"
}
/**
* @enum StopOrderStatus
* @description Enumeration of stop order statuses.
*/
declare enum StopOrderStatus {
PUT = "put",
ACTIVE_SUCCESS = "active_success",
ACTIVE_FAIL = "active_fail",
CANCEL = "cancel"
}
/**
* @enum TriggerDirection
* @description Enumeration of trigger directions.
*/
declare enum TriggerDirection {
HIGHER = "higher",
LOWER = "lower"
}
/**
* @enum PositionEvent
* @description Enumeration of position events.
*/
declare enum PositionEvent {
UPDATE = "update",
CLOSE = "close",
SYS_CLOSE = "sys_close",
ADL = "adl",
LIQ = "liq"
}
/**
* @enum Locale
* @description Enumeration of supported locales.
*/
declare enum Locale {
DE_DE = "de-DE",
EN_US = "en-US",
ES_AR = "es-AR",
ES_ES = "es-ES",
ES_MX = "es-MX",
FR_FR = "fr-FR",
KK_KZ = "kk-KZ",
ID_ID = "id-ID",
UK_UA = "uk-UA",
JA_JP = "ja-JP",
RU_RU = "ru-RU",
TH_TH = "th-TH",
PT_BR = "pt-BR",
TR_TR = "tr-TR",
VI_VN = "vi-VN",
ZH_TW = "zh-TW",
AR_SA = "ar-SA",
HI_IN = "hi-IN",
FIL_PH = "fil-PH"
}
/**
* @enum Permission
* @description Enumeration of sub-account permissions.
*/
declare enum Permission {
FUTURES = "FUTURES",
MARGIN = "MARGIN",
AMM = "AMM",
API = "API"
}
/**
* @enum TransferDirection
* @description Enumeration of transfer directions.
*/
declare enum TransferDirection {
IN = "in",
OUT = "out"
}
/**
* @enum TransferStatus
* @description Enumeration of transfer statuses.
*/
declare enum TransferStatus {
CREATED = "created",
DEDUCTED = "deducted",
FAILED = "failed",
FINISHED = "finished"
}
/**
* @enum LoanStatus
* @description Enumeration of loan statuses.
*/
declare enum LoanStatus {
LOAN = "loan",
DEBT = "debt",
LIQUIDATED = "liquidated",
FINISH = "finish"
}
/**
* @enum DepositStatus
* @description Enumeration of deposit statuses.
*/
declare enum DepositStatus {
PROCESSING = "processing",
CONFIRMING = "confirming",
CANCELLED = "cancelled",
FINISHED = "finished",
TOO_SMALL = "too_small",
EXCEPTION = "exception"
}
/**
* @enum OrderStatus
* @description Enumeration of order statuses.
*/
declare enum OrderStatus {
OPEN = "open",
PART_FILLED = "part_filled",
FILLED = "filled",
PART_CANCELED = "part_canceled",
CANCELED = "canceled"
}
/**
* @enum ContractType
* @description Enumeration of contract types.
*/
declare enum ContractType {
LINEAR = "linear",
INVERSE = "inverse"
}
/**
* @enum MarginMode
* @description Enumeration of margin modes.
*/
declare enum MarginMode {
ISOLATED = "isolated",
CROSS = "cross"
}
/**
* @enum TakeProfitType
* @description Enumeration of take profit types.
*/
declare enum TakeProfitType {
LATEST_PRICE = "latest_price",
MARK_PRICE = "mark_price"
}
/**
* @enum StopLossType
* @description Enumeration of stop loss types.
*/
declare enum StopLossType {
LATEST_PRICE = "latest_price",
MARK_PRICE = "mark_price"
}
/**
* @enum PositionSide
* @description Enumeration of position sides.
*/
declare enum PositionSide {
SHORT = "short",
LONG = "long"
}
/**
* @enum PositionFinishedType
* @description Enumeration of position finished types.
*/
declare enum PositionFinishedType {
LIQ = "liq",
ADL = "adl",
SYS = "sys",
LIMIT = "limit",
MARKET = "market",
MARKET_CLOSE_ALL = "market_close_all",
TAKE_PROFIT = "take_profit",
STOP_LOSS = "stop_loss"
}
/**
* @enum TriggerPriceType
* @description Enumeration of trigger price types.
*/
declare enum TriggerPriceType {
LATEST_PRICE = "latest_price",
MARK_PRICE = "mark_price",
INDEX_PRICE = "index_price"
}
/**
* @enum TransactionType
* @description Enumeration of transaction types.
*/
declare enum TransactionType {
DEPOSIT = "deposit",
WITHDRAW = "withdraw",
TRADE = "trade",
MAKER_CASH_BACK = "maker_cash_back"
}
/**
* @enum AmmType
* @description Enumeration of AMM types.
*/
declare enum AmmType {
INFINITE = "infinite",
FINITE = "finite"
}
/**
* @enum UserType
* @description Enumeration of user types.
*/
declare enum UserType {
NORMAL = "NORMAL",
SUB_ACCOUNT = "SUB_ACCOUNT"
}
/**
* @interface GetAccountTradeFeesParams
* @description Parameters for getting the account trading fee rate.
* @see https://docs.coinex.com/api/v2/account/fees/http/get-account-trade-fees
*/
interface GetAccountTradeFeesParams {
/**
* @property {MarketType} [market_type] - Market type.
* @description If not passed, the default is spot market.
* @example MarketType.SPOT
*/
market_type?: MarketType;
}
/**
* @interface Fee
* @description Trading fee rate details.
*/
interface Fee {
/**
* @property {string} market - Market name.
* @example "BTCUSDT"
*/
market: string;
/**
* @property {string} taker_fee - Taker fee rate.
* @example "0.002"
*/
taker_fee: string;
/**
* @property {string} maker_fee - Maker fee rate.
* @example "0.001"
*/
maker_fee: string;
}
/**
* @type GetAccountTradeFeesResponse
* @description Represents the response from the Get Account Trading Fee Rate endpoint, which is an array of fee structures.
*/
type GetAccountTradeFeesResponse = Fee[];
/**
* @interface GetFuturesMarketSettingsResponse
* @description Response for getting futures market settings.
* @see https://docs.coinex.com/api/v2/account/settings/http/accquire-futures-market-settings
*/
interface GetFuturesMarketSettingsResponse {
/**
* @property {string[]} markets - List of markets.
* @example ["BTCUSDT", "ETHUSDT"]
*/
markets: string[];
/**
* @property {PositionSide} position_side - Position side.
* @example PositionSide.LONG
*/
position_side: PositionSide;
}
/**
* @interface ModifyAccountSettingsParams
* @description Parameters for modifying account settings.
* @see https://docs.coinex.com/api/v2/account/settings/http/modify-account-settings
*/
interface ModifyAccountSettingsParams {
/**
* @property {boolean} cet_enabled - Whether to use CET as transaction fee.
* @example true
*/
cet_enabled: boolean;
}
/**
* @interface ModifyFuturesMarketSettingsParams
* @description Outlines the parameters for modifying futures market settings, including the markets and position side.
* @see https://docs.coinex.com/api/v2/account/settings/http/modify-futures-market-settings
*/
interface ModifyFuturesMarketSettingsParams {
/**
* @property {string[]} markets - List of markets.
* @example ["BTCUSDT", "ETHUSDT"]
*/
markets: string[];
/**
* @property {PositionSide} position_side - Position side.
* @example PositionSide.LONG
*/
position_side: PositionSide;
}
/**
* @interface CreateSubAccountParams
* @description Parameters for creating a sub-account.
*/
interface CreateSubAccountParams {
/**
* @property {string} sub_user_name - Sub-account username.
* @description 3-26 characters, can only contain numbers, letters and English symbols "-". Cannot be the same as an existing sub-account name.
* @example "sub2"
*/
sub_user_name: string;
/**
* @property {Permission[]} [permissions] - Sub-user permissions. The sub-account created by default has full permissions.
* @example [Permission.AMM, Permission.MARGIN]
*/
permissions?: Permission[];
/**
* @property {string} [remark] - Sub-account note. The length of the note cannot exceed 50 characters.
* @example "spot market maker"
*/
remark?: string;
}
/**
* @interface GetSubAccountListParams
* @description Parameters for getting the sub-account list.
*/
interface GetSubAccountListParams {
/**
* @property {string} [sub_user_name] - Sub-account username.
*/
sub_user_name?: string;
/**
* @property {boolean} [is_frozen] - Frozen or not. Default is false.
*/
is_frozen?: boolean;
/**
* @property {number} [page] - Number of pagination. Default is 1.
*/
page?: number;
/**
* @property {number} [limit] - Number in each page. Default is 10.
*/
limit?: number;
}
/**
* @interface SubAccountInfo
* @description Information about a single sub-account.
*/
interface SubAccountInfo {
/**
* @property {string} sub_user_name - Sub-account username.
* @example "sub2"
*/
sub_user_name: string;
/**
* @property {boolean} is_frozen - Whether the sub-account is frozen or not.
* @example true
*/
is_frozen: boolean;
/**
* @property {boolean} is_authorized - Whether it is authorized or not.
* @example false
*/
is_authorized: boolean;
/**
* @property {Permission[]} permissions - Sub-account permission list.
* @example [Permission.FUTURES, Permission.API]
*/
permissions: Permission[];
/**
* @property {string} balance_usd - Market value of sub-account balance.
* @example "3564.23"
*/
balance_usd: string;
}
/**
* @interface Pagination
* @description Pagination information for list responses.
*/
interface Pagination {
/**
* @property {number} total - Total number of items.
* @example 1
*/
total: number;
/**
* @property {boolean} has_next - Whether there is a next page.
* @example false
*/
has_next: boolean;
}
/**
* @interface GetSubAccountListResponse
* @description The response for the getSubAccountList method.
*/
interface GetSubAccountListResponse {
data: SubAccountInfo[];
pagination: Pagination;
}
/**
* @interface DisableSubAccountParams
* @description Parameters for disabling a sub-account.
*/
interface DisableSubAccountParams {
/**
* @property {string} sub_user_name - Sub-account username.
* @example "sub2"
*/
sub_user_name: string;
}
/**
* @interface EnableSubAccountParams
* @description Parameters for enabling a sub-account.
*/
interface EnableSubAccountParams {
/**
* @property {string} sub_user_name - Sub-account username.
* @example "sub2"
*/
sub_user_name: string;
}
/**
* @interface CreateSubAccountApiKeyParams
* @description Parameters for creating a sub-account API key.
*/
interface CreateSubAccountApiKeyParams {
/**
* @property {string} sub_user_name - Sub-account username.
*/
sub_user_name: string;
/**
* @property {string[]} ip_whitelist - The IP whitelist bound to API KEY. Up to 50 IPs can be bound.
*/
ip_whitelist: string[];
/**
* @property {boolean} trade_enabled - Whether the API KEY has trading permissions.
*/
trade_enabled: boolean;
/**
* @property {string} [remark] - API KEY note. The length of the note cannot exceed 50 characters.
*/
remark?: string;
}
/**
* @interface SubAccountApiKey
* @description Information about a sub-account API key.
*/
interface SubAccountApiKey {
/**
* @property {number} api_id - Unique ID for API KEY.
*/
api_id: number;
/**
* @property {number} created_at - Data creation time.
*/
created_at: number;
/**
* @property {string} access_id - access_id of the key pair.
*/
access_id: string;
/**
* @property {string} secret_key - secret_key of the key pair.
*/
secret_key: string;
/**
* @property {string[]} ip_whitelist - The IP whitelist bound to API KEY.
*/
ip_whitelist: string[];
/**
* @property {boolean} trade_enabled - Whether the API KEY has trading permissions.
*/
trade_enabled: boolean;
/**
* @property {boolean} withdraw_enabled - Whether the API KEY has withdrawal permissions.
*/
withdraw_enabled: boolean;
/**
* @property {boolean} is_expired - Whether the API KEY has expired.
*/
is_expired: boolean;
/**
* @property {number} expires_at - Expiration time of API KEY. 0 means the API KEY is permanently valid.
*/
expires_at: number;
/**
* @property {string} remark - API KEY note.
*/
remark: string;
}
/**
* @interface GetSubAccountApiKeyDetailParams
* @description Parameters for getting sub-account API key detail.
*/
interface GetSubAccountApiKeyDetailParams {
/**
* @property {number} api_id - Unique ID for API KEY.
*/
api_id: number;
}
/**
* @interface GetSubAccountInfoResponse
* @description The response for the getSubAccountInfo method.
* @see https://docs.coinex.com/api/v2/account/subs/http/get-sub-info
*/
interface GetSubAccountInfoResponse {
/**
* @property {UserType} user_type - User Types.
* @example UserType.SUB_ACCOUNT
*/
user_type: UserType;
/**
* @property {string | null} sub_user_name - Sub-account username. If it is an ordinary user, this value is null.
* @example "sub1"
*/
sub_user_name: string | null;
}
/**
* @interface SubAccountTransferParams
* @description Parameters for transferring assets between sub-accounts.
* @see https://docs.coinex.com/api/v2/account/subs/http/sub-transfer
*/
interface SubAccountTransferParams {
/**
* @property {string} from_sub_user_name - The username of the sub-account to transfer from.
*/
from_sub_user_name: string;
/**
* @property {string} to_sub_user_name - The username of the sub-account to transfer to.
*/
to_sub_user_name: string;
/**
* @property {string} ccy - The currency to transfer.
*/
ccy: string;
/**
* @property {string} amount - The amount to transfer.
*/
amount: string;
}
/**
* @interface GetSubAccountTransferHistoryParams
* @description Parameters for getting the transfer history of a sub-account.
* @see https://docs.coinex.com/api/v2/account/subs/http/list-sub-transfer-history
*/
interface GetSubAccountTransferHistoryParams {
/**
* @property {string} sub_user_name - The username of the sub-account.
*/
sub_user_name: string;
/**
* @property {TransferDirection} [direction] - The direction of the transfer.
*/
direction?: TransferDirection;
/**
* @property {string} [ccy] - The currency of the transfer.
*/
ccy?: string;
/**
* @property {number} [start_time] - The start time of the query range.
*/
start_time?: number;
/**
* @property {number} [end_time] - The end time of the query range.
*/
end_time?: number;
/**
* @property {number} [page] - The page number.
*/
page?: number;
/**
* @property {number} [limit] - The number of records to return.
*/
limit?: number;
}
/**
* @interface SubAccountTransferHistory
* @description Information about a sub-account transfer.
*/
interface SubAccountTransferHistory {
/**
* @property {string} from_sub_user_name - The username of the sub-account that sent the transfer.
*/
from_sub_user_name: string;
/**
* @property {string} to_sub_user_name - The username of the sub-account that received the transfer.
*/
to_sub_user_name: string;
/**
* @property {string} ccy - The currency of the transfer.
*/
ccy: string;
/**
* @property {string} amount - The amount of the transfer.
*/
amount: string;
/**
* @property {number} created_at - The time the transfer was created.
*/
created_at: number;
}
/**
* @interface GetSubAccountTransferHistoryResponse
* @description The response for the getSubAccountTransferHistory method.
*/
interface GetSubAccountTransferHistoryResponse {
data: SubAccountTransferHistory[];
pagination: Pagination;
}
/**
* @interface GetSubAccountApiKeyListParams
* @description Parameters for getting the API key list of a sub-account.
* @see https://docs.coinex.com/api/v2/account/subs/http/list-sub-api
*/
interface GetSubAccountApiKeyListParams {
/**
* @property {string} sub_user_name - The username of the sub-account.
*/
sub_user_name: string;
}
/**
* @interface GetSubAccountApiKeyListResponse
* @description The response for the getSubAccountApiKeyList method.
*/
interface GetSubAccountApiKeyListResponse {
data: SubAccountApiKey[];
}
/**
* @interface GetSubAccountSpotBalanceParams
* @description Parameters for getting the spot balance of a sub-account.
* @see https://docs.coinex.com/api/v2/account/subs/http/get-sub-spot-balance
*/
interface GetSubAccountSpotBalanceParams {
/**
* @property {string} sub_user_name - The username of the sub-account.
*/
sub_user_name: string;
/**
* @property {string} [ccy] - The currency to query.
*/
ccy?: string;
}
/**
* @interface SubAccountSpotBalance
* @description Information about a sub-account spot balance.
*/
interface SubAccountSpotBalance {
/**
* @property {string} ccy - The currency.
*/
ccy: string;
/**
* @property {string} available - The available balance.
*/
available: string;
/**
* @property {string} frozen - The frozen balance.
*/
frozen: string;
}
/**
* @type GetSubAccountSpotBalanceResponse
* @description Represents the response for a sub-account's spot balance, which is an array of balance details per currency.
*/
type GetSubAccountSpotBalanceResponse = SubAccountSpotBalance[];
/**
* @interface EditSubAccountApiKeyParams
* @description Parameters for editing a sub-account API key.
* @see https://docs.coinex.com/api/v2/account/subs/http/edit-sub-api
*/
interface EditSubAccountApiKeyParams {
/**
* @property {string} sub_user_name - The username of the sub-account.
*/
sub_user_name: string;
/**
* @property {number} api_id - The ID of the API key to edit.
*/
api_id: number;
/**
* @property {string[]} [ip_whitelist] - The new IP whitelist.
*/
ip_whitelist?: string[];
/**
* @property {boolean} [trade_enabled] - Whether to enable trading.
*/
trade_enabled?: boolean;
/**
* @property {string} [remark] - The new remark.
*/
remark?: string;
}
/**
* @interface DeleteSubAccountApiKeyParams
* @description Parameters for deleting a sub-account API key.
* @see https://docs.coinex.com/api/v2/account/subs/http/delete-sub-api
*/
interface DeleteSubAccountApiKeyParams {
/**
* @property {string} sub_user_name - The username of the sub-account.
*/
sub_user_name: string;
/**
* @property {number} api_id - The ID of the API key to delete.
*/
api_id: number;
}
/**
* @interface GetAccountInfoResponse
* @description Contains the response data for a user account information request.
* @see https://docs.coinex.com/api/v2/account/info/http/get-account-info
*/
interface GetAccountInfoResponse {
/**
* @property {string} user_id - User ID.
*/
user_id: string;
}
/**
* @interface AddAMMLiquidityParams
* @description Parameters for adding AMM liquidity
* @see https://docs.coinex.com/api/v2/assets/amm/http/add-liquidtiy
*/
interface AddAMMLiquidityParams {
/**
* @property {string} market - Market name
* @example "CETUSDT"
*/
market: string;
/**
* @property {string} amount - The amount of asset to add
* @example "100"
*/
amount: string;
}
/**
* @interface GetAMMIncomeHistoryParams
* @description Parameters for getting AMM income history
* @see https://docs.coinex.com/api/v2/assets/amm/http/list-income-history
*/
interface GetAMMIncomeHistoryParams {
/**
* @property {string} [market] - Market name
* @description If not passed, all markets will be returned.
* @example "CETUSDT"
*/
market?: string;
/**
* @property {number} [page] - Page number
* @default 1
*/
page?: number;
/**
* @property {number} [limit] - Number of records per page
* @default 100
*/
limit?: number;
}
/**
* @interface AMMIncomeHistory
* @description AMM income history
*/
interface AMMIncomeHistory {
/**
* @property {string} market - Market name
* @example "CETUSDT"
*/
market: string;
/**
* @property {string} income - Income
* @example "0.1"
*/
income: string;
/**
* @property {number} created_at - Creation time
* @example 1614837902000
*/
created_at: number;
}
/**
* @interface GetAMMIncomeHistoryResponse
* @description Response for getting AMM income history
*/
interface GetAMMIncomeHistoryResponse {
data: AMMIncomeHistory[];
pagination: Pagination;
}
/**
* @interface GetAMMLiquidityPoolParams
* @description Parameters for getting AMM liquidity pool
* @see https://docs.coinex.com/api/v2/assets/amm/http/list-liquidity-pool
*/
interface GetAMMLiquidityPoolParams {
/**
* @property {string} market - Market name list, separating multiple market names with "," and the maximum limit is 10 markets.
* @example "CETUSDT,BTCUSDT"
*/
market: string;
}
/**
* @interface AMMLiquidityPool
* @description AMM liquidity pool
*/
interface AMMLiquidityPool {
/**
* @property {string} market - Market name
* @example "CETUSDT"
*/
market: string;
/**
* @property {string} total_liquidity - Total liquidity
* @example "1000000"
*/
total_liquidity: string;
/**
* @property {string} apy - APY
* @example "0.05"
*/
apy: string;
}
/**
* @interface GetAMMLiquidityPoolResponse
* @description Response for getting AMM liquidity pool
*/
type GetAMMLiquidityPoolResponse = AMMLiquidityPool[];
/**
* @interface RemoveAMMLiquidityParams
* @description Parameters for removing AMM liquidity
* @see https://docs.coinex.com/api/v2/assets/amm/http/remove-liquidtiy
*/
interface RemoveAMMLiquidityParams {
/**
* @property {string} market - Market name
* @example "CETUSDT"
*/
market: string;
/**
* @property {string} amount - The amount of asset to remove
* @example "100"
*/
amount: string;
}
/**
* @interface AMMLiquidityInfo
* @description AMM liquidity information.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-amm-liquidity
*/
interface AMMLiquidityInfo {
/**
* @property {string} market - Market name.
* @example "CETUSDT"
*/
market: string;
/**
* @property {string} asset_amount - The amount of assets in the AMM account.
* @example "1000"
*/
asset_amount: string;
/**
* @property {string} share_amount - The amount of shares in the AMM account.
* @example "1000"
*/
share_amount: string;
}
/**
* @interface GetAMMLiquidityParams
* @description Parameters for getting AMM liquidity.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-amm-liquidity
*/
interface GetAMMLiquidityParams {
/**
* @property {number} [account_id] - Account ID.
* @description The default is the main account.
*/
account_id?: number;
}
/**
* @interface GetAMMLiquidityResponse
* @description Response for getting AMM liquidity.
*/
type GetAMMLiquidityResponse = AMMLiquidityInfo[];
/**
* @interface CreditBalance
* @description Credit account balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-credit-balance
*/
interface CreditBalance {
/**
* @property {string} ccy - Currency name.
* @example "USDT"
*/
ccy: string;
/**
* @property {string} available - Available balance.
* @example "1000"
*/
available: string;
/**
* @property {string} frozen - Frozen balance.
* @example "0"
*/
frozen: string;
/**
* @property {number} updated_at - Update time.
* @example 1614837902000
*/
updated_at: number;
}
/**
* @interface GetCreditBalanceParams
* @description Parameters for getting credit balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-credit-balance
*/
interface GetCreditBalanceParams {
/**
* @property {string} [ccy] - Currency name.
* @description If not passed, all currencies will be returned.
*/
ccy?: string;
}
/**
* @interface GetCreditBalanceResponse
* @description Response for getting credit balance.
*/
type GetCreditBalanceResponse = CreditBalance[];
/**
* @interface CreditInfo
* @description Credit account information.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-credit-info
*/
interface CreditInfo {
/**
* @property {string} ccy - Currency name.
* @example "USDT"
*/
ccy: string;
/**
* @property {string} total_balance - Total balance.
* @example "1000"
*/
total_balance: string;
/**
* @property {string} available_balance - Available balance.
* @example "1000"
*/
available_balance: string;
/**
* @property {string} frozen_balance - Frozen balance.
* @example "0"
*/
frozen_balance: string;
/**
* @property {string} loan_balance - Loan balance.
* @example "0"
*/
loan_balance: string;
/**
* @property {string} interest - Interest.
* @example "0"
*/
interest: string;
/**
* @property {number} updated_at - Update time.
* @example 1614837902000
*/
updated_at: number;
}
/**
* @interface GetCreditInfoParams
* @description Parameters for getting credit info.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-credit-info
*/
interface GetCreditInfoParams {
/**
* @property {string} [ccy] - Currency name.
* @description If not passed, all currencies will be returned.
*/
ccy?: string;
}
/**
* @interface GetCreditInfoResponse
* @description Response for getting credit info.
*/
type GetCreditInfoResponse = CreditInfo[];
/**
* @interface FinancialBalance
* @description Financial account balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-financial-balance
*/
interface FinancialBalance {
/**
* @property {string} ccy - Currency name.
* @example "USDT"
*/
ccy: string;
/**
* @property {string} available - Available balance.
* @example "1000"
*/
available: string;
/**
* @property {string} frozen - Frozen balance.
* @example "0"
*/
frozen: string;
/**
* @property {number} updated_at - Update time.
* @example 1614837902000
*/
updated_at: number;
}
/**
* @interface GetFinancialBalanceParams
* @description Parameters for getting financial balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-financial-balance
*/
interface GetFinancialBalanceParams {
/**
* @property {string} [ccy] - Currency name.
* @description If not passed, all currencies will be returned.
*/
ccy?: string;
}
/**
* @interface GetFinancialBalanceResponse
* @description Response for getting financial balance.
*/
type GetFinancialBalanceResponse = FinancialBalance[];
/**
* @interface FuturesBalance
* @description Futures account balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-futures-balance
*/
interface FuturesBalance {
/**
* @property {string} ccy - Currency name.
* @example "USDT"
*/
ccy: string;
/**
* @property {string} available - Available balance.
* @example "1000"
*/
available: string;
/**
* @property {string} frozen - Frozen balance.
* @example "0"
*/
frozen: string;
/**
* @property {string} margin - Position margin.
* @example "0"
*/
margin: string;
/**
* @property {string} transferable - Transferable balance.
* @example "1000"
*/
transferable: string;
/**
* @property {string} unrealized_pnl - Unrealized PNL.
* @example "0"
*/
unrealized_pnl: string;
/**
* @property {string} equity - Equity.
* @example "1000"
*/
equity: string;
/**
* @property {number} updated_at - Update time.
* @example 1614837902000
*/
updated_at: number;
}
/**
* @interface GetFuturesBalanceParams
* @description Parameters for getting futures balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-futures-balance
*/
interface GetFuturesBalanceParams {
/**
* @property {string} [ccy] - Currency name.
* @description If not passed, all currencies will be returned.
*/
ccy?: string;
}
/**
* @interface GetFuturesBalanceResponse
* @description Response for getting futures balance.
*/
type GetFuturesBalanceResponse = FuturesBalance[];
/**
* @interface MarginBalanceDetail
* @description Margin balance detail.
*/
interface MarginBalanceDetail {
/**
* @property {string} ccy - Currency name.
* @example "USDT"
*/
ccy: string;
/**
* @property {string} available - Available balance.
* @example "1000"
*/
available: string;
/**
* @property {string} frozen - Frozen balance.
* @example "0"
*/
frozen: string;
/**
* @property {number} updated_at - Update time.
* @example 1614837902000
*/
updated_at: number;
}
/**
* @interface MarginBalance
* @description Margin account balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-marigin-balance
*/
interface MarginBalance {
/**
* @property {string} market - Market name.
* @example "BTCUSDT"
*/
market: string;
/**
* @property {MarginBalanceDetail[]} margin_balance - Margin balance details.
*/
margin_balance: MarginBalanceDetail[];
}
/**
* @interface GetMarginBalanceParams
* @description Parameters for getting margin balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-marigin-balance
*/
interface GetMarginBalanceParams {
/**
* @property {string} market - Market name.
* @example "BTCUSDT"
*/
market: string;
/**
* @property {string} [ccy] - Currency name.
* @description If not passed, all currencies will be returned.
*/
ccy?: string;
}
/**
* @interface GetMarginBalanceResponse
* @description Response for getting margin balance.
*/
type GetMarginBalanceResponse = MarginBalance[];
/**
* @interface SpotBalance
* @description Spot account balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-spot-balance
*/
interface SpotBalance {
/**
* @property {string} ccy - Currency name.
* @example "USDT"
*/
ccy: string;
/**
* @property {string} available - Available balance.
* @example "1000"
*/
available: string;
/**
* @property {string} frozen - Frozen balance.
* @example "0"
*/
frozen: string;
/**
* @property {number} updated_at - Update time.
* @example 1614837902000
*/
updated_at: number;
}
/**
* @interface GetSpotBalanceParams
* @description Parameters for getting spot balance.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-spot-balance
*/
interface GetSpotBalanceParams {
/**
* @property {string} [ccy] - Currency name.
* @description If not passed, all currencies will be returned.
*/
ccy?: string;
}
/**
* @interface GetSpotBalanceResponse
* @description Response for getting spot balance.
*/
type GetSpotBalanceResponse = SpotBalance[];
/**
* @interface SpotTransaction
* @description Spot transaction details.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-spot-transcation-history
*/
interface SpotTransaction {
/**
* @property {number} transaction_id - Transaction ID.
* @example 123456789
*/
transaction_id: number;
/**
* @property {string} ccy - Currency name.
* @example "USDT"
*/
ccy: string;
/**
* @property {string} amount - Transaction amount.
* @example "100"
*/
amount: string;
/**
* @property {string} balance - Balance after transaction.
* @example "1100"
*/
balance: string;
/**
* @property {string} transaction_type - Transaction type.
* @example "deposit"
*/
transaction_type: string;
/**
* @property {number} created_at - Creation time.
* @example 1614837902000
*/
created_at: number;
}
/**
* @interface GetSpotTransactionHistoryParams
* @description Parameters for getting spot transaction history.
* @see https://docs.coinex.com/api/v2/assets/balance/http/get-spot-transcation-history
*/
interface GetSpotTransactionHistoryParams {
/**
* @property {string} [ccy] - Currency name.
* @description If not passed, all currencies will be returned.
*/
ccy?: string;
/**
* @property {string} [transaction_type] - Transaction type.
*/
transaction_type?: string;
/**
* @property {number} [start_time] - Start time.
*/
start_time?: number;
/**
* @property {number} [end_time] - End time.
*/
end_time?: number;
/**
* @property {number} [page] - Page number.
*/
page?: number;
/**
* @property {number} [limit] - Number of records per page.
*/
limit?: number;
}
/**
* @interface GetSpotTransactionHistoryResponse
* @description Response for getting spot transaction history.
*/
interface GetSpotTransactionHistoryResponse {
data: SpotTransaction[];
pagination: Pagination;
}
/**
* @interface GetMarginBorrowHistoryParams
* @description Parameters for getting margin borrow history
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
*/
interface GetMarginBorrowHistoryParams {
/**
* @property {string} [market] - Market name
* @description If not passed, all markets will be returned.
* @example "BTCUSDT"
*/
market?: string;
/**
* @property {number} [page] - Page number
* @default 1
*/
page?: number;
/**
* @property {number} [limit] - Number of records per page
* @default 100
*/
limit?: number;
}
/**
* @interface MarginBorrowHistory
* @description Margin borrow history
*/
interface MarginBorrowHistory {
/**
* @property {string} market - Market name
* @example "BTCUSDT"
*/
market: string;
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} amount - Borrow amount
* @example "100"
*/
amount: string;
/**
* @property {number} created_at - Creation time
* @example 1614837902000
*/
created_at: number;
}
/**
* @interface GetMarginBorrowHistoryResponse
* @description Response for getting margin borrow history
*/
interface GetMarginBorrowHistoryResponse {
data: MarginBorrowHistory[];
pagination: Pagination;
}
/**
* @interface GetMarginInterestLimitParams
* @description Parameters for getting margin interest limit
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
*/
interface GetMarginInterestLimitParams {
/**
* @property {string} market - Market name
* @example "BTCUSDT"
*/
market: string;
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
}
/**
* @interface MarginInterestLimit
* @description Margin interest limit
*/
interface MarginInterestLimit {
/**
* @property {string} min_amount - Minimum borrow amount
* @example "10"
*/
min_amount: string;
/**
* @property {string} max_amount - Maximum borrow amount
* @example "10000"
*/
max_amount: string;
/**
* @property {string} daily_interest_rate - Daily interest rate
* @example "0.001"
*/
daily_interest_rate: string;
}
/**
* @interface GetMarginInterestLimitResponse
* @description Response for getting margin interest limit
*/
type GetMarginInterestLimitResponse = MarginInterestLimit;
/**
* @interface MarginBorrowParams
* @description Parameters for margin borrow
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
*/
interface MarginBorrowParams {
/**
* @property {string} market - Market name
* @example "BTCUSDT"
*/
market: string;
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} amount - Borrow amount
* @example "100"
*/
amount: string;
}
/**
* @interface MarginRepayParams
* @description Parameters for margin repay
* @see https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
*/
interface MarginRepayParams {
/**
* @property {string} market - Market name
* @example "BTCUSDT"
*/
market: string;
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} amount - Repay amount
* @example "100"
*/
amount: string;
}
/**
* @interface CancelWithdrawalParams
* @description Parameters for cancelling a withdrawal
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/cancel-withdrawal
*/
interface CancelWithdrawalParams {
/**
* @property {number} withdrawal_id - Withdrawal ID
* @example 12345
*/
withdrawal_id: number;
}
/**
* @interface GetDepositAddressParams
* @description Parameters for getting a deposit address
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-address
*/
interface GetDepositAddressParams {
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} network - Public chain name
* @example "TRC20"
*/
network: string;
}
/**
* @interface DepositAddress
* @description Deposit address
*/
interface DepositAddress {
/**
* @property {string} address - Deposit address
* @example "0x1234567890123456789012345678901234567890"
*/
address: string;
/**
* @property {string} [memo] - Memo/Tag
* @example "12345"
*/
memo?: string;
}
/**
* @interface GetDepositAddressResponse
* @description Response for getting a deposit address
*/
type GetDepositAddressResponse = DepositAddress;
/**
* @interface GetDepositWithdrawalConfigParams
* @description Parameters for getting deposit and withdrawal configuration
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config
*/
interface GetDepositWithdrawalConfigParams {
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
}
/**
* @interface DepositWithdrawalConfig
* @description Deposit and withdrawal configuration
*/
interface DepositWithdrawalConfig {
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} min_deposit_amount - Minimum deposit amount
* @example "10"
*/
min_deposit_amount: string;
/**
* @property {string} min_withdrawal_amount - Minimum withdrawal amount
* @example "10"
*/
min_withdrawal_amount: string;
/**
* @property {boolean} is_deposit_available - Whether deposit is available
* @example true
*/
is_deposit_available: boolean;
/**
* @property {boolean} is_withdrawal_available - Whether withdrawal is available
* @example true
*/
is_withdrawal_available: boolean;
}
/**
* @interface GetDepositWithdrawalConfigResponse
* @description Response for getting deposit and withdrawal configuration
*/
type GetDepositWithdrawalConfigResponse = DepositWithdrawalConfig[];
/**
* @interface GetAllDepositWithdrawalConfigResponse
* @description Response for getting all deposit and withdrawal configuration
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-all-deposit-withdrawal-config
*/
type GetAllDepositWithdrawalConfigResponse = DepositWithdrawalConfig[];
/**
* @interface GetAssetInfoParams
* @description Parameters for getting asset information
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-assets-info
*/
interface GetAssetInfoParams {
/**
* @property {string} [ccy] - Currency name
* @description If not passed, all currencies will be returned.
* @example "USDT"
*/
ccy?: string;
}
/**
* @interface AssetInfo
* @description Asset information
*/
interface AssetInfo {
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} asset_name - Asset name
* @example "TetherUS"
*/
asset_name: string;
/**
* @property {string} description - Asset description
* @example "A stablecoin pegged to the US dollar."
*/
description: string;
/**
* @property {string} logo - Asset logo URL
* @example "https://s.coinex.com/static/dist/images/coins/USDT.png"
*/
logo: string;
}
/**
* @interface GetAssetInfoResponse
* @description Response for getting asset information
*/
type GetAssetInfoResponse = AssetInfo[];
/**
* @interface GetDepositHistoryParams
* @description Parameters for getting deposit history
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
*/
interface GetDepositHistoryParams {
/**
* @property {string} [ccy] - Currency name
* @description If not passed, all currencies will be returned.
* @example "USDT"
*/
ccy?: string;
/**
* @property {string} [tx_id] - Transaction ID
* @example "0x1234567890123456789012345678901234567890"
*/
tx_id?: string;
/**
* @property {string} [status] - Deposit status
* @example "success"
*/
status?: string;
/**
* @property {number} [start_time] - Start time
*/
start_time?: number;
/**
* @property {number} [end_time] - End time
*/
end_time?: number;
/**
* @property {number} [page] - Page number
* @default 1
*/
page?: number;
/**
* @property {number} [limit] - Number of records per page
* @default 100
*/
limit?: number;
}
/**
* @interface DepositHistory
* @description Deposit history
*/
interface DepositHistory {
/**
* @property {number} deposit_id - Deposit ID
* @example 12345
*/
deposit_id: number;
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} network - Public chain name
* @example "TRC20"
*/
network: string;
/**
* @property {string} amount - Deposit amount
* @example "100"
*/
amount: string;
/**
* @property {string} address - Deposit address
* @example "0x1234567890123456789012345678901234567890"
*/
address: string;
/**
* @property {string} memo - Memo/Tag
* @example "12345"
*/
memo: string;
/**
* @property {string} tx_id - Transaction ID
* @example "0x1234567890123456789012345678901234567890"
*/
tx_id: string;
/**
* @property {string} status - Deposit status
* @example "success"
*/
status: string;
/**
* @property {number} created_at - Creation time
* @example 1614837902000
*/
created_at: number;
}
/**
* @interface GetDepositHistoryResponse
* @description Response for getting deposit history
*/
interface GetDepositHistoryResponse {
data: DepositHistory[];
pagination: Pagination;
}
/**
* @interface GetWithdrawalHistoryParams
* @description Parameters for getting withdrawal history
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
*/
interface GetWithdrawalHistoryParams {
/**
* @property {string} [ccy] - Currency name
* @description If not passed, all currencies will be returned.
* @example "USDT"
*/
ccy?: string;
/**
* @property {string} [status] - Withdrawal status
* @example "success"
*/
status?: string;
/**
* @property {number} [start_time] - Start time
*/
start_time?: number;
/**
* @property {number} [end_time] - End time
*/
end_time?: number;
/**
* @property {number} [page] - Page number
* @default 1
*/
page?: number;
/**
* @property {number} [limit] - Number of records per page
* @default 100
*/
limit?: number;
}
/**
* @interface WithdrawalHistory
* @description Withdrawal history
*/
interface WithdrawalHistory {
/**
* @property {number} withdrawal_id - Withdrawal ID
* @example 12345
*/
withdrawal_id: number;
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} network - Public chain name
* @example "TRC20"
*/
network: string;
/**
* @property {string} amount - Withdrawal amount
* @example "100"
*/
amount: string;
/**
* @property {string} fee - Withdrawal fee
* @example "1"
*/
fee: string;
/**
* @property {string} address - Withdrawal address
* @example "0x1234567890123456789012345678901234567890"
*/
address: string;
/**
* @property {string} memo - Memo/Tag
* @example "12345"
*/
memo: string;
/**
* @property {string} tx_id - Transaction ID
* @example "0x1234567890123456789012345678901234567890"
*/
tx_id: string;
/**
* @property {string} status - Withdrawal status
* @example "success"
*/
status: string;
/**
* @property {number} created_at - Creation time
* @example 1614837902000
*/
created_at: number;
}
/**
* @interface GetWithdrawalHistoryResponse
* @description Response for getting withdrawal history
*/
interface GetWithdrawalHistoryResponse {
data: WithdrawalHistory[];
pagination: Pagination;
}
/**
* @interface UpdateDepositAddressParams
* @description Parameters for updating a deposit address
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/update-deposit-address
*/
interface UpdateDepositAddressParams {
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} network - Public chain name
* @example "TRC20"
*/
network: string;
}
/**
* @interface WithdrawalParams
* @description Parameters for making a withdrawal
* @see https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal
*/
interface WithdrawalParams {
/**
* @property {string} ccy - Currency name
* @example "USDT"
*/
ccy: string;
/**
* @property {string} network - Public chain name
* @example "TRC20"
*/
network: string;
/**
* @property {string} address - Withdrawal address
* @example "0x1234567890123456789012345678901234567890"
*/
address: string;
/**
* @property {string} amount - Withdrawal amount
* @example "100"
*/
amount: string;
/**
* @property {string} [memo] - Memo/Tag
* @example "12345"
*/
memo?: string;
}
/**
* @interface GetAssetTransferHistoryParams
* @description Parameters for getting asset transfer history
* @see https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
*/
interface GetAssetTransferHistoryParams {
/**
* @property {string} [ccy] - Currency name
* @description If not passed, all currencies will be returned.
* @example "USDT"
*/
ccy?: string;
/**
* @property {string} [status] - Transfer status
* @example "success"
*/
status?: string;
/**
* @property {number} [start_time] - Start time
*/
start_time?: number;
/**
* @property {number} [end_time] - End time
*/
end_time?: number;
/**
* @property {number} [page] - Page number
* @default 1
*/
page?: number;
/**
* @property {number} [limit] - Number of records per page
* @default 100
*/
limit?: number;
}
/**
* @interface AssetTransferHistory
* @description Asset transfer history
*/
interface AssetTransferHistory {
/**
* @property {number} transfer_id - Transfer ID
* @example 12345
*/
transfer_id: number;
/**
* @property {string} from_account_type - From account type
* @example "spot"
*/
from_account_type: string;
/**
* @property {string} to_account_type - To account type
* @example "margin"
*/
to_account_type: string;
/**
* @property {string} ccy - Currency