@ln-markets/sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.10 • Public • Published

LN Market's logo

NPM Package Version NPM Package Downloads Follow us on X (Twitter)

LN Markets TypeScript SDK

Website - API Reference - Python SDK

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.

⚠️ 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

Function Method Route Documentation
futures.addMargin POST /futures/add-margin Reference
futures.cancelAllTrades DELETE /futures/all/cancel Reference
futures.cancelTrade POST /futures/cancel Reference
futures.cashIn POST /futures/cash-in Reference
futures.closeAllTrades DELETE /futures/all/close Reference
futures.closeTrade DELETE /futures Reference
futures.getCarryFeesHistory GET /futures/carry-fees Reference
futures.getFixingHistory GET /futures/history/fixing Reference
futures.getIndexHistory GET /futures/history/index Reference
futures.getLeaderboard GET /futures/leaderboard Reference
futures.getMarketDetails GET /futures/market Reference
futures.getOHLCHistory GET /futures/ohlcs Reference
futures.getPriceHistory GET /futures/history/price Reference
futures.getTicker GET /futures/ticker Reference
futures.getTrade GET /futures/trades/:id Reference
futures.getTrades GET /futures Reference
futures.newTrade POST /futures Reference
futures.updateTrade PUT /futures Reference
notifications.getAllNotifications GET /notifications Reference
notifications.markAllAsRead DELETE /notifications/all Reference
options.closeAllTrades DELETE /options/all/close Reference
options.closeTrade DELETE /options Reference
options.getInstrument GET /options/instrument Reference
options.getInstruments GET /options/instruments Reference
options.getMarketDetails GET /options Reference
options.getTrade GET /options/trades/:id Reference
options.getTrades GET /options/trades Reference
options.newTrade POST /options Reference
options.updateTrade PUT /options Reference
oracle.getLastPrice GET /oracle/last-price Reference
swaps.getSwapBySourceId GET /swap/source/:sourceId Reference
swaps.getSwap GET /swap/:swapId Reference
swaps.getSwaps GET /swap Reference
swaps.newSwap POST /swap Reference
user.depositSyntheticUsd POST /user/deposit/susd Reference
user.deposit POST /user/deposit Reference
user.getBitcoinAddresses GET /user/bitcoin/addresses Reference
user.getDeposit GET /user/deposit/:depositId Reference
user.getDeposits GET /user/deposit Reference
user.getUser GET /user Reference
user.getWithdrawal GET /user/withdrawals/:id Reference
user.getWithdrawals GET /user/withdraw Reference
user.newBitcoinAddress POST /user/bitcoin/address Reference
user.transfer POST /user/transfer Reference
user.updateUser PUT /user Reference
user.withdrawSyntheticUsd POST /user/withdraw/susd Reference
user.withdraw POST /user/withdraw Reference

Package Sidebar

Install

npm i @ln-markets/sdk

Weekly Downloads

109

Version

0.0.10

License

MIT

Unpacked Size

174 kB

Total Files

271

Last publish

Collaborators

  • vafanassieff
  • flavianito