0.0.10 • Published 1 year ago

@ln-markets/sdk v0.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Getting Started

Setup

Install our SDK using your preferred package manager:

npm install @ln-markets/sdk
pnpm install @ln-markets/sdk
yarn add @ln-markets/sdk
bun add @ln-markets/sdk

Network

By default, the SDK will connect to the LN Markets production environment. You can change this by setting the LNM_API_NETWORK environment variable to testnet or mainnet or passing the network option to the createRestClient function.

import { createRestClient } from '@ln-markets/sdk'

const client = createRestClient({
  network: 'testnet',
})

Unauthenticated client

You can use an unauthenticated client to access public endpoints.

import { createRestClient } from '@ln-markets/sdk'

const client = createRestClient()

await client.futures.getMarketDetails()

Authenticated client

You can authenticate using your API key, secret and passphrase directly passed to the createRestClient function.

You can get your API key, secret and passphrase from the API Keys section of your LN Markets account.

:warning: Important: Your API key, secret and passphrase are sensitive and should be kept secure. Do not expose them in your client-side code, nor share them with anyone. Any leakage of your API key, secret or passphrase may lead to unauthorized access to your account and irreversible loss of funds.

import { createRestClient } from '@ln-markets/sdk'

const client = createRestClient({
  key: 'your-api-key',
  secret: 'your-api-secret',
  passphrase: 'your-api-key-passphrase',
})

await client.futures.getTrades({
  type: 'open',
})

Alternatively, you can set the environment variables LNM_API_KEY, LNM_API_SECRET and LNM_API_PASSPHRASE to authenticate, which will be used by default if no parameters are provided to the createRestClient function.

Function List

FunctionMethodRouteDocumentation
futures.addMarginPOST/futures/add-marginReference
futures.cancelAllTradesDELETE/futures/all/cancelReference
futures.cancelTradePOST/futures/cancelReference
futures.cashInPOST/futures/cash-inReference
futures.closeAllTradesDELETE/futures/all/closeReference
futures.closeTradeDELETE/futuresReference
futures.getCarryFeesHistoryGET/futures/carry-feesReference
futures.getFixingHistoryGET/futures/history/fixingReference
futures.getIndexHistoryGET/futures/history/indexReference
futures.getLeaderboardGET/futures/leaderboardReference
futures.getMarketDetailsGET/futures/marketReference
futures.getOHLCHistoryGET/futures/ohlcsReference
futures.getPriceHistoryGET/futures/history/priceReference
futures.getTickerGET/futures/tickerReference
futures.getTradeGET/futures/trades/:idReference
futures.getTradesGET/futuresReference
futures.newTradePOST/futuresReference
futures.updateTradePUT/futuresReference
notifications.getAllNotificationsGET/notificationsReference
notifications.markAllAsReadDELETE/notifications/allReference
options.closeAllTradesDELETE/options/all/closeReference
options.closeTradeDELETE/optionsReference
options.getInstrumentGET/options/instrumentReference
options.getInstrumentsGET/options/instrumentsReference
options.getMarketDetailsGET/optionsReference
options.getTradeGET/options/trades/:idReference
options.getTradesGET/options/tradesReference
options.newTradePOST/optionsReference
options.updateTradePUT/optionsReference
oracle.getLastPriceGET/oracle/last-priceReference
swaps.getSwapBySourceIdGET/swap/source/:sourceIdReference
swaps.getSwapGET/swap/:swapIdReference
swaps.getSwapsGET/swapReference
swaps.newSwapPOST/swapReference
user.depositSyntheticUsdPOST/user/deposit/susdReference
user.depositPOST/user/depositReference
user.getBitcoinAddressesGET/user/bitcoin/addressesReference
user.getDepositGET/user/deposit/:depositIdReference
user.getDepositsGET/user/depositReference
user.getUserGET/userReference
user.getWithdrawalGET/user/withdrawals/:idReference
user.getWithdrawalsGET/user/withdrawReference
user.newBitcoinAddressPOST/user/bitcoin/addressReference
user.transferPOST/user/transferReference
user.updateUserPUT/userReference
user.withdrawSyntheticUsdPOST/user/withdraw/susdReference
user.withdrawPOST/user/withdrawReference