NAV
curl Node.js Python

Introduction

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

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

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

Authentication

One type of authentication is required, currently we are using a JSON Web Token (JWT)

In order to generate your JWT, go to your Profile on LN Markets (click on the menu in the upper right corner) and select API Tokens.

You can now generate your token for various scopes: user, positions, deposit, withdraw.

Your JWT can be valid for a given period of time or indefinitely.

The JWT must be provided within the header AUTHORIZATION like :

Authorization: Bearer <token>

Note : Never share your JWT !

You can revoke any JWT on your profile page.

Limits

Positions

There is a maximum of 50 open positions 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.

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

Headers

Header Value
Retry-After 14
X-Ratelimit-Remaining 0
X-Ratelimit-Reset 1601997680244


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.

X-Ratelimit-Reset: This is the timestamp in ms when you will be granted new points.

Websocket

You can find a websocket endpoint where you can gather realtime data from LN Markets such as bid, offer, index, and last price.

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

You are limited to 60 connections per hour.

Authentication to websocket will come soon!

Errors

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- Your api key has the wrong scope.
404 Not Found -- Not Found.
405 Method Not Allowed -- You tried to access a ressource 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 !
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.

API v1.0.0

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

Trade derivatives on the Lightning Network. You can find our website here.

Base URLs:

Login

Here you can find the different way to auth yourself on LN Markets, mostly use for browser.

Login with a JWT

Code samples

import requests

url = "https://api.lnmarkets.com/v1/login/token"

payload = {
    "type": "object",
    "additionalProperties": False,
    "required": ["token"],
    "properties": {"token": {"type": "string"}}
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/login/token",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  type: 'object',
  additionalProperties: false,
  required: ['token'],
  properties: {token: {type: 'string'}}
}));
req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/login/token \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"type":"object","additionalProperties":false,"required":["token"],"properties":{"token":{"type":"string"}}}'

POST /login/token

Use a JWT to log on LN Markets. The token need to have the 'user' scope and the token will be revoked ater the sucessfull login

Body parameter

{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "token"
  ],
  "properties": {
    "token": {
      "type": "string"
    }
  }
}

Parameters

Name In Type Required Description
body body object true none
» token body string true none

Example responses

200 Response

{
  "login": "lnmarkets",
  "account_type": "credentials",
  "balance": 1337
}

Responses

Status Meaning Description Schema
200 OK Successfuly logged into the account. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» username string true none User choosen username (May differe from login)
» balance string true none User current balance
» account_type string true none User account type, here credentials

Response Headers

Status Header Type Format Description
200 Set-Cookie string none

Webln Verify Message

Code samples

import requests

url = "https://api.lnmarkets.com/v1/login/joule"

payload = {
    "signature": "rd1nn7qbnibf58mzaknokqu6eciiqr64gahrzzxy3h8ybdygbun7s86zrms1dedqnh7t4gxz3esqmaqi9pkf85f48rexai7qztbdznfp",
    "alias": "LN-BIG 1337",
    "message": "Sign this super secret message"
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/login/joule",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  signature: 'rd1nn7qbnibf58mzaknokqu6eciiqr64gahrzzxy3h8ybdygbun7s86zrms1dedqnh7t4gxz3esqmaqi9pkf85f48rexai7qztbdznfp',
  alias: 'LN-BIG 1337',
  message: 'Sign this super secret message'
}));
req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/login/joule \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"signature":"rd1nn7qbnibf58mzaknokqu6eciiqr64gahrzzxy3h8ybdygbun7s86zrms1dedqnh7t4gxz3esqmaqi9pkf85f48rexai7qztbdznfp","alias":"LN-BIG 1337","message":"Sign this super secret message"}'

POST /login/joule

Use WebLN to authenticate user. The message has to be obtained using GET /login/joule

Body parameter

{
  "signature": "rd1nn7qbnibf58mzaknokqu6eciiqr64gahrzzxy3h8ybdygbun7s86zrms1dedqnh7t4gxz3esqmaqi9pkf85f48rexai7qztbdznfp",
  "alias": "LN-BIG 1337",
  "message": "Sign this super secret message"
}

Parameters

Name In Type Required Description
body body object true none
» message body string true Message signed by the wallet private key, who is obtained using GET /login/joule
» signature body string true Signature created by the wallet
» alias body string false Node alias if avalaible

Example responses

200 Response

{
  "account_type": "joule",
  "linkingpublickey": "02b21cc4667e2d5e14920013d187d2af8c3ccfd32a310f63c7767cf8564f126357",
  "balance": 1337,
  "username": "LN-BIG 1337"
}

Responses

Status Meaning Description Schema
200 OK Sucessfuly logged user. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» username string true none Username default to node alias
» balance string true none User balance
» linkingpublickey string true none Pubkey of the node
» account_type string true none Account type

Response Headers

Status Header Type Format Description
200 Set-Cookie string none

WebLN request Auth

Code samples

import requests

url = "https://api.lnmarkets.com/v1/login/joule"

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/login/joule",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/login/joule \
  --header 'Accept: application/json'

GET /login/joule

Generates a message that user can sign with POST /login/joule

Example responses

200 Response

{
  "message": "I am signing this message to login on LN Markets : 09d9bc06786d37eae6b60b537475d83d6b97177af22a74160a1fc3b0721f051e"
}

Responses

Status Meaning Description Schema
200 OK Message generated Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» message string false none The message contain a fixed part : "I am signing this message to login on LN Markets"
and a variable one who is a 64 char hex string, the variable one is used to identify which session should be authentificated

Futures

Interactions with the futures market and retrive your positions

Create

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures"

payload = {
    "type": "l",
    "side": "b",
    "price": 10000,
    "stoploss": 9000,
    "takeprofit": 11000,
    "quantity": 100,
    "leverage": 50
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  type: 'l',
  side: 'b',
  price: 10000,
  stoploss: 9000,
  takeprofit: 11000,
  quantity: 100,
  leverage: 50
}));
req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/futures \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Content-Type: application/json' \
  --data '{"type":"l","side":"b","price":10000,"stoploss":9000,"takeprofit":11000,"quantity":100,"leverage":50}'

POST /futures

Send the order form parameters to add a new position in database. If type="l", the property price must be included in the request to know when the position 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 choosed

Body parameter

{
  "type": "l",
  "side": "b",
  "price": 10000,
  "stoploss": 9000,
  "takeprofit": 11000,
  "quantity": 100,
  "leverage": 50
}

Parameters

Name In Type Required Description
body body object true Payload with all the information needed to setup a new position.
» type body string true Type of the order (Market or Limit)
» side body string true Side of the order (Buy or Sell)
» margin body integer(int32) false Margin or quantity should be filled
» leverage body number(double) true Leverage of the order
» quantity body number false Quantity or margin should be filled
» takeprofit body number(double) false Takeprofit level
» stoploss body number(double) false Stoploss level
» price body number(double) false Required when using a limit order

Detailed descriptions

body: Payload with all the information needed to setup a new position.

Enumerated Values

Parameter Value
» type l
» type m
» side b
» side s

Example responses

200 Response

{
  "pid": "249dc818-f8a5-4713-a3a3-8fe85f2e8969",
  "id": 666,
  "type": "m",
  "takeprofit_wi": "running",
  "takeprofit": 13337,
  "stoploss_wi": "running",
  "stoploss": 1337,
  "side": "s",
  "quantity": 42,
  "price": 8888,
  "pl": -13640,
  "market_wi": "filled",
  "market_filled_ts": "020-09-15T10:50:40.332Z",
  "margin_wi": "running",
  "margin": 424242,
  "liquidation": 1000,
  "leverage": 50,
  "creation_ts": "020-09-15T10:50:40.332Z"
}

Responses

Status Meaning Description Schema
200 OK Position sucessfully created. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» pid string false none UUID of the position
» id string false none Position ID to be deprecated
» type string false none Position type [l,m]
» side string false none Side of the position [s,b]
» price string false none Entry price of the position
» quantity string false none Quantity of the position
» margin string false none Margin used for the position creation
» leverage string false none Leverage of the position
» liquidation string false none Liquidation level when the position will be closed
» market_filled_ts string(date-time)¦null false none When the order was filled
» market_wi string false none Market working indicator [filled, running, closed, canceled]
» pl string false none PL of the position
» margin_wi string false none Margin working indicator [filled, running, closed, canceled]
» stoploss string¦null false none stoploss level
» stoploss_wi string¦null false none Stoploss working indicator [filled, running, closed, canceled]
» takeprofit string¦null false none Takeprofit level
» takeprofit_wi string¦null false none Takeprofit working indicator [filled, running, closed, canceled]
» creation_ts string(date-time) false none When the position was created

Update

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures"

payload = {
    "pid": "b87eef8a-52ab-2fea-1adc-c41fba870b0f",
    "type": "takeprofit",
    "value": 13290.5
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("PUT", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "PUT",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  pid: 'b87eef8a-52ab-2fea-1adc-c41fba870b0f',
  type: 'takeprofit',
  value: 13290.5
}));
req.end();
curl --request PUT \
  --url https://api.lnmarkets.com/v1/futures \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Content-Type: application/json' \
  --data '{"pid":"b87eef8a-52ab-2fea-1adc-c41fba870b0f","type":"takeprofit","value":13290.5}'

PUT /futures

Allows user to modify stoploss or takeprofit parameters of an existing position.

Body parameter

{
  "pid": "b87eef8a-52ab-2fea-1adc-c41fba870b0f",
  "type": "takeprofit",
  "value": 13290.5
}

Parameters

Name In Type Required Description
body body object true none
» pid body string true none
» type body string true none
» value body number true none

Enumerated Values

Parameter Value
» type takeprofit
» type stoploss

Example responses

200 Response

{
  "pid": "b87eef8a-52ab-2fea-1adc-c41fba870b0f"
}

Responses

Status Meaning Description Schema
200 OK Says whether or not the position was updated. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» pid string false none Position id

Close

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures"

querystring = {"pid":"a2ca6172-1078-463d-ae3f-8733f36a9b0e"}

headers = {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("DELETE", url, headers=headers, params=querystring)

print(response.text)
const http = require("https");

const options = {
  "method": "DELETE",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures?pid=a2ca6172-1078-463d-ae3f-8733f36a9b0e",
  "headers": {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request DELETE \
  --url 'https://api.lnmarkets.com/v1/futures?pid=a2ca6172-1078-463d-ae3f-8733f36a9b0e' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}'

DELETE /futures

Close the user position, the PL will be calculated against the current bid or offer depending on the side of the position

Parameters

Name In Type Required Description
pid query string true ID of the position to close.

Example responses

200 Response

{
  "pid": "a2ca6172-1078-463d-ae3f-8733f36a9b0e",
  "exit_price": 2000,
  "closed_ts": "020-10-15T10:50:40.332Z",
  "closed": true,
  "pl": 1337
}

Responses

Status Meaning Description Schema
200 OK Position is closed Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» closed boolean false none Is position closed
» closed_ts string(date-time)¦null false none Position closed ts
» exit_price string false none At which price the position was closed
» pid string false none Position id
» pl integer false none PL of the position

History

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures"

querystring = {"type":"open"}

headers = {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures?type=open",
  "headers": {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url 'https://api.lnmarkets.com/v1/futures?type=open' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}'

GET /futures

Fetch users positions

Parameters

Name In Type Required Description
type query string true Choose wich kind of positions you need to fetch
from query integer(int64) false Starting timestamp (in ms) (only used for closed positions)
to query integer(int64) false Ending timestamp (in ms) (only used for closed positions)
limit query integer(int64) false Number of rows (only used for closed positions)

Enumerated Values

Parameter Value
type open
type running
type closed

Example responses

200 Response

{
  "positions": [
    {
      "pid": "249dc818-f8a5-4713-a3a3-8fe85f2e8969",
      "id": 666,
      "type": "m",
      "takeprofit_wi": "canceled",
      "takeprofit": 13337,
      "stoploss_wi": "canceled",
      "stoploss": 1337,
      "sign": -1,
      "side": "s",
      "quantity": 42,
      "price": 8888,
      "pl": -13640,
      "market_wi": "filled",
      "market_filled_ts": 1630568137340,
      "margin_wi": "closed",
      "margin": 424242,
      "liquidation": 1000,
      "leverage": 50,
      "exit_price": 2000,
      "creation_ts": 1630568137340,
      "closed_ts": 1630568137340,
      "closed": false,
      "canceled": true,
      "sum_carry_fees": 4242
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Positions history sucessfully fetched. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» pid string(uuid) false none id of the position
» type string false none Position type [l,m]
» side string false none Side of the position [s,b]
» pl number false none PL of the position
» price number false none Entry price of the position
» quantity number false none Quantity of the position
» leverage number false none Leverage of the position
» liquidation number false none Liquidation level when the position will be closed
» margin number false none Margin used for the position creation
» margin_wi string false none Margin working indicator [filled, running, closed, canceled]
» market_filled_ts number¦null false none When the order was filled
» market_wi string false none Market working indicator [filled, running, closed, canceled]
» canceled boolean false none Is the position canceled
» closed boolean false none Is the position closed
» closed_ts number¦null false none When the position was closed
» creation_ts number(date-time) false none When the position was created
» exit_price number¦null false none At which price the position was closed
» stoploss number¦null false none stoploss level
» stoploss_wi string¦null false none Stoploss working indicator [filled, running, closed, canceled]
» takeprofit string¦null false none Takeprofit level
» takeprofit_wi string¦null false none Takeprofit working indicator [filled, running, closed, canceled]
» sum_carry_fees integer false none Sum of the positions carry fees

Futures index history

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/history/index"

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/history/index",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/futures/history/index \
  --header 'Accept: application/json'

GET /futures/history/index

Retrieves index history at most 1000 entries between two given timestamps.

Parameters

Name In Type Required Description
from query integer(int64) false Starting timestamp (in ms).
to query integer(int64) false Ending timestamp (in ms).
limit query integer(int64) false Number of rows

Example responses

200 Response

{
  "data": [
    {
      "time": 1605633250615990,
      "index": 15853
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Futures index history Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» time integer(int64) false none Timestamp at which the data was recorded (in µs)
» index number false none Index value at that time

Futures bid and offer history

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/history/bid-offer"

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/history/bid-offer",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/futures/history/bid-offer \
  --header 'Accept: application/json'

GET /futures/history/bid-offer

Retrieves bid and offer at most 1000 entries between two given timestamps.

Parameters

Name In Type Required Description
from query integer(int64) false Starting timestamp (in ms).
to query integer(int64) false Ending timestamp (in ms).
limit query integer(int64) false Number of rows

Example responses

200 Response

{
  "data": [
    {
      "time": 1605633250615990,
      "bid": 15853,
      "offer": 15885
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Futures bid offer history Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» time integer(int64) false none Timestamp at which the data was recorded (in µs)
» bid number false none Bid value at that time
» offer number false none Offer value at that time

Futures fixing history

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/history/fixing"

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/history/fixing",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/futures/history/fixing \
  --header 'Accept: application/json'

GET /futures/history/fixing

Retrieves at most 1000 entries between two given timestamps

Parameters

Name In Type Required Description
from query integer(int64) false Starting timestamp (in ms).
to query integer(int64) false Ending timestamp (in ms).
limit query integer(int64) false Number of rows

Example responses

200 Response

{
  "data": [
    {
      "ts": 1605633250615990,
      "id": "46b6cd74-d91d-4f25-8a55-1cde32a9341c",
      "fixing_price": 15885,
      "fee_bp_value": 10
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Fixing history Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» ts integer(int64) false none Timestamp in ms whent the fixing occured
» id number false none Fixing uuid
» fixing_price number false none Fixing price
» fee_bp_value number false none BP value of fees

Cancel

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/cancel"

payload = {"pid": "b87eef8a-52ab-2fea-1adc-c41fba870b0f"}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/cancel",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({pid: 'b87eef8a-52ab-2fea-1adc-c41fba870b0f'}));
req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/futures/cancel \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Content-Type: application/json' \
  --data '{"pid":"b87eef8a-52ab-2fea-1adc-c41fba870b0f"}'

POST /futures/cancel

Cancel the position linked to the given pid.Only works on positions that are not currently filled.

Body parameter

{
  "pid": "b87eef8a-52ab-2fea-1adc-c41fba870b0f"
}

Parameters

Name In Type Required Description
body body object true Payload containing the position id that will be cancelled.
» pid body string true Position ID

Example responses

200 Response

{
  "pid": "b87eef8a-52ab-2fea-1adc-c41fba870b0f",
  "canceled": true,
  "closed_ts": "020-11-15T10:50:40.332Z"
}

Responses

Status Meaning Description Schema
200 OK Position is canceled Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» canceled boolean false none Canncel success
» closed_ts string(date-time) false none When the position was canceled
» pid string false none Position ID

Cash-in

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/cash-in"

payload = {
    "amount": 1000,
    "pid": "99c470e1-2e03-4486-a37f-1255e08178b1"
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/cash-in",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({amount: 1000, pid: '99c470e1-2e03-4486-a37f-1255e08178b1'}));
req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/futures/cash-in \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Content-Type: application/json' \
  --data '{"amount":1000,"pid":"99c470e1-2e03-4486-a37f-1255e08178b1"}'

POST /futures/cash-in

Retrieves part of one running position's PL.

Body parameter

{
  "amount": 1000,
  "pid": "99c470e1-2e03-4486-a37f-1255e08178b1"
}

Parameters

Name In Type Required Description
body body object true Payload with data relative to the process.
» amount body integer(int64) true Amount of PL to cash-in (in sats)
» pid body string true Position ID from which to retrieve PL

Detailed descriptions

body: Payload with data relative to the process.

Example responses

200 Response

{
  "pid": "249dc818-f8a5-4713-a3a3-8fe85f2e8969",
  "id": 666,
  "type": "m",
  "takeprofit_wi": "running",
  "takeprofit": 13337,
  "stoploss_wi": "running",
  "stoploss": 1337,
  "side": "s",
  "quantity": 42,
  "price": 8888,
  "pl": -13640,
  "market_wi": "filled",
  "market_filled_ts": "020-09-15T10:50:40.332Z",
  "margin_wi": "running",
  "margin": 424242,
  "liquidation": 1000,
  "leverage": 50,
  "creation_ts": "020-09-15T10:50:40.332Z"
}

Responses

Status Meaning Description Schema
200 OK Cash-in successfully retrieved and new position informations are sent back. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» pid string false none UUID of the position
» id string false none Position ID to be deprecated
» type string false none Position type [l,m]
» side string false none Side of the position [s,b]
» price string false none Entry price of the position
» quantity string false none Quantity of the position
» margin string false none Margin used for the position creation
» leverage string false none Leverage of the position
» liquidation string false none Liquidation level when the position will be closed
» market_filled_ts string(date-time)¦null false none When the order was filled
» market_wi string false none Market working indicator [filled, running, closed, canceled]
» pl string false none PL of the position
» margin_wi string false none Margin working indicator [filled, running, closed, canceled]
» stoploss string¦null false none stoploss level
» stoploss_wi string¦null false none Stoploss working indicator [filled, running, closed, canceled]
» takeprofit string¦null false none Takeprofit level
» takeprofit_wi string¦null false none Takeprofit working indicator [filled, running, closed, canceled]
» creation_ts string(date-time) false none When the position was created

Add margin

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/add-margin"

payload = {
    "amount": 1000,
    "pid": "99c470e1-2e03-4486-a37f-1255e08178b1"
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/add-margin",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({amount: 1000, pid: '99c470e1-2e03-4486-a37f-1255e08178b1'}));
req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/futures/add-margin \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Content-Type: application/json' \
  --data '{"amount":1000,"pid":"99c470e1-2e03-4486-a37f-1255e08178b1"}'

POST /futures/add-margin

Add margin to a running position.

Body parameter

{
  "amount": 1000,
  "pid": "99c470e1-2e03-4486-a37f-1255e08178b1"
}

Parameters

Name In Type Required Description
body body object true Payload with data relative to the process.
» amount body integer(int64) true Amount of margin to add (in sats)
» pid body string true Position ID from which to retrieve PL

Detailed descriptions

body: Payload with data relative to the process.

Example responses

200 Response

{
  "pid": "249dc818-f8a5-4713-a3a3-8fe85f2e8969",
  "id": 666,
  "type": "m",
  "takeprofit_wi": "running",
  "takeprofit": 13337,
  "stoploss_wi": "running",
  "stoploss": 1337,
  "side": "s",
  "quantity": 42,
  "price": 8888,
  "pl": -13640,
  "market_wi": "filled",
  "market_filled_ts": "020-09-15T10:50:40.332Z",
  "margin_wi": "running",
  "margin": 424242,
  "liquidation": 1000,
  "leverage": 50,
  "creation_ts": "020-09-15T10:50:40.332Z"
}

Responses

Status Meaning Description Schema
200 OK Margin successfully added and new position informations are sent back. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» pid string false none UUID of the position
» id string false none Position ID to be deprecated
» type string false none Position type [l,m]
» side string false none Side of the position [s,b]
» price string false none Entry price of the position
» quantity string false none Quantity of the position
» margin string false none Margin used for the position creation
» leverage string false none Leverage of the position
» liquidation string false none Liquidation level when the position will be closed
» market_filled_ts string(date-time)¦null false none When the order was filled
» market_wi string false none Market working indicator [filled, running, closed, canceled]
» pl string false none PL of the position
» margin_wi string false none Margin working indicator [filled, running, closed, canceled]
» stoploss string¦null false none stoploss level
» stoploss_wi string¦null false none Stoploss working indicator [filled, running, closed, canceled]
» takeprofit string¦null false none Takeprofit level
» takeprofit_wi string¦null false none Takeprofit working indicator [filled, running, closed, canceled]
» creation_ts string(date-time) false none When the position was created

Close-all

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/all/close"

headers = {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("DELETE", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "DELETE",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/all/close",
  "headers": {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request DELETE \
  --url https://api.lnmarkets.com/v1/futures/all/close \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}'

DELETE /futures/all/close

Close every user position. The PL will be calculated against the current bid or offer depending on the side of the position.

Example responses

200 Response

{
  "data": [
    {
      "pid": "a2ca6172-1078-463d-ae3f-8733f36a9b0e",
      "exit_price": 2000,
      "closed_ts": "020-10-15T10:50:40.332Z",
      "closed": true,
      "pl": 1337
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Every position has been successfully closed Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» closed boolean false none Is position closed
» closed_ts string(date-time)¦null false none Position closed ts
» exit_price string false none At which price the position was closed
» pid string false none Position id
» pl integer false none PL of the position

Cancel-all

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/all/cancel"

headers = {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("DELETE", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "DELETE",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/all/cancel",
  "headers": {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request DELETE \
  --url https://api.lnmarkets.com/v1/futures/all/cancel \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}'

DELETE /futures/all/cancel

Cancel all open positions

Example responses

200 Response

{
  "data": [
    {
      "pid": "a2ca6172-1078-463d-ae3f-8733f36a9b0e",
      "canceled_ts": "020-10-15T10:50:40.332Z",
      "canceled": true,
      "margin": 1337
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Array with canceled positions Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» canceled boolean false none Is position canceled
» closed_ts string(date-time)¦null false none Position canceled ts
» pid string false none Position id

Futures carry fees history

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/carry-fees"

headers = {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/carry-fees",
  "headers": {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/futures/carry-fees \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}'

GET /futures/carry-fees

Retrieves carry fees for user

Parameters

Name In Type Required Description
from query integer(int64) false Starting timestamp (in ms).
to query integer(int64) false Ending timestamp (in ms).
limit query integer(int64) false Number of rows

Example responses

200 Response

{
  "data": [
    {
      "fixing": "fc342986-f59d-43f7-937b-0dcaa74b5f20",
      "index": 1337
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Carry fees event of the position Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» ts integer(int64) false none Timestamp in ms whent the fixing occured
» pid string(uuid) false none Position id
» fixing string(uuid) false none Fixing uuid
» fees number false none Fees that were taken from the position

User

You can retrieve your user data and modify it

Informations

Code samples

import requests

url = "https://api.lnmarkets.com/v1/user"

headers = {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/user",
  "headers": {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/user \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}'

GET /user

Get the user account Information

Example responses

200 Response

{
  "uid": "d068f829-26e6-4743-b10d-ebb5a83b3624",
  "balance": 361086,
  "account_type": "Joule",
  "username": "Testnet-node",
  "linkingpublickey": "035555cbdd2b5642bbd196b31df477fad20125ae99119fd5ffb1d42c7f4811dd3a",
  "show_username": false,
  "show_leaderboard": true
}

Responses

Status Meaning Description Schema
200 OK User information Inline
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» uid string false none User's UUID
» balance string false none User current balance (avalaible)
» username string false none Username
» account_type string false none One of ['lnurl', 'credentials', 'joule']
» linkingpublickey string false none Public key used for lnurl or joule account
» show_leaderboard boolean false none Show the user PL in the leaderboard
» show_username boolean false none Show the username on LN Marktes public data, if false show 'Anonymous'

Update user

Code samples

import requests

url = "https://api.lnmarkets.com/v1/user"

payload = {
    "show_username": False,
    "show_leaderboard": True,
    "username": "Cryptoking"
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("PUT", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "PUT",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/user",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({show_username: false, show_leaderboard: true, username: 'Cryptoking'}));
req.end();
curl --request PUT \
  --url https://api.lnmarkets.com/v1/user \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Content-Type: application/json' \
  --data '{"show_username":false,"show_leaderboard":true,"username":"Cryptoking"}'

PUT /user

Modifies account parameters

Body parameter

{
  "show_username": false,
  "show_leaderboard": true,
  "username": "Cryptoking"
}

Parameters

Name In Type Required Description
body body object true none
» show_leaderboard body boolean false Show the user PL in the leaderboard
» show_username body boolean false Show the username on LN Marktes public data, if false show 'Anonymous'
» username body string false Username displayed on LN Markets public data

Example responses

200 Response

{
  "uid": "d068f829-26e6-4743-b10d-ebb5a83b3624",
  "balance": 361086,
  "account_type": "Joule",
  "username": "Testnet-node",
  "linkingpublickey": "035555cbdd2b5642bbd196b31df477fad20125ae99119fd5ffb1d42c7f4811dd3a",
  "show_username": false,
  "show_leaderboard": true
}

Responses

Status Meaning Description Schema
200 OK User information Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» uid string false none User's UUID
» balance string false none User current balance (avalaible)
» username string false none Username
» account_type string false none One of ['lnurl', 'credentials', 'joule']
» linkingpublickey string false none Public key used for lnurl or joule account
» show_leaderboard boolean false none Show the user PL in the leaderboard
» show_username boolean false none Show the username on LN Marktes public data, if false show 'Anonymous'

List

Code samples

import requests

url = "https://api.lnmarkets.com/v1/user/jwt"

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/user/jwt",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/user/jwt \
  --header 'Accept: application/json'

GET /user/jwt

Retrieves the list of active JSON Web Token user currently holds.

Example responses

200 Response

[
  {
    "aud": [
      "withdraw",
      "deposit"
    ],
    "exp": "020-09-15T10:50:40.332Z",
    "iat": "020-09-15T10:50:40.332Z",
    "jti": "ckea35me20019r8u36374585f",
    "revoked": false
  }
]

Responses

Status Meaning Description Schema
200 OK Token list retrieved. Inline
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» aud [string] false none Scopes of the token
» exp string(date-time) false none Expiration of the token
» iat string(date-time) false none When the token was issued
» jti string false none Unique id of the token
» revoked boolean false none Is it revoked or not

Revoke

Code samples

import requests

url = "https://api.lnmarkets.com/v1/user/jwt"

response = requests.request("DELETE", url)

print(response.text)
const http = require("https");

const options = {
  "method": "DELETE",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/user/jwt",
  "headers": {}
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request DELETE \
  --url https://api.lnmarkets.com/v1/user/jwt

DELETE /user/jwt

Using the jti parameter, identifies and revoke usage of a given JWT.

Parameters

Name In Type Required Description
jti query string false Token unique identifier.

Responses

Status Meaning Description Schema
200 OK Token successfuly revoked. None
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Generate

Code samples

import requests

url = "https://api.lnmarkets.com/v1/user/jwt"

payload = {
    "expiry": 86400,
    "scopes": ["deposit", "withdraw"]
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/user/jwt",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({expiry: 86400, scopes: ['deposit', 'withdraw']}));
req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/user/jwt \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"expiry":86400,"scopes":["deposit","withdraw"]}'

POST /user/jwt

Using the given scopes, allow the token bearer to get access to different parts of the public API.

Body parameter

{
  "expiry": 86400,
  "scopes": [
    "deposit",
    "withdraw"
  ]
}

Parameters

Name In Type Required Description
body body object true Scopes of authorization that the token will grant to the bearer.
» scopes body [string] true Scopes of the token
» expiry body integer(int32) true Expiration of the token

Detailed descriptions

body: Scopes of authorization that the token will grant to the bearer.

Enumerated Values

Parameter Value
» scopes deposit
» scopes withdraw
» scopes futures
» scopes user

Example responses

200 Response

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAiLCJpYXQiOjE1OTgwNTg2NDQsInNjb3BlcyI6WyJ3aXRoZHJhdyIsImRlcG9zaXQiXX0.xJ3f5eMeRiN0eSzo3IDviny9B9v_-bLg4t_EWmXFBxc"
}

Responses

Status Meaning Description Schema
200 OK Token successfuly created, its Base64URL encoded signature is returned for future use. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» token string false none JWT

Deposit

Code samples

import requests

url = "https://api.lnmarkets.com/v1/user/deposit"

payload = {
    "amount": 1000,
    "unit": "sat"
}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/user/deposit",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({amount: 1000, unit: 'sat'}));
req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/user/deposit \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Content-Type: application/json' \
  --data '{"amount":1000,"unit":"sat"}'

POST /user/deposit

Add fund to your LN Markets balance

Body parameter

{
  "amount": 1000,
  "unit": "sat"
}

Parameters

Name In Type Required Description
body body object true Payload that contains all informations to initialize a new deposit.
» amount body integer true Amount of sat to deposit on the account
» unit body string false Should be sat by default

Detailed descriptions

body: Payload that contains all informations to initialize a new deposit.

Example responses

200 Response

{
  "paymentRequest": "lntb100u1p0jrfz0pp5q0ntrkf052dvep8w6vf0z77rek3fz8xm6c2yau4zhy7f4mzauqgsdzcf3hy6ctjddjhgueqg3jhqmmnd96zqgmxxquryvesvv6z6dehv43z6drpvycj6wfevs6j6dmyxcunxefcxccxxvn9cqzpgxqzpdsp5z40mxcrfqtsxf55u9ju3lvqdw36htsjh4xl2ujrzdff3953fg2yq9qy9qsqv7gfvp0tryme3e8r5xfrpg39j645302fkggps4h5j0aj708lzdgh2dq3pdz6lqazgvkt3wm7qq20vcff46vu5549m3v2d6h0uw3sjacqrkjqcv",
  "expiry": 45
}

Responses

Status Meaning Description Schema
200 OK New deposit entry in database waiting for payment. Using paymentRequest afterwards, user will confirm the deposit and funds will be added to his account. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» paymentRequest string false none Invoice you should pay to add balance to your account
» expiry integer false none When the invoice will expiry

Deposit History

Code samples

import requests

url = "https://api.lnmarkets.com/v1/user/deposit"

headers = {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/user/deposit",
  "headers": {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/user/deposit \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}'

GET /user/deposit

Get deposit history

Parameters

Name In Type Required Description
from query integer false Start of the time interval (UNIX UTC timestamp)
to query integer false End of the time interval (UNIX UTC timestamp)
limit query integer false number of transactions to fetch

Example responses

200 Response

{
  "transaction": [
    {
      "id": "269157f3-d4a1-4493-afcb-5e8fdaa49288",
      "amount": 99400,
      "creation_ts": "020-09-15T10:50:40.332Z",
      "success": true,
      "payment_hash": "33f45c13c7ddcae46c6732414552893ca599f9399c62ffc2cfae209e8b17c5c3",
      "sucess_ts": "020-09-15T10:50:40.332Z"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK History sucessfully pulled. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» transaction [object] false none none
»» id string false none Deposit ID in case of deposit
»» amount integer false none Amount in sat
»» creation_ts string(date-time) false none When the transaction was initiated
»» payment_hash string false none none
»» success boolean false none none
»» sucess_ts string(date-time)¦null false none none

Withdraw via invoice

Code samples

import requests

url = "https://api.lnmarkets.com/v1/user/withdraw"

payload = {"invoice": "lntb100u1p0jr0ykpp5ldx3un8ym6z0uwjxd083mp2rcr04d2dv0fkx729ajs62pq9pfjqqdql23jhxapdwa5hg6rywfshwttjda6hgegcqzpgxq92fjuqsp5m6q0fzynu2qr624mzjc285duurhccmkfg94mcdctc0p9s7qkrq8q9qy9qsqp862cjznpey5r76e7amhlpmhwn2c7xvke59srhv0xf75m4ksjm4hzn8y9xy0zs5ec6gxmsr8gj4q23w8ped32llscjcneyjz2afeapqpu4gamz"}
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/user/withdraw",
  "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  invoice: 'lntb100u1p0jr0ykpp5ldx3un8ym6z0uwjxd083mp2rcr04d2dv0fkx729ajs62pq9pfjqqdql23jhxapdwa5hg6rywfshwttjda6hgegcqzpgxq92fjuqsp5m6q0fzynu2qr624mzjc285duurhccmkfg94mcdctc0p9s7qkrq8q9qy9qsqp862cjznpey5r76e7amhlpmhwn2c7xvke59srhv0xf75m4ksjm4hzn8y9xy0zs5ec6gxmsr8gj4q23w8ped32llscjcneyjz2afeapqpu4gamz'
}));
req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/user/withdraw \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}' \
  --header 'Content-Type: application/json' \
  --data '{"invoice":"lntb100u1p0jr0ykpp5ldx3un8ym6z0uwjxd083mp2rcr04d2dv0fkx729ajs62pq9pfjqqdql23jhxapdwa5hg6rywfshwttjda6hgegcqzpgxq92fjuqsp5m6q0fzynu2qr624mzjc285duurhccmkfg94mcdctc0p9s7qkrq8q9qy9qsqp862cjznpey5r76e7amhlpmhwn2c7xvke59srhv0xf75m4ksjm4hzn8y9xy0zs5ec6gxmsr8gj4q23w8ped32llscjcneyjz2afeapqpu4gamz"}'

POST /user/withdraw

Withdraw from LN Markets with a Lightning Invoice

Body parameter

{
  "invoice": "lntb100u1p0jr0ykpp5ldx3un8ym6z0uwjxd083mp2rcr04d2dv0fkx729ajs62pq9pfjqqdql23jhxapdwa5hg6rywfshwttjda6hgegcqzpgxq92fjuqsp5m6q0fzynu2qr624mzjc285duurhccmkfg94mcdctc0p9s7qkrq8q9qy9qsqp862cjznpey5r76e7amhlpmhwn2c7xvke59srhv0xf75m4ksjm4hzn8y9xy0zs5ec6gxmsr8gj4q23w8ped32llscjcneyjz2afeapqpu4gamz"
}

Parameters

Name In Type Required Description
body body object true Payload that countains all informations to initiate a new withdraw.
» invoice body string true Bolt 11 invoice with the same amount as the request withdraw amount

Example responses

200 Response

{
  "amount": 1000,
  "paymentsecret": "1b84c9852e929f99700b6cbabc4ca9d1593afc3736938b348c4d3d143e418bd4",
  "id": "3fcbd8b7-c35b-4e83-87bc-111d5bd186b7",
  "paymenthash": "fb4d1e4ce4de84fe3a466bcf1d8543c0df56a9ac7a6c6f28bd9434a080a14c80"
}

Responses

Status Meaning Description Schema
200 OK Funds are removed from user account and added to user wallet. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» amount integer false none Amount withdrawnd
» fees integer false none Amount of fees payed
» paymentsecret string false none Payment secret of the settled invoice
» id string false none Withdraw ID
» paymenthash string false none Payment hash for the settled invoice

Withdraw History

Code samples

import requests

url = "https://api.lnmarkets.com/v1/user/withdraw"

headers = {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/user/withdraw",
  "headers": {
    "Accept": "application/json",
    "Authorization": "Bearer {access-token}"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/user/withdraw \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {access-token}'

GET /user/withdraw

Ge withdraw history

Parameters

Name In Type Required Description
from query integer false Start of the time interval (UNIX UTC timestamp)
to query integer false End of the time interval (UNIX UTC timestamp)
limit query integer false number of transactions to fetch

Example responses

200 Response

{
  "transaction": [
    {
      "id": "269157f3-d4a1-4493-afcb-5e8fdaa49288",
      "amount": 99400,
      "creation_ts": "020-09-15T10:50:40.332Z",
      "success": true,
      "payment_hash": "33f45c13c7ddcae46c6732414552893ca599f9399c62ffc2cfae209e8b17c5c3",
      "sucess_ts": "020-09-15T10:50:40.332Z"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK History sucessfully pulled. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» transaction [object] false none none
»» id string false none Withdraw ID in case of withdraw
»» amount integer false none Amount in sat
»» creation_ts string(date-time) false none When the transaction was initiated
»» fail boolean false none Is the transaction failed
»» fail_reason string¦null false none none
»» fail_ts string(date-time)¦null false none When did the withdraw failed ?
»» payment_hash string false none none
»» success boolean false none none
»» sucess_ts string(date-time)¦null false none none

State

LN Markets state with data about our node and api availability

Leaderboard

Code samples

import requests

url = "https://api.lnmarkets.com/v1/futures/leaderboard"

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/futures/leaderboard",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/futures/leaderboard \
  --header 'Accept: application/json'

GET /futures/leaderboard

Queries the database to get the 10 users with the biggest posititve PL

Example responses

200 Response

[
  {
    "username": "Bob",
    "pl": 4242424242
  },
  {
    "username": "Jean-Kevin",
    "pl": 3491941
  },
  {
    "username": "Roger",
    "pl": 24013441
  },
  {
    "username": "Laura",
    "pl": 23126094
  },
  {
    "username": "Marcus",
    "pl": 1414019
  },
  {
    "username": "Charles",
    "pl": 242918
  },
  {
    "username": "Antoine",
    "pl": 99999
  },
  {
    "username": "XXxRoBeRtLeBgDu24xXX",
    "pl": 61491
  },
  {
    "username": "CRYPTOKING",
    "pl": 10000
  },
  {
    "username": "HEY",
    "pl": 3
  }
]

Responses

Status Meaning Description Schema
200 OK Leaderboard successfully fetched Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» username string false none Username or 'Anonymous' if the Leaderboard view is disabled
» pl integer false none Sum of every profits and losses of the user

API

Code samples

import requests

url = "https://api.lnmarkets.com/v1/state"

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/state",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/state \
  --header 'Accept: application/json'

GET /state

Shows informations about api.

Example responses

200 Response

{
  "ts": 1600244845097,
  "version": {
    "api": "74958cef7d4416dfa7f2c13fd23cd4aa7b469047",
    "soec": "31a4964e0ab4c77e7235ce5a0b458ba32dd8ace8"
  },
  "withdraw": true,
  "newPosition": true,
  "accountCreation": true
}

Responses

Status Meaning Description Schema
200 OK The API is online. Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» ts integer(int64) false none Timestamp reported by the API
» version object false none none
»» api string false none API version hash
»» spec string false none Open API version hash
» withdraw boolean false none Are withdraw enabled ?
» newposition boolean false none Are new position enabled ?
» accountCreation boolean false none Are account creation enabled ?

Node

Code samples

import requests

url = "https://api.lnmarkets.com/v1/state/node"

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/state/node",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/state/node \
  --header 'Accept: application/json'

GET /state/node

Shows informations about the lightning node.

Example responses

200 Response

{
  "version": "0.11.0-beta commit=v0.11.0-beta'",
  "alias": "LN Markets",
  "pubkey": "03bae2db4b57738c1ec1ffa1c5e5a4423968cc592b3b39cddf7d495e72919d6431",
  "blockHeigth": 1835008,
  "remoteBalance": 266903254,
  "example": "localBalance",
  "channels": 1337,
  "peers": 42,
  "onionUri": "03bae2db4b57738c1ec1ffa1c5e5a4423968cc592b3b39cddf7d495e72919d6431@3pv4ci27cnahbztwlqtbez36rblecanoyxthrtjvxpk3en2y7dxfr3id.onion:9735",
  "uri": "03bae2db4b57738c1ec1ffa1c5e5a4423968cc592b3b39cddf7d495e72919d6431@34.192.102.161:9735"
}

Responses

Status Meaning Description Schema
200 OK The Node is online. Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» version string false none LND version
» alias string false none Node Alias
» pubkey string false none Node pubkey
» uri string false none Node URI
» onionUri string false none Node URI on tor
» peers integer(int64) false none Number of peers
» channels integer(int64) false none Number of channels
» localBalance integer(int64) false none Node local balance
» remoteBalance integer(int64) false none Node remote balance
» blockHeigth integer(int64) false none Node block heigth

Announcements

Code samples

import requests

url = "https://api.lnmarkets.com/v1/state/announcements"

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/state/announcements",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url https://api.lnmarkets.com/v1/state/announcements \
  --header 'Accept: application/json'

GET /state/announcements

Get the list of LN Markets announcements

Example responses

200 Response

[
  {
    "title": "Good news everyone !",
    "text": "Bitcoin is the world money now !",
    "creation_ts": 1607076175239
  },
  {
    "title": "Bad news everyone !",
    "text": "We have too much sats",
    "creation_ts": 1607019462532
  }
]

Responses

Status Meaning Description Schema
200 OK Announcements successfully fetched Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» title string false none none
» text string false none none
» ts integer false none none

LNURL

Interaction with the lightning network using the LNURL procotocol LNURL enable simple auth, withdraw and pay UX / UI

Auth Verify

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/auth"

querystring = {"tag":"login","k1":"kyNVmR6HDtAW2aplYk6XmmpDrIhvzzq6","sig":"qep5sAqwleQS27UdKLGNsCBTWB4soS45us9vJAbk1hMEdCAXoeB6IESi3Nz7SXJM","key":"Yc4h1Z5BZVmgmVQfIbdPWRVj9kHAo3uf","hmac":"kuSHSXXDiP4qofiL2LGelesLLlRXUCJd"}

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/auth?tag=login&k1=kyNVmR6HDtAW2aplYk6XmmpDrIhvzzq6&sig=qep5sAqwleQS27UdKLGNsCBTWB4soS45us9vJAbk1hMEdCAXoeB6IESi3Nz7SXJM&key=Yc4h1Z5BZVmgmVQfIbdPWRVj9kHAo3uf&hmac=kuSHSXXDiP4qofiL2LGelesLLlRXUCJd",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url 'https://api.lnmarkets.com/v1/lnurl/auth?tag=login&k1=kyNVmR6HDtAW2aplYk6XmmpDrIhvzzq6&sig=qep5sAqwleQS27UdKLGNsCBTWB4soS45us9vJAbk1hMEdCAXoeB6IESi3Nz7SXJM&key=Yc4h1Z5BZVmgmVQfIbdPWRVj9kHAo3uf&hmac=kuSHSXXDiP4qofiL2LGelesLLlRXUCJd' \
  --header 'Accept: application/json'

GET /lnurl/auth

Verify the public key with the signature and the k1 to create a account or connect into a existing account. If JWT is set to true, a JWT will be returned with by default all scopes and an expiry of 1h, they can be changed by setting the query paramater expiry or scopes like POST /user/jwt. Else the connected state will be push over websocketsto the client.

Parameters

Name In Type Required Description
tag query string true LNURL type.
k1 query string true Hex encoded 32 bytes of challenge which is going to be signed by user private key.
sig query string true Signature generated by the lightning wallet.
key query string true Public key of the lightning wallet.
hmac query string true HMAC signature used to secure LNURL.
t query string false Timestamp.
jwt query boolean false Request will responsd with a JWT token instead of pushing auth state to websocket
expiry query integer(int32) false JWT expiration, default to 3600
scopes query string false Scope of the jwt

Enumerated Values

Parameter Value
tag login

Example responses

200 Response

{
  "status": "OK",
  "event": "LOGGEDIN"
}

Responses

Status Meaning Description Schema
200 OK Sucessfuly logged in. Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» status string false none Does the request suceed ?
» event string false none State of the user
» token string false none JWT if asked

Auth Request

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/auth"

headers = {"Accept": "application/json"}

response = requests.request("POST", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/auth",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/lnurl/auth \
  --header 'Accept: application/json'

POST /lnurl/auth

LNURL string used to create an account or connect to a existing account. The user wallet will sign a message using the provided k1 inside the LNURL. You need to have a session cookie on the browser you are using to log in.

Example responses

200 Response

{
  "lnurl": "lnurl1dp68gup69uhkcmmrv9kxsmmnwsarxvpsxqhkcmn4wfkz7cflw3skw0tvdankjm3xdvcn6venvgcrjenpx3nrwdtpxsur2vfsvdjk2dfkxe3kgceexymkgcmrxpjkgc3jvgmrqdnzvvurjwtr89jk2dp4vccrxvmrvvmxzdehxuejv6rdv93n6wpkv56rxcf4xqcxgwfsvsuxget9vymnqcfnv43rgwfjv5ex2cn9vyckgwtyvejrgc3excekyetpx43rvd3nxeskxvm9xqcxvwtpv5mq9uwr0k"
}

Responses

Status Meaning Description Schema
200 OK Bech32 encoded string. Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» lnurl string false none LNURL used by the wallet

Withdraw (3) Final

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/withdraw"

querystring = {"k1":"kyNVmR6HDtAW2aplYk6XmmpDrIhvzzq6","pr":"<invoice>"}

response = requests.request("GET", url, params=querystring)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/withdraw?k1=kyNVmR6HDtAW2aplYk6XmmpDrIhvzzq6&pr=%3Cinvoice%3E",
  "headers": {}
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url 'https://api.lnmarkets.com/v1/lnurl/withdraw?k1=kyNVmR6HDtAW2aplYk6XmmpDrIhvzzq6&pr=%3Cinvoice%3E'

GET /lnurl/withdraw

Use LNURL to withdraw from the user balance.

Parameters

Name In Type Required Description
k1 query string true Random hex string to identify the user Lightning Wallet.
pr query string true Bolt 11 invoice.

Responses

Status Meaning Description Schema
200 OK Sucessfuly withdrawn funds from account None

Withdraw (1) Create

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/withdraw"

headers = {"Accept": "application/json"}

response = requests.request("POST", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/withdraw",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/lnurl/withdraw \
  --header 'Accept: application/json'

POST /lnurl/withdraw

Create a LNURL Withdraw

Example responses

200 Response

{
  "lnurl": "LNURL1DP68GURN8GHJ7UM9WFMXJCM99E3K7MF0V9CXJ0M385EKVCENXC6R2C35XVUKXEFCV5MKVV34X5EKZD3EV56NYD3HXQURZEPEXEJXXEPNXSCRVWFNV9NXZCN9XQ6XYEFHVGCXXCMYXYMNSERXFQ5FNS"
}

Responses

Status Meaning Description Schema
200 OK Return the LNURL Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» lnurl string false none LNURL for the users wallet

Withdraw (2) Request

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/withdraw/request"

querystring = {"signature":"type,string","n":"type,string,minLength,16,maxLength,16","expiry":"1599841538304","uid":"type,string,format,uuid"}

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/withdraw/request?signature=type%2Cstring&n=type%2Cstring%2CminLength%2C16%2CmaxLength%2C16&expiry=1599841538304&uid=type%2Cstring%2Cformat%2Cuuid",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url 'https://api.lnmarkets.com/v1/lnurl/withdraw/request?signature=type%2Cstring&n=type%2Cstring%2CminLength%2C16%2CmaxLength%2C16&expiry=1599841538304&uid=type%2Cstring%2Cformat%2Cuuid' \
  --header 'Accept: application/json'

GET /lnurl/withdraw/request

Ask the Lightning wallet to create an invoice with amount and description.

Parameters

Name In Type Required Description
signature query string true HMAC payload signature.
n query string true Nonce.
expiry query integer true Timestamp when the LNURL is expired.
uid query string(uuid) true User id

Example responses

200 Response

{
  "k1": "31c92c1bd79d2ae5f96a153ceda105cb67888c61bfb76baa1d2505a6bf8a06ca",
  "tag": "withdrawRequest",
  "maxWithdrawable": 1000,
  "minWithdrawable": 1000,
  "defaultDescription": "LN Markets withdraw",
  "callback": "https://api.lnmarkets.com/lnurl/w"
}

Responses

Status Meaning Description Schema
200 OK LNURL withdraw invoice parameter. Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» callback string false none Callback URL used by the wallet
» defaultDescription string false none Invoice default description
» tag string false none Kind of LNURL
» balanceCheck string false none none
» balanceNotify string false none none
» maxWithdrawable integer(int32) false none Max withdrawable amount
» minWithdrawable integer(int32) false none Min withdrawable amount
» k1 string false none Random hex string to identify the user Lightning Wallet.

Withdraw to Lightning Address

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/withdraw/address"

querystring = {"amount":"1000","address":"satoshi@lightning.ovh"}

response = requests.request("GET", url, params=querystring)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/withdraw/address?amount=1000&address=satoshi%40lightning.ovh",
  "headers": {}
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url 'https://api.lnmarkets.com/v1/lnurl/withdraw/address?amount=1000&address=satoshi%40lightning.ovh'

GET /lnurl/withdraw/address

Use Lightning Address to withdraw your sat !

Parameters

Name In Type Required Description
amount query integer true Amount to withdraw in sat
address query string true Lightning Address username@service.org

Responses

Status Meaning Description Schema
200 OK Sucessfuly withdrawn funds from account. None

Pay (1) Create

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/pay"

headers = {"Accept": "application/json"}

response = requests.request("POST", url, headers=headers)

print(response.text)
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/pay",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request POST \
  --url https://api.lnmarkets.com/v1/lnurl/pay \
  --header 'Accept: application/json'

POST /lnurl/pay

Create a LNURL Pay

Example responses

200 Response

{
  "lnurl": "LNURL1DP68GURN8GHJ7UM9WFMXJCM99E3K7MF0V9CXJ0M385EKVCENXC6R2C35XVUKXEFCV5MKVV34X5EKZD3EV56NYD3HXQURZEPEXEJXXEPNXSCRVWFNV9NXZCN9XQ6XYEFHVGCXXCMYXYMNSERXFQ5FNS"
}

Responses

Status Meaning Description Schema
200 OK Return the LNURL Inline
400 Bad Request The request query and / or body does not fit the schema requirements. It can also be raised by parameters leading to unexpected behaviour / results. None
401 Unauthorized Unauthorized None

Response Schema

Status Code 200

Name Type Required Restrictions Description
» lnurl string false none LNURL for the users wallet

Pay (3) Finalize

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/pay"

querystring = {"signature":"type,string","n":"type,string,minLength,16,maxLength,16","amount":"type,integer,minimum,1000000,maximum,1000000000"}

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/pay?signature=type%2Cstring&n=type%2Cstring%2CminLength%2C16%2CmaxLength%2C16&amount=type%2Cinteger%2Cminimum%2C1000000%2Cmaximum%2C1000000000",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url 'https://api.lnmarkets.com/v1/lnurl/pay?signature=type%2Cstring&n=type%2Cstring%2CminLength%2C16%2CmaxLength%2C16&amount=type%2Cinteger%2Cminimum%2C1000000%2Cmaximum%2C1000000000' \
  --header 'Accept: application/json'

GET /lnurl/pay

LNURL Pay

Parameters

Name In Type Required Description
signature query string true HMAC payload signature.
n query string true Nonce
uid query string(uuid) false User id
username query string false Username
expiry query integer false When the lnurl pay is expired
amount query integer true Amount to deposit in msat
nonce query string false An optional parameter used to prevent server response caching
fromnodes query string false An optional parameter with value set to comma separated nodeIds if payer wishes a service to provide payment routes starting from specified LN nodeIds
comment query string false An optional parameter to pass the LN WALLET user's comment to LN SERVICE
proofofpayer query string false An optional ephemeral secp256k1 public key generated by payer, a corresponding private key should be retained by payer, a payee may later ask payer to provide a public key itself or sign a random message using corresponding private key and thus provide a proof of payer.

Example responses

200 Response

{
  "disposable": true
}

Responses

Status Meaning Description Schema
200 OK LNURL pay response Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» pr string false none bech32-serialized lightning invoice
» disposable boolean false none none
» routes array false none none
» successAction object false none none
»» tag string false none message
»» message string false none message

Pay (1) Request

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/pay/request"

querystring = {"signature":"type,string","n":"type,string,minLength,16,maxLength,16","uid":"type,string,format,uuid"}

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/pay/request?signature=type%2Cstring&n=type%2Cstring%2CminLength%2C16%2CmaxLength%2C16&uid=type%2Cstring%2Cformat%2Cuuid",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url 'https://api.lnmarkets.com/v1/lnurl/pay/request?signature=type%2Cstring&n=type%2Cstring%2CminLength%2C16%2CmaxLength%2C16&uid=type%2Cstring%2Cformat%2Cuuid' \
  --header 'Accept: application/json'

GET /lnurl/pay/request

Response from the LNURL

Parameters

Name In Type Required Description
signature query string true HMAC payload signature.
n query string true Nonce
uid query string(uuid) true User id

Example responses

200 Response

{
  "tag": "payRequest",
  "minSendable": 1000,
  "maxSendable": 1000000,
  "callback": "https://api.lnmarkets.com/v1/lnurl/pay",
  "metadata": "{}"
}

Responses

Status Meaning Description Schema
200 OK LNURL pay request response Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» callback string false none Callback URL used by the wallet
» tag string false none Type of LNURL, payRequest here.
» maxSendable integer(int32) false none Max sendable amount in msat
» minSendable integer(int32) false none Min sendable amount in msat
» metadata string false none Metadata json as string

Lightning Address

Code samples

import requests

url = "https://api.lnmarkets.com/v1/lnurl/pay/address"

querystring = {"username":"type,string"}

headers = {"Accept": "application/json"}

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "api.lnmarkets.com",
  "port": null,
  "path": "/v1/lnurl/pay/address?username=type%2Cstring",
  "headers": {
    "Accept": "application/json"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
curl --request GET \
  --url 'https://api.lnmarkets.com/v1/lnurl/pay/address?username=type%2Cstring' \
  --header 'Accept: application/json'

GET /lnurl/pay/address

Lightning Address

Parameters

Name In Type Required Description
username query string true Username

Example responses

200 Response

{
  "tag": "payRequest",
  "minSendable": 1000,
  "maxSendable": 1000000,
  "callback": "https://api.lnmarkets.com/v1/lnurl/pay",
  "metadata": "{}"
}

Responses

Status Meaning Description Schema
200 OK LNURL pay request response Inline

Response Schema

Status Code 200

Name Type Required Restrictions Description
» callback string false none Callback URL used by the wallet
» tag string false none Type of LNURL, payRequest here.
» maxSendable integer(int32) false none Max sendable amount in msat
» minSendable integer(int32) false none Min sendable amount in msat
» metadata string false none Metadata json as string

undefined