LN Markets API (2.0.0)

Download OpenAPI specification:Download

LN Markets API

LN Markets opens a REST and a Websocket API to integrate with your program or trading bot.

This API reference provides information on available endpoints and how to interact with it.

You can find a javascript package here ready to use

Signature

LNM-ACCESS-SIGNATURE header is generated by creating a sha256 HMAC using the secret key on the prehash string timestamp + method + path + params (where + represents string concatenation) digested in Base 64.

  • method : MUST be UPPER CASE.

  • path : is the request path of the URL, e.g.: /v2/user

  • timestamp : value is the same as the LNM-ACCESS-TIMESTAMP header.

    It MUST be number of millisecond since Unix Epoch in UTC and it should be within 30 seconds of our API time.

  • params : is the request body as a JSON string (with no space, no line return)

    or the request query as URL search params

    and if there is no data it should be an empty string

Here is some example to create the signature

Javascript

const { createHmac } = require('crypto')
const { URLSearchParams } = require('url')

let params = ''

if (method.match(/^(GET|DELETE)$/)) {
  params = new URLSearchParams(data).toString()
} else {
  params = JSON.stringify(data)
}

const signature = createHmac('sha256', secret).update(`${timestamp}${method}${path}${params}`).digest('base64')

Python

import hmac
import base64
import json
import urllib

params = ''

if ((method == 'GET') | (method == 'DELETE')):
    params = urllib.parse.urlencode(data)

elif ((method == 'POST') | (method == 'PUT')):
    params = json.dumps(data, separators=(',', ':'))

signature = base64.b64encode(hmac.new(secret, timestamp + method + path + params, hashlib.sha256).digest())

Bash

signature=$(echo -n "$timestamp$method$path$params" | openssl dgst -sha256 -hmac $SECRET -binary | base64 )

REST API

The API endpoint for mainnet is https://api.lnmarkets.com/v2

If you want to try our API with testnet bitcoin use https://api.testnet.lnmarkets.com/v2

REST Authentication

API key authentication requires each request to be signed (enhanced security measure). You can create and activate new API keys on your profile here. Your API keys should be assigned to access only accounts and permission scopes that are necessary for your app to function.

Making a request

All REST requests must contain the following headers:

Header Description
LNM-ACCESS-KEY API key as a string.
LNM-ACCESS-SIGNATURE Message signature.
LNM-ACCESS-PASSPHRASE API key passphrase.
LNM-ACCESS-TIMESTAMP Timestamp for your request.

All request bodies should have content type application/json and be valid JSON.

curl https://api.lnmarkets.com/v2/futures \
  --header "LNM-ACCESS-KEY: <your api key>" \
  --header "LNM-ACCESS-PASSPHRASE: <your api key passphrase>" \
  --header "LNM-ACCESS-SIGNATURE: <the user generated message signature in base64>" \
  --header "LNM-ACCESS-TIMESTAMP: <a timestamp for your request in milliseconds>" \
  --header "Content-Type: application/json" \
  --request POST \
  --data '{"type":"l","side":"b","price":40000,"quantity":1,"leverage":10}'

REST Examples

Here is an example on how to do a request to LN Markets :

const https = require('https')
const { createHmac } = require('crypto')
const { URLSearchParams } = require('url')

const requestAPI = (options) => {
  return new Promise((resolve, reject) => {
    const req = https.request(options, (res) => {
      res.setEncoding('utf8')

      let data = ''

      res.on('data', (chunk) => {
        data += chunk
      })

      res.on('error', (error) => {
        reject(error)
      })

      res.on('end', () => {
        if (this.debug) {
          return resolve({ req, res })
        }

        try {
          const body = JSON.parse(data)

          if (res.statusCode === 200) {
            resolve(body)
          } else {
            console.error(body)
            reject(new Error(res.statusCode, body))
          }
        } catch (error) {
          error.data = data
          reject(error)
        }
      })
    })

    req.on('error', (error) => {
      reject(error)
    })

    if (options.method.match(/^(PUT|POST)$/) && options.params) {
      req.write(JSON.stringify(options.params))
    }

    req.end()
  })
}

const main = async () => {
  const key = 'API_KEY'
  const secret = 'API_SECRET'
  const passphrase = 'API_PASSPHRASE'
  const timestamp = Date.now()

  const params = { type: 'm', side: 'b', quantity: 4242 }

  const method = `POST`
  const path = `/v2/futures`

  let data = ''

  if (method.match(/^(GET|DELETE)$/)) {
    data = new URLSearchParams(params).toString()
  } else {
    data = JSON.stringify(params)
  }

  const payload = `${timestamp}${method}${path}${data}`

  const signature = createHmac('sha256', secret)
    .update(payload)
    .digest('base64')

  const headers = {
    'Content-Type': 'application/json',
    'LNM-ACCESS-KEY': key,
    'LNM-ACCESS-PASSPHRASE': passphrase,
    'LNM-ACCESS-TIMESTAMP': timestamp,
    'LNM-ACCESS-SIGNATURE': signature,
  }

  const options = {
    port: 443,
    hostname: 'api.lnmarkets.com',
    method,
    path,
    headers,
  }

  if (method.match(/^(GET|DELETE)$/) && params) {
    options.path += `?${new URLSearchParams(params).toString()}`
  }

  const position = await requestAPI(options)
  console.log(position)
}

main()

If you want a full implementation example you can take a look at our npm package @ln-markets/api.

Websockets API

The websocket endpoint for mainnet is wss://api.lnmarkets.com

If you want to try with testnet bitcoin use wss://api.testnet.lnmarkets.com

This API follows the JSON-RPC specification.

Request sent to the API should be a valid JSON like:

{
  "jsonrpc": "2.0",
  "method": "debug/echo",
  "id": "faffssdfsdf432", // Random id
  "params": {
    "hello": "world"
  }
}

And response would look like:

{
  "jsonrpc": "2.0",
  "id": "faffssdfsdf432", // Same id
  "result": {
    "hello": "world"
  }
}

You need to listen for the id provided in the request to get the response back!

Websocket Authentication

To create an authenticated websocket you need to send a payload once, this payload should be like:

{
  "jsonrpc": "2.0",
  "method": "auth/api-key",
  "params": {
    "timestamp": 1636389122390, // The current timestamp
    "signature": "SAFiGx46GGqztiHu31Mfm89VT3Cp0kqhap4DEs6Pv/U=", // HMAC SHA256 (method + timestamp concatenation) Base 64
    "passphrase": "fd026g0d4i52", // Your passphrase
    "key": "DKJLy/OlXQqQgbT0bE18HJgzQOJnuaTW43OQD8EEHuM=" // Your api key
  }
}

Websockets Examples

Here is an example on how to do a request to LN Markets :

const Websocket = require('ws')

const ws = new Websocket('wss://api.lnmarkets.com')

const key = 'API_KEY'
const secret = 'API_SECRET'
const passphrase = 'API_PASSPHRASE'

const timestamp = Date.now()
const method = `auth/api-key`
const payload = `${timestamp}${method}`

const signature = createHmac('sha256', secret)
  .update(payload)
  .digest('base64')

const request = {
  jsonrpc: '2.0',
  method,
  params: {
    timestamp,
    signature,
    passphrase,
    key,
  },
}

ws.on('message', console.log)
ws.send(JSON.stringify(request))

If you want a full implementation example you can take a look at our npm package @ln-markets/api

Heartbeats

If you are concerned about your connection silently dropping, we recommend implementing the following flow:

After receiving each message, set a timer duration of 5 seconds. If any message is received before that timer fires, restart the timer. When the timer fires (no messages received in 5 seconds), send a raw ping frame. Expect a raw pong frame in response. If this is not received within 5 seconds, throw an error or reconnect.

Subscription

You can subscribe to differents events using the subscribe method. If you wish to unsubscribe, call the unsubscribe and the event you want to be unsubscribed from. Here is the full list of available subscriptions.

[
  "futures/market/bid-offer",
  "futures/market/index",
  "options/data/forwards",
  "options/data/volcurve",
  "options/data/ordermap"
]

Limits

We established some limitation across th API to ensure our services integrity.

Futures

There is a maximum of 50 open positions per account.

Options

There is a maximum of 50 open trades per account.

Rate

Requests to our REST API are rate limited to 1 request per second, endpoints which do not require authentication are limited to 30 requests per minute.

Here are Headers related to rate limitation:

Header Description
Retry-After Will tell you how many seconds you need to wait to call this endpoint if your limit is down to 0.
X-Ratelimit-Remaining This is how many request do you have left before blocking.
X-Ratelimit-Reset This is the timestamp in ms when limitation will be reset.

Requests

If you throw too much error such as 4XX or 5XX, your IP could be banned for a certain period of time.

Errors

Code Meaning
400 Bad request. Your request is invalid.
401 Unauthorized. Your API key is wrong or you don't have access to the requested resource.
403 Forbidden. Your API key has the wrong scope.
404 Not found.
405 Method Not Allowed. You tried to access a resource with an invalid method.
418 I'm a teapot.
429 Too many requests. Your connection is being rate limited.
500 Internal server error. Something went wrong, please try again or contact us.
503 Service unavailable. We're temporarily offline for maintenance. Please try again later.

Futures

Add margin

Add margin to a running trade

Authorizations:
ApiKey
Request Body schema: application/json
required
id
required
string <uuid>
amount
required
number > 0

Responses

Request samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "amount": 0
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "type": "m",
  • "side": "b",
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "maintenance_margin": 0,
  • "quantity": 0,
  • "margin": 0,
  • "leverage": 0,
  • "price": 0,
  • "liquidation": 0,
  • "stoploss": 0,
  • "takeprofit": 0,
  • "exit_price": 0,
  • "pl": 0,
  • "creation_ts": 0,
  • "market_filled_ts": 0,
  • "closed_ts": null,
  • "open": true,
  • "running": true,
  • "canceled": false,
  • "closed": false,
  • "last_update_ts": 0,
  • "sum_carry_fees": 0,
  • "entry_price": 0,
  • "entry_margin": 0
}

Cancel all trades

Cancel all open trades

Authorizations:
ApiKey

Responses

Response samples

Content type
application/json
{
  • "trades": [
    ]
}

Cancel

Cancel an open trade

Authorizations:
ApiKey
Request Body schema: application/json
required
id
required
string <uuid>

Responses

Request samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "type": "l",
  • "side": "b",
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "maintenance_margin": 0,
  • "quantity": 0,
  • "margin": 0,
  • "leverage": 0,
  • "price": 0,
  • "liquidation": 0,
  • "stoploss": 0,
  • "takeprofit": 0,
  • "exit_price": 0,
  • "pl": 0,
  • "creation_ts": 0,
  • "market_filled_ts": null,
  • "closed_ts": 0,
  • "open": true,
  • "running": false,
  • "canceled": true,
  • "closed": false,
  • "last_update_ts": 0,
  • "sum_carry_fees": 0,
  • "entry_price": 0,
  • "entry_margin": 0
}

Cash-in

Cash-in a portion of a trade PL

Authorizations:
ApiKey
Request Body schema: application/json
required
id
required
string <uuid>
amount
required
number > 0

Responses

Request samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "amount": 0
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "type": "m",
  • "side": "b",
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "maintenance_margin": 0,
  • "quantity": 0,
  • "margin": 0,
  • "leverage": 0,
  • "price": 0,
  • "liquidation": 0,
  • "stoploss": 0,
  • "takeprofit": 0,
  • "exit_price": 0,
  • "pl": 0,
  • "creation_ts": 0,
  • "market_filled_ts": 0,
  • "closed_ts": null,
  • "open": true,
  • "running": true,
  • "canceled": false,
  • "closed": false,
  • "last_update_ts": 0,
  • "sum_carry_fees": 0,
  • "entry_price": 0,
  • "entry_margin": 0
}

Close all trades

Close all running trades

Authorizations:
ApiKey

Responses

Response samples

Content type
application/json
{
  • "trades": [
    ]
}

Close

Close the user trade, the PL will be calculated against the current last price depending on the side of the trade

Authorizations:
ApiKey
query Parameters
id
required
string <uuid>

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "type": "m",
  • "side": "b",
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "maintenance_margin": 0,
  • "quantity": 0,
  • "margin": 0,
  • "leverage": 0,
  • "price": 0,
  • "liquidation": 0,
  • "stoploss": 0,
  • "takeprofit": 0,
  • "exit_price": 0,
  • "pl": 0,
  • "creation_ts": 0,
  • "market_filled_ts": 0,
  • "closed_ts": 0,
  • "open": true,
  • "running": false,
  • "canceled": false,
  • "closed": true,
  • "last_update_ts": 0,
  • "sum_carry_fees": 0,
  • "entry_price": 0,
  • "entry_margin": 0
}

Trades

Fetch users trades

Authorizations:
ApiKey
query Parameters
type
required
string
Enum: "running" "open" "closed"
from
integer
to
integer
limit
integer [ 1 .. 1000 ]
Default: 100

Responses

Response samples

Content type
application/json
[
  • {
    }
]

New trade

Send the order form parameters to add a new trade in database. If type="l", the property price must be included in the request to know when the trade should be filled. You can choose to use the margin or the quantity as a parameter, the other will be calculated with the one you chose

Authorizations:
ApiKey
Request Body schema: application/json
required
required
string or string
required
string or string
margin
number
leverage
required
number
price
number
quantity
number
takeprofit
number
stoploss
number

Responses

Request samples

Content type
application/json
{
  • "side": "b",
  • "type": "m",
  • "margin": 0,
  • "leverage": 0,
  • "price": 0,
  • "quantity": 0,
  • "takeprofit": 0,
  • "stoploss": 0
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "type": "m",
  • "side": "b",
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "maintenance_margin": 0,
  • "quantity": 0,
  • "margin": 0,
  • "leverage": 0,
  • "price": 0,
  • "liquidation": 0,
  • "stoploss": 0,
  • "takeprofit": 0,
  • "exit_price": 0,
  • "pl": 0,
  • "creation_ts": 0,
  • "market_filled_ts": 0,
  • "closed_ts": null,
  • "open": true,
  • "running": true,
  • "canceled": false,
  • "closed": false,
  • "last_update_ts": 0,
  • "sum_carry_fees": 0,
  • "entry_price": 0,
  • "entry_margin": 0
}

Update trade

Allows user to modify stoploss or takeprofit on a trade

Authorizations:
ApiKey
Request Body schema: application/json
required
id
required
string <uuid>
type
required
string
Enum: "stoploss" "takeprofit"
value
required
number >= 0

Responses

Request samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "type": "stoploss",
  • "value": 0
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "type": "m",
  • "side": "b",
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "maintenance_margin": 0,
  • "quantity": 0,
  • "margin": 0,
  • "leverage": 0,
  • "price": 0,
  • "liquidation": 0,
  • "stoploss": 0,
  • "takeprofit": 0,
  • "exit_price": 0,
  • "pl": 0,
  • "creation_ts": 0,
  • "market_filled_ts": 0,
  • "closed_ts": null,
  • "open": true,
  • "running": true,
  • "canceled": false,
  • "closed": false,
  • "last_update_ts": 0,
  • "sum_carry_fees": 0,
  • "entry_price": 0,
  • "entry_margin": 0
}

Carry fees history

Retrieves carry fees for user

Authorizations:
ApiKey
query Parameters
from
integer
to
integer
limit
integer [ 1 .. 1000 ]
Default: 100

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Fixing history

Retrieve fixing history at most 1000 entries between two given timestamps

query Parameters
from
integer
to
integer
limit
integer [ 1 .. 1000 ]
Default: 100

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Index history

Retrieve index history at most 1000 entries between two given timestamps

query Parameters
from
integer
to
integer
limit
integer [ 1 .. 1000 ]
Default: 100

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Leaderboard

Get the 10 first users by P&L broke down by day/week/month/all-time

Responses

Response samples

Content type
application/json
null

Futures market

Get the futures market details

Responses

Response samples

Content type
application/json
{
  • "active": true,
  • "limits": {
    },
  • "fees": {
    }
}

Price history

Retrieve price history at most 1000 entries between two given timestamps

query Parameters
from
integer
to
integer
limit
integer [ 1 .. 1000 ]
Default: 100

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Ticker

Get the futures ticker

Responses

Response samples

Content type
application/json
{
  • "index": 0,
  • "askPrice": 0,
  • "bidPrice": 0,
  • "lastPrice": 0,
  • "carryFeeRate": 0,
  • "carryFeeTimestamp": 0
}

Get trade

Get a trade by id

Authorizations:
ApiKey
path Parameters
id
required
string

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "type": "l",
  • "side": "b",
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "maintenance_margin": 0,
  • "quantity": 0,
  • "margin": 0,
  • "leverage": 0,
  • "price": 0,
  • "liquidation": 0,
  • "stoploss": 0,
  • "takeprofit": 0,
  • "exit_price": 0,
  • "pl": 0,
  • "creation_ts": 0,
  • "market_filled_ts": null,
  • "closed_ts": 0,
  • "open": true,
  • "running": false,
  • "canceled": true,
  • "closed": false,
  • "last_update_ts": 0,
  • "sum_carry_fees": 0,
  • "entry_price": 0,
  • "entry_margin": 0
}

Options

Close all trades

Close all of the user option trades, the PL will be calculated against the current last price depending on the type of the options

Authorizations:
ApiKey

Responses

Response samples

Content type
application/json
{
  • "trades": [
    ]
}

Close

Close option trade

Authorizations:
ApiKey
query Parameters
id
required
string <uuid>

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "forward": 0,
  • "forward_point": 0,
  • "domestic": "string",
  • "settlement": "physical",
  • "fixing_price": 0,
  • "creation_ts": 0,
  • "expiry_ts": 0,
  • "closed_ts": 0,
  • "physical_delivery_id": "string",
  • "leg_id": "string",
  • "side": "b",
  • "type": "c",
  • "quantity": 0,
  • "strike": 0,
  • "volatility": 0,
  • "margin": 0,
  • "pl": 0,
  • "maintenance_margin": 0,
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "running": true,
  • "closed": true,
  • "expired": true,
  • "exercised": true
}

Trades

Get user's vanilla options trades

Authorizations:
ApiKey
query Parameters
status
string
Enum: "running" "closed"
from
integer
to
integer
limit
integer [ 1 .. 1000 ]
Default: 100

Responses

Response samples

Content type
application/json
[
  • {
    }
]

New trade

Create a new options trade

Authorizations:
ApiKey
Request Body schema: application/json
required
side
required
string
Value: "b"
quantity
required
number > 0
settlement
required
string
Enum: "physical" "cash"
instrument_name
required
string

Responses

Request samples

Content type
application/json
{
  • "side": "b",
  • "quantity": 0,
  • "settlement": "physical",
  • "instrument_name": "string"
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "forward": 0,
  • "forward_point": 0,
  • "domestic": "string",
  • "settlement": "physical",
  • "fixing_price": 0,
  • "creation_ts": 0,
  • "expiry_ts": 0,
  • "closed_ts": null,
  • "physical_delivery_id": null,
  • "leg_id": "string",
  • "side": "b",
  • "type": "c",
  • "quantity": 0,
  • "strike": 0,
  • "volatility": 0,
  • "margin": 0,
  • "pl": 0,
  • "maintenance_margin": 0,
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "running": true,
  • "closed": false,
  • "expired": true,
  • "exercised": true
}

Update trade

Allows user to update settlement parameter in running option trade

Authorizations:
ApiKey
Request Body schema: application/json
required
id
required
string <uuid>
settlement
required
string
Enum: "physical" "cash"

Responses

Request samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "settlement": "physical"
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "forward": 0,
  • "forward_point": 0,
  • "domestic": "string",
  • "settlement": "physical",
  • "fixing_price": 0,
  • "creation_ts": 0,
  • "expiry_ts": 0,
  • "closed_ts": null,
  • "physical_delivery_id": null,
  • "leg_id": "string",
  • "side": "b",
  • "type": "c",
  • "quantity": 0,
  • "strike": 0,
  • "volatility": 0,
  • "margin": 0,
  • "pl": 0,
  • "maintenance_margin": 0,
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "running": true,
  • "closed": false,
  • "expired": true,
  • "exercised": true
}

Instrument

Instrument details

query Parameters
instrument_name
required
string
Example: instrument_name=BTC.2023-01-27.10000.C

Responses

Response samples

Content type
application/json
{
  • "volatility": "0.88"
}

Instruments

Instruments list

Responses

Response samples

Content type
application/json
[
  • "BTC.2023-01-27.10000.C",
  • "BTC.2023-01-27.10000.P",
  • "BTC.2023-01-27.20000.C",
  • "BTC.24H.20000.P"
]

Get trade

Get a trade by id

Authorizations:
ApiKey
path Parameters
id
required
string

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "uid": "string",
  • "forward": 0,
  • "forward_point": 0,
  • "domestic": "string",
  • "settlement": "physical",
  • "fixing_price": 0,
  • "creation_ts": 0,
  • "expiry_ts": 0,
  • "closed_ts": 0,
  • "physical_delivery_id": null,
  • "leg_id": "string",
  • "side": "b",
  • "type": "c",
  • "quantity": 0,
  • "strike": 0,
  • "volatility": 0,
  • "margin": 0,
  • "pl": 0,
  • "maintenance_margin": 0,
  • "opening_fee": 0,
  • "closing_fee": 0,
  • "running": true,
  • "closed": false,
  • "expired": true,
  • "exercised": true
}

Volatility

Volatility index

Responses

Response samples

Content type
application/json
{
  • "volatilityIndex": "1.337"
}

Options market

Get the options market details

Responses

Response samples

Content type
application/json
{
  • "active": true,
  • "limits": {
    },
  • "fees": {
    }
}

Swap

Swaps

Fetch users swaps

Authorizations:
ApiKey
query Parameters
from
integer
to
integer
limit
integer [ 1 .. 1000 ]
Default: 100

Responses

Response samples

Content type
application/json
[
  • {
    }
]

New swap

Create a new swap

Authorizations:
ApiKey
Request Body schema: application/json
required
in_asset
required
string
out_asset
required
string
in_amount
number
out_amount
number

Responses

Request samples

Content type
application/json
{
  • "in_asset": "string",
  • "out_asset": "string",
  • "in_amount": 0,
  • "out_amount": 0
}

Response samples

Content type
application/json
{
  • "in_asset": "string",
  • "out_asset": "string",
  • "in_amount": 0,
  • "out_amount": 0,
  • "exchange_rate": 0
}

User

Get user information

Get user information

Authorizations:
ApiKey

Responses

Response samples

Content type
application/json
{
  • "uid": "string",
  • "role": "string",
  • "balance": 0,
  • "username": "string",
  • "synthetic_usd_balance": 0,
  • "linkingpublickey": "string",
  • "show_leaderboard": true,
  • "email": "string",
  • "email_confirmed": true,
  • "use_taproot_addresses": true,
  • "account_type": "string",
  • "auto_withdraw_enabled": true,
  • "auto_withdraw_lightning_address": "string",
  • "nostr_pubkey": "string",
  • "fee_tier": 0,
  • "totp_enabled": true,
  • "webauthn_enabled": true,
  • "metrics": null
}

Update user information

Update user information

Authorizations:
ApiKey
Request Body schema: application/json
required
auto_withdraw_enabled
boolean
auto_withdraw_lightning_address
string
nostr_pubkey
string
username
string
use_taproot_addresses
boolean
show_leaderboard
boolean

Responses

Request samples

Content type
application/json
{
  • "auto_withdraw_enabled": true,
  • "auto_withdraw_lightning_address": "string",
  • "nostr_pubkey": "string",
  • "username": "string",
  • "use_taproot_addresses": true,
  • "show_leaderboard": true
}

Response samples

Content type
application/json
{
  • "uid": "string",
  • "role": "string",
  • "balance": 0,
  • "username": "string",
  • "synthetic_usd_balance": 0,
  • "linkingpublickey": "string",
  • "show_leaderboard": true,
  • "email": "string",
  • "email_confirmed": true,
  • "use_taproot_addresses": true,
  • "account_type": "string",
  • "auto_withdraw_enabled": true,
  • "auto_withdraw_lightning_address": "string",
  • "nostr_pubkey": "string",
  • "fee_tier": 0,
  • "totp_enabled": true,
  • "webauthn_enabled": true,
  • "metrics": null
}

Wallet

Cancel an on-chain withdrawal request

Cancel an on-chain withdrawal request

Authorizations:
ApiKey
path Parameters
id
required
string

Responses

Response samples

Content type
application/json
null

Create a new bitcoin address

Create a new bitcoin address

Authorizations:
ApiKey
Request Body schema: application/json
optional
format
string
Enum: "p2wpkh" "p2tr"

Responses

Request samples

Content type
application/json
{
  • "format": "p2wpkh"
}

Response samples

Content type
application/json
{
  • "address": "string",
  • "creation_ts": 0
}

Get Bitcoin addresses

Get Bitcoin addresses

Authorizations:
ApiKey

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Get deposit

Get deposit by id

Authorizations:
ApiKey
path Parameters
id
required
string <uuid>

Responses

Response samples

Content type
application/json
{
  • "ts": 0,
  • "type": "lightning",
  • "id": "string",
  • "amount": 0,
  • "payment_hash": "string",
  • "success": false
}

Get deposits

Get deposits

Authorizations:
ApiKey
query Parameters
from
number
to
number
limit
integer [ 1 .. 1000 ]
Default: 100
types
string

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Deposit

Deposit

Authorizations:
ApiKey
Request Body schema: application/json
required
amount
required
number

Responses

Request samples

Content type
application/json
{
  • "amount": 0
}

Response samples

Content type
application/json
{
  • "depositId": "string",
  • "paymentRequest": "string",
  • "expiry": 0
}

Get withdrawal

Get withdrawal by id

Authorizations:
ApiKey
path Parameters
id
required
string

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "amount": 0,
  • "address": "string",
  • "status": "string",
  • "transaction_id": "string",
  • "fee": 0,
  • "ts": 0,
  • "type": "bitcoin"
}

Get withdrawals

Get withdrawals

Authorizations:
ApiKey
query Parameters
from
number
to
number
limit
integer [ 1 .. 1000 ]
Default: 100
types
string

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Withdraw

Withdraw

Authorizations:
ApiKey
Request Body schema: application/json
required
invoice
required
string

Responses

Request samples

Content type
application/json
{
  • "invoice": "string"
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "paymentHash": "string",
  • "amount": 0,
  • "fee": 0,
  • "successTime": 0
}

Request an on-chain withdrawal

Request an on-chain withdrawal

Authorizations:
ApiKey
Request Body schema: application/json
required
address
required
string
amount
required
number

Responses

Request samples

Content type
application/json
{
  • "address": "string",
  • "amount": 0
}

Response samples

Content type
application/json
{
  • "id": "string"
}

Internal transfer

Transfer sats to another LN Markets user,

Authorizations:
ApiKey
Request Body schema: application/json
required
toUsername
required
string
amount
required
number >= 1

Responses

Request samples

Content type
application/json
{
  • "toUsername": "string",
  • "amount": 1
}

Response samples

Content type
application/json
{
  • "to": "string",
  • "amount": 0
}

Oracle

Index

Samples index history at most 100 entries between two given timestamps.

query Parameters
from
required
number
to
required
number
limit
integer [ 1 .. 1000 ]
Default: 100

Responses

Response samples

Content type
application/json
[
  • {
    },
  • {
    }
]

Last Price

Samples last price history at most 100 entries between two given timestamps.

query Parameters
from
required
number
to
required
number
limit
integer [ 1 .. 1000 ]
Default: 100

Responses

Response samples

Content type
application/json
[
  • {
    },
  • {
    }
]

Notifications

Fetch

Get unread notifications

Authorizations:
ApiKey

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Mark all notifications as read

Mark all notifications as read

Authorizations:
ApiKey

Responses

Response samples

Content type
application/json
null

App

Configuration

Retrieve the current configuration of LN Markets

Responses

Response samples

Content type
application/json
{
  • "max_balance_amount": 0,
  • "max_deposit_amount": 0,
  • "min_deposit_amount": 0,
  • "max_withdraw_amount": 0,
  • "min_withdraw_amount": 0
}

Node

Retrieve information about the lightning node

Responses

Response samples

Content type
application/json
null