Perpetual Trading API
Unified Interface Domain Name:
Test environment:
REST:https://test-futures-api.ln.exchange
WebSocket:wss://test-futures-ws.ln.exchange/kline-api/ws
Introduction
Obtain API Key
Many interfaces require API Key to access. Please create a user on the site first. Then call the interface: import nostr address and obtain API Key
the API Key is displayed only once for security purposes. Please keep your API key/secret
never tell anyone your API key/secret
Signature
First sort the parameters in ascending dictionary order of their parameter names
traverses the sorted dictionary and splices all parameters together in the "keyvalue" format.
Plus your private key.
Using MD5 to Treat Signature String for Signing
REST Request Validation
All REST private request headers must contain the following
Request Header Parameters
apikey
String
Yes
API key
time
String
Yes
13-digit timestamp
sign
String
Yes
Signature
API section-OPEN:
Access to public information
URL:
/napi/common/public_info
Method:
GET
Login required: N
Request Parameters
Request Example
Return parameter
nostrAddress
String
NostrAddress
wsUrl
String
WebSocket Connection Address
currentTimeMillis
String
Current timestamp
marginCoinList
List
List of Margin Currencies
coinList
List
Currency List
coin
String
currency Name
precious
String
currency precision
contractList
List
contract List
id
String
Contract ID
contractName
String
contract Name
symbol
String
transaction Pair Symbol
closeMakerFee
String
Maker fees
closeTakerFee
String
Taker fee
base
String
base Currency
quote
String
pricing Currency
sort
String
sort Value
robot
String
robot Address
coinResultVo
Object
coin pair information
symbolPricePrecision
String
trading Pair Price Precision
minOrderVolume
String
minimum Order Quantity
minOrderMoney
String
minimum Order Amount
maxMarketVolume
String
maximum Market Order Volume
maxMarketMoney
String
Maximum Market Order Amount
maxLimitVolume
String
maximum Limit Order Quantity
maxLimitMoney
String
maximum Limit Order Amount
marginCoinPrecision
String
currency precision
depth
List
coin Pair Depth Precision Array
Return Results
Get list of outstanding orders
URL:
/open/v1/openOrders
Method:
POST
Login required:Y
Request Parameters
contractName
String
yes
Contract Name
Request Example
Return parameters
orderId
String
Order id
contractName
String
contract Name
price
String
order Price
origQty
String
order quantity
executedQty
String
number of transactions
avgPrice
String
average Transaction Price
status
String
order Status (Order Status: 0 init,1 new,2 filled,3 part_filled,4 canceled,5 pending_cancel,6 expired)
type
Strin
order Type (1 limit; 2 market;)
timeInForce
String
order Type (1 limit; 2 market;)
side
String
BUY and SELL direction (BUY BUY, SELL SELL)
transactTime
String
creation time
Return Results
Get Transaction Details
URL:
/open/v1/myTrades
Method:
POST
Login required: Y
Request Parameters
contractName
String
Yes
Contract Name
limit
String
no
get the number of bars: the default 100 maximum 1000
fromId
String
no
query start ID (this ID is not included)
Request Example
Return parameters
price
String
Transaction Price
volume
String
number of transactions
amount
String
transaction amount
contractName
String
contract Name
time
String
transaction time
side
Strin
BUY and SELL direction (BUY BUY, SELL SELL)
fee
String
fees
bidId
String
pay id
askId
String
selling order id
bidUserId
String
pay user ID
askUserId
String
sell order user ID
isBuyer
String
buyer (true buyer, false seller)
tradeId
String
the ID of the transaction details.
isMaker
String
Whether the order is pending (ture order taker, false order taker)
Return Results
Batch Order & Batch Withdrawal
URL:
/open/v1/batchOrders
Method:
POST
Login required: Y
Request Parameters
contractName
String
Yes
Contract Name
orders
List
yes
order List
side
String
yes
BUY and SELL direction (BUY BUY, SELL SELL)
open
String
yes
OPEN position direction (OPEN position, CLOSE position)
type
String
yes
order type (1 limit, 2 market,3 IOC,4 FOK,5 POST_ONLY)
volume
String
yes
order quantity
price
String
no
order Price
clientOrderId
String
no
client order ID
orderIds
List
yes
List of cancellation ID
Request Example (Bulk Order)
Request Example (Bulk Withdrawal)
Return parameters
ids
List
Successful order ID list
cancelIds
List
list of order withdrawal ID when placing an order failed
Return Results
Get depth list
URL:
/open/v1/depth
Method:
POST
Login required:N
Request Parameters
contractName
String
Yes
contract Name
limit
String
no
get the number of bars: the default 100 maximum 100
Request Example
Return parameters
asks
String
Sale order depth
bids
String
paying Depth
time
String
latest timestamp
Return Results
Batch withdrawal of all orders
URL:
/open/v1/cancelAll
Method:
POST
Login required: Y
Request Parameters
contractName
String
Yes
Contract Name
Request Example
Return parameters
Return Results
View account balance
URL:
/open/v1/account
Method:
POST
Login required: Y
Request Parameters
Request Example
Return parameters
data
List
Asset List
accountNormal
String
available
accountLock
String
freeze
marginCoin
String
currency of margin
partPositionNormal
String
position-by-position margin balance
totalPositionNormal
String
initial margin occupied by a full position
achievedAmount
String
realized profit and loss
unrealizedAmount
String
unrealized profit and loss
totalMarginRate
String
Full position margin rate
totalEquity
String
full Position Equity
partEquity
String
position-by-position equity
totalCost
String
cost of full warehouse occupancy
sumMarginRate
String
margin rate for full account
positionVos
List
position collection
contractId
String
contract id
contractName
String
contract Name
contractSymbol
String
contract currency exchange
positions
List
position collection
positionType
String
position type (1 full position, 2 positions one by one)
side
String
BUY and SELL direction (BUY BUY, SELL SELL)
volume
String
Number of Positions
openPrice
String
opening Price
avgPrice
String
average price of position
closePrice
String
average closing price
leverageLevel
String
leverage multiple
openAmount
String
opening margin (including Variation)
holdAmount
String
position Margin
closeVolume
String
number of closed positions
pendingCloseVolume
String
the number of open positions that have been hung out.
realizedAmount
String
Realized profit and loss
historyRealizedAmount
String
historical cumulative realized profit and loss
tradeFee
String
Transaction Fees
capitalFee
String
capital expenses
closeProfit
String
closing profit and loss
shareAmount
String
apportioned amount
freezeLock
String
position freeze status: 0 normal, 1 burst freeze, 2 delivery freeze
status
String
position validity, 0 invalid 1 valid
marginRate
String
margin rate
reducePrice
String
price reduction
returnRate
String
rate of Return (Yield)
unRealizedAmount
String
unrealized profit and loss
openRealizedAmount
String
unrealized profit or loss on opening position
positionBalance
String
position Value
settleProfit
String
position settlement (current number of positions, average opening price and average position price profit and loss)
indexPrice
String
Latest Mark Price
keepRate
String
ladder Minimum Maintenance Margin Rate
maxFeeRate
String
maximum commission rate for closing positions
Return Results
API part-NAPI-direct call:
Interaction-Nostr part:
Before making a request to any interface, you must sign the request parameters through the Nostr protocol.
Parameter Description
sig
String
Yes
Event entire signature
kind
String
yes
Event Type:(1 plaintext; 4 ciphertext;)
created_at
String
yes
Event timestamp
id
String
yes
Event message ID
content
String
yes
Event Content: (AES/CBC/PKCS5Padding) encryption required,(? The first half of iv =) is base64Message ,(? The second half of iv =) is iv
pubkey
String
yes
fields returned by the public_info interface: nostrAddress
tags
String
yes
p: User nostrAddress r:json
Request Sample
Access to public information
URL:
/napi/common/public_info
Method:
GET
Login required: N
Request Parameters
Request Example
Return parameters
nostrAddress
String
Nostr address
wsUrl
String
WebSocket connection address
currentTimeMillis
String
current timestamp
marginCoinList
List
list of Margin Currencies
coinList
List
currency List
coin
String
currency Name
precious
String
currency precision
contractList
List
contract List
id
String
contract ID
contractName
String
contract Name
symbol
String
transaction Pair Symbol
closeMakerFee
String
Maker fees
closeTakerFee
String
Taker fee
base
String
base Currency
quote
String
pricing Currency
sort
String
sort Value
robot
String
robot Address
coinResultVo
Object
coin pair information
symbolPricePrecision
String
trading Pair Price Precision
minOrderVolume
String
minimum Order Quantity
minOrderMoney
String
minimum Order Amount
maxMarketVolume
String
maximum Market Order Volume
maxMarketMoney
String
maximum Market Order Amount
maxLimitVolume
String
maximum Limit Order Quantity
maxLimitMoney
String
maximum Limit Order Amount
marginCoinPrecision
String
currency precision
depth
List
Coin Pair Depth Precision Array
Return Results
Get all tag prices and index prices
URL:
/napi/common/public_all_index_tag_price
Method:
GET
Login required:N
Request Parameters
Request Example
Return parameters
contract_name
String
Contract Name
currentFundRate
String
current Funding Rate
tag_price
String
tag Price
index_price
String
index price
nextFundRate
String
next Fund Rate
Return Results
Get depth list
URL:
/napi/market/depth
Method:
POST
Login required: N
Request Parameters
contractName
String
Yes
contract Name
limit
String
no
get the number of bars: the default 100 maximum 100
Request Example
Return parameters
asks
String
Sale order depth
bids
String
paying Depth
time
String
latest timestamp
Return Results
Open currency exchange account
URL:
/napi/user/enable_trade
Method:
POST
Login required: Y
Request Parameters
contractName
String
Yes
contract Name
Request Example
Return parameters
code
String
Successful opening for 0
Return Results
Get user current delegate and current conditional delegate count
URL:
/napi/order/get_user_order_count
Method:
POST
Login required:Y
Request Parameters
Parameter Name
Type
Required
Description
contractName
String
Yes
Contract Name
Request Example
Return parameters
orderCount
String
Normal Current Delegation Count
triggerOrderCount
String
condition Current Delegate Count
Return Results
Get the list of current delegates
URL:
/napi/order/current_order_list
Method:
POST
Login required:Y
Request Parameters
contractName
String
Yes
contract Name
page
String
no
page number: Default 1
limit
String
no
number: default 100
Request Example
Return parameters
count
String
Total
orderList
List
order
symbol
String
transaction Pair
pricePrecision
String
price precision
eventId
String
event ID
side
String
BUY and SELL direction (BUY BUY, SELL SELL)
address
String
user Address
avgPrice
String
average Transaction Price
tradeFee
String
transaction Fees
memo
String
order Status Remarks
type
String
order type (1 limit; 2 market; 3 IOC; 4 FOK; 5 POST_ONLY; 6 warehouse explosion, only displayed on the page, not recorded in the database;)
mtime
String
Update time
volume
String
order quantity
dealVolume
String
number of transactions
price
String
order Price
ctime
String
creation time
contractName
String
contract Name
id
String
order ID
orderBalance
String
order Balance
dealMoney
String
amount of transactions
status
String
order Status (Order Status: 0 init,1 new,2 filled,3 part_filled,4 canceled,5 pending_cancel,6 expired)
Return Results
Obtain the historical delegation list.
URL:
/napi/order/history_order_list
Method:
POST
Login required:Y
Request Parameters
contractName
String
Yes
contract Name
wallet
String
yes
wallet address
page
String
no
page number: Default 1
limit
String
no
number: default 100
Request Example
Return parameters
count
String
Total
orderList
List
order
symbol
String
transaction Pair
pricePrecision
String
price precision
eventId
String
event ID
side
String
BUY and SELL direction (BUY BUY, SELL SELL)
address
String
user Address
avgPrice
String
average Transaction Price
tradeFee
String
transaction Fees
memo
String
order Status Remarks
type
String
order type (1 limit; 2 market; 3 IOC; 4 FOK; 5 POST_ONLY; 6 warehouse explosion, only displayed on the page, not recorded in the database;)
mtime
String
Update time
volume
String
order quantity
dealVolume
String
number of transactions
price
String
order Price
ctime
String
creation time
contractName
String
contract Name
id
String
order ID
orderBalance
String
order Balance
dealMoney
String
amount of transactions
status
String
order Status (Order Status: 0 init,1 new,2 filled,3 part_filled,4 canceled,5 pending_cancel,6 expired)
Return Results
Get the list of current plan delegations
URL:
/napi/order/trigger_order_list
Method:
POST
Login required:Y
Request Parameters
Parameter Name
Type
Required
Description
contractName
String
Yes
contract Name
page
String
no
page number: Default 1
limit
String
no
number: default 100
Request Example
Return parameters
count
String
Total
trigOrderList
Lis
planned Order
symbol
String
transaction Pair
pricePrecision
String
price precision
eventId
String
event ID
side
String
BUY and SELL direction (BUY BUY, SELL SELL)
triggerPrice
String
trigger Price
memo
String
order Status Remarks
type
String
order type (1 limit; 2 market; 3 IOC; 4 FOK; 5 POST_ONLY; 6 warehouse explosion, only displayed on the page, not recorded in the database;)
mtime
String
Update time
volume
String
order quantity
expireTime
String
condition Order Expiration Time
price
String
order Price
ctime
String
creation time
contractName
String
contract Name
id
String
order ID
triggerType
String
condition sheet type (1 stop loss,2 take profit,3 stop loss limit,4 take profit limit)
timeInForce
String
effective Way (1 GTC, 2 IOC, 3 FOK, 4GTX, 5 PostOnly)
status
String
Valid Status (0 Valid, 1 Expired, 2 Completed, 3 Trigger Failed)
Return Results
Get historical plan delegation list
URL:
/napi/order/history_trigger_order_list
Method:
POST
Login required:Y
Request Parameters
contractName
String
Yes
contract Name
page
String
no
page number: Default 1
limit
String
no
number: default 100
Request Example
Return parameters
count
String
Total
trigOrderList
List
planned Order
symbol
String
transaction Pair
pricePrecision
String
price precision
eventId
String
event ID
side
String
BUY and SELL direction (BUY BUY, SELL SELL)
triggerPrice
String
trigger Price
memo
String
order Status Remarks
type
String
order type (1 limit; 2 market; 3 IOC; 4 FOK; 5 POST_ONLY; 6 warehouse explosion, only displayed on the page, not recorded in the database;)
mtime
String
Update time
volume
String
order quantity
expireTime
String
condition Order Expiration Time
price
String
order Price
ctime
String
creation time
contractName
String
contract Name
id
String
order ID
triggerType
String
condition sheet type (1 stop loss,2 take profit,3 stop loss limit,4 take profit limit)
timeInForce
String
effective Way (1 GTC, 2 IOC, 3 FOK, 4GTX, 5 PostOnly)
status
String
valid Status (0 Valid, 1 Expired, 2 Completed, 3 Trigger Failed)
Return Results
Get historical transaction list
URL:
/napi/order/his_trade_list
Method:
POST
Login required:Y
Request Parameters
contractName
String
Yes
contract Name
page
String
no
page number: Default 1
limit
String
no
number: default 100
Request Example
Return parameters
count
String
Total
tradeHisList
List
transaction Order List
symbol
String
transaction Pair
pricePrecision
String
price precision
eventId
String
event ID
side
String
BUY and SELL direction (BUY BUY, SELL SELL)
role
String
active one-way direction:(Maker hangs one-way, Taker eats one-way)
fee
String
fees
realizedAmount
String
accumulated profit and loss of order
feeCoinPrecision
String
currency Display Precision
volume
String
number of transactions
feeCoin
String
fee Currency
price
String
transaction Price
ctime
String
transaction time
contractName
String
contract Name
id
String
transaction ID
Return Results
Browser-Market Data
URL:
/napi/order/history_order_list_explorer
Method:
POST
Login required:N
Request Parameters
contractName
String
Yes
Contract Name
wallet
String
no
wallet address or eventId retrieval
page
String
no
page number: Default 1
limit
String
no
number: default 100
type
String
no
order Type (1 limit; 2 market;)
Request Example
Return parameters
count
String
Total
orderList
List
order
symbol
String
transaction Pair
pricePrecision
String
price precision
eventId
String
event ID
side
String
BUY and SELL direction (BUY BUY, SELL SELL)
address
String
user Address
avgPrice
String
average Transaction Price
tradeFee
String
transaction Fees
memo
String
Order Status Remarks
type
String
order type (1 limit; 2 market; 3 IOC; 4 FOK; 5 POST_ONLY; 6 warehouse explosion, only displayed on the page, not recorded in the database;)
mtime
String
update time
volume
String
order quantity
dealVolume
String
number of transactions
price
String
order Price
ctime
String
creation time
contractName
String
contract Name
id
String
order ID
orderBalance
String
order Balance
dealMoney
String
Amount of transactions
status
String
order Status (Order Status: 0 init,1 new,2 filled,3 part_filled,4 canceled,5 pending_cancel,6 expired)
Return Results
Browser-Market Data-Details
URL:
/napi/order/his_trade_list_explorer
Method:
POST
Login required: N
Request Parameters
contractName
String
Yes
contract Name
page
String
no
page number: Default 1
limit
String
no
number: default 100
orderId
String
yes
order ID
Request Example
Return parameter
count
String
Total
tradeHisList
List
transaction Order List
symbol
String
transaction Pair
pricePrecision
String
price precision
eventId
String
event ID
side
String
BUY and SELL direction (BUY BUY, SELL SELL)
role
String
active one-way direction:(Maker hangs one-way, Taker eats one-way)
fee
String
fees
realizedAmount
String
accumulated profit and loss of order
feeCoinPrecision
String
currency Display Precision
volume
String
number of transactions
feeCoin
String
fee Currency
price
String
transaction Price
ctime
String
transaction time
contractName
String
contract Name
id
String
transaction ID
Return Results
Browser-Money Flow
URL:
/napi/trade/get_transaction_list_explorer
Method:
POST
Login required: N
Request Parameters
address
String
No
wallet address
symbol
String
no
currency
page
String
no
page number: Default 1
limit
String
no
number: default 100
type
String
no
type of flowing water (1 transfer-in 2 Transfer-out 6 Transaction Fee 13 Order Freeze 14 Order Cancellation Unfreeze 15 Transaction Transfer )
Request Example
Return parameter
ctimeL
String
Create timestamp
fromCoinSymbol
String
from Currency Name
toCoinSymbol
String
to Currency Name
type
String
type of flowing water (1 transfer-in 2 Transfer-out 6 Transaction Fee 13 Order Freeze 14 Order Cancellation Unfreeze 15 Transaction Transfer )
amount
String
quantity
fromAddress
String
from user address
toAddress
String
to User Address
Return Results
Get Daily Trading Volume
URL:
/napi/common/getDayTradeAmount
Method:
POST
Login required: N
Request Parameters
dayTimestamp
String
No
query date 0 timestamp (milliseconds), not passed default: query current day
Request Example
Return parameter
contractName
String
Contract Name
dayNtlVlm
String
daily trading volume
Return Results
Acquisition day fee, Total fee
URL:
/napi/common/getTradeFee
Method:
POST
Login required: N
Request Parameters
startTimestamp
String
Yes
query date start timestamp (milliseconds)
endTimestamp
String
yes
query date end timestamp (milliseconds)
Request Example
Return parameters
dailyFees
String
Daily fee
totalFees
String
total Handling Fee
Return Results
API section-NAPI- RELAY instruction:
Create User
URL:
/napi/user/create_user
Method:
POST
Login required: N
Request Parameters
nostrAddress
String
Yes
nostr protocol address
sign
String
no
value after eth signature
broker
String
yes
merchant id: fixed 1000
ethAddress
String
yes
eth address
time
String
yes
latest timestamp
referrals
String
no
invitation Code
Request Example
Return parameter
code
String
0 is successful.
Return Results
Limit order & Market price order & Plan to entrust order
URL:
/napi/order/order_create
Method:
POST
Login required: Y
Request Parameters
side
String
Yes
BUY and SELL direction (BUY BUY, SELL SELL)
open
String
yes
OPEN position direction (OPEN position, CLOSE position)
isConditionOrder
String
yes
whether it is a conditional list (true is, false is not)
type
String
yes
order type (1 limit, 2 market,3 IOC,4 FOK,5 POST_ONLY)
volume
String
yes
order quantity (open market price order: Amount)
contractName
String
yes
contract Name
price
String
yes
order Price
clientId
String
no
client order ID
triggerPrice
String
yes
trigger Price
source
String
yes
order source (order Source: 1web,2app,3api,4 others)
triggerType
String
yes
condition order type (0 normal condition order, 3 stop loss limit, 4 take profit limit)
expiredTime
String
Yes
validity duration of conditional sheet
ctime
String
yes
creation time
timeInForce
String
yes
effective Way (1 limit, 2 market,3 IOC,4 FOK,5 POST_ONLY)
Request Example
Return parameter
ids
List
Successful order ID list
cancelIds
List
list of order withdrawal ID when placing an order failed
Return Results
Withdrawal & Revocation of Plan Delegation
URL:
/napi/order/order_cancel
Method:
POST
Login required: Y
Request Parameters
orderId
String
Yes
order ID
clientId
String
no
client order ID
contractName
String
yes
contract Name
isConditionOrder
String
yes
whether it is a conditional list (true is, false is not)
Request Example
Return parameter
cancelIds
List
List of successful withdrawal ID
Return Results
Withdraw all orders&Cancellation of all plan commissions
URL:
/napi/order/order_cancel_all
Method:
POST
Login required: Y
Request Parameters
contractName
String
Yes
contract Name
isConditionOrder
String
yes
whether it is a conditional list (true is, false is not)
Request Example
Return parameter
cancelIds
List
List of successful withdrawal ID
Return Results
WSS:
OrderBook
Subscription Parameters
Push data
Latest Transaction (Full Volume)
Subscription Parameters
Push data
Latest Deal (Increment)
Subscription Parameters
Push data
Trading Pair Real-Time Price Trading Volume
Subscription Parameters
Push data
K line (full quantity)
Subscription Parameters
Push data
K-Line (increment)
Subscription Parameters
Push data
Last updated