Changelog

Version

Date

Description

1.0.0

May 2020

Initial version

Introduction

This is the documentation for the public API of the LGO platform, that you can use without authentication.

LGO provides an API available with authentication to allow viewing of your personal data on the platform. You can find it’s documentation here: https://doc.exchange.lgo.markets

Public HTTP API

Currencies

You can receive currencies list by sending a GET request to:

Sandbox

https://exchange-api.public.sandbox.lgo.markets/v1/live/currencies

Production

https://exchange-api.public.lgo.markets/v1/live/currencies

along with the following headers:

Name

Type

Value

Accept

String

application/json

You will receive this JSON payload as response:

{
  "currencies": [
    {
      "name": "Bitcoin",  (1)
      "code": "BTC",  (2)
      "decimals": 8  (3)
    },
    {
      "name": "United States Dollar",
      "code": "USD",
      "decimals": 4
    }
  ]
}
1 name name of the currency
2 code code of the currency
3 decimals maximum decimals allowed

Products list

You can receive products list by sending a GET request to:

Sandbox

https://exchange-api.public.sandbox.lgo.markets/v1/live/products

Production

https://exchange-api.public.lgo.markets/v1/live/products

along with the following headers (previously described):

Name

Type

Value

Accept

String

application/json

You will receive this JSON payload as response:

{
  "products": [
    {
      "id": "BTC-USD",  (1)
      "total": {
        "limits": {  (2)
          "min": "10",
          "max": "50000000"
        }
      },
      "base": {
        "id": "BTC",
        "limits": {  (3)
          "min": "0.001",
          "max": "1000"
        }
      },
      "quote": {
        "id": "USD",
        "increment": "0.10",  (4)
        "limits": {  (5)
          "min": "10",
          "max": "1000000"
        }
      }
    }
  ]
}
1 id identifier of the product
2 total.limits minimum and maximum total price*quantity allowed (quote currency)
3 base.limits minimum and maximum quantity allowed
4 quote.increment price increment allowed
5 quote.limits minimum and maximum price allowed

Level 2 market data

You can receive the current state of the order book with a GET request to:

Sandbox

https://exchange-api.public.sandbox.lgo.markets/v1/live/products/BTC-USD/book

Production

https://exchange-api.public.lgo.markets/v1/live/products/BTC-USD/book

along with the following headers:

Name

Type

Value

Accept

String

application/json

where BTC-USD is the product identifier you want to retrieve the book for.

You will receive this JSON payload as response:

{
  "batch_id": 345888, (1)
  "timestamp": 1578665295204, (2)
  "product_id": "BTC-USD", (3)
  "bids": [
      ["7998.3000", "6.21470000"],
      ["7998.1000", "2.14420000"],
      ["7997.8000", "6.08540000"]
    ],
    "asks": [
      ["8000.5000", "1.34970000"],
      ["8000.9000", "8.16290000"],
      ["8001.2000", "1.16220000"]
    ]
  ]
}
1 batch_id identifier of the last processed batch
2 timestamp timestamp of the last processed batch
3 product_id product id

Each line (for example: ["7998.3000", "6.21470000"]) contains the price level (quote currency) and the quantity at this price level (base currency).

You will receive a response with HTTP status 400 and this body in case of invalid path parameter:

{
  "message": "PRODUCT_NOT_AVAILABLE"
}

Trades

You can receive last trades by sending a GET request to:

Sandbox

https://exchange-api.public.sandbox.lgo.markets/v1/live/live/products/BTC-USD/trades

Production

https://exchange-api.public.lgo.markets/v1/live/products/BTC-USD/trades

along with the following headers:

Name

Type

Value

Accept

String

application/json

where BTC-USD is the product id you want trades for.

You will receive this JSON payload as response:

{
  "batch_id": 98797,
  "timestamp": 1578665295204,
  "trades": [
    {
      "trade_id": "182",  (1)
      "side": "B",  (2)
      "price": "7422.6100",  (3)
      "quantity": "1.00000000", (4)
      "trade_creation_time": "2018-08-27T14:41:54.028" (5)
    }
  ]
}
1 trade_id identifier of the match
2 side maker side of this match
3 price price of the match (quote currency)
4 quantity quantity of the match (base currency)

You will receive a response with HTTP status 400 and this body in case of invalid product identifier:

{
  "code": "PRODUCT_NOT_AVAILABLE"
}

Public Websocket API

Level 2 market data feeds and trade feeds are publicly available for each product offered by LGO on the public websocket API, at these URLs:

Production

wss://ws.public.lgo.markets

Sandbox

wss://ws.public.sandbox.lgo.markets

Level 2 market data

Open a websocket connection and connect to the level2 channel for the product of your choice by sending this message:

{
  "type": "subscribe",
  "channels": [
    {
      "name": "level2",
      "product_id": "BTC-USD"
    }
  ]
}

On subscribe, the server will send a snapshot of the current order book, and the last executed batch identifier:

{
  "payload": {
    "bids": [
      ["7998.3000", "6.21470000"],
      ["7998.1000", "2.14420000"],
      ["7997.8000", "6.08540000"]
    ],
    "asks": [
      ["8000.5000", "1.34970000"],
      ["8000.9000", "8.16290000"],
      ["8001.2000", "1.16220000"]
    ]
  },
  "batch_id": 776,
  "timestamp": 1578665295204,
  "type": "snapshot",
  "channel": "level2",
  "product_id": "BTC-USD"
}

Each line (for example: ["7998.3000", "6.21470000"]) contains the price level (quote currency) and the quantity at this price level (base currency).

You will then receive updates for every batch:

{
  "payload": {
    "bids": [],
    "asks": [["7000.0000", "2.00000000"]]
  },
  "batch_id": 777,
  "timestamp": 1578665895204,
  "type": "update",
  "channel": "level2",
  "product_id": "BTC-USD"
}

In an update, a line with quantity 0 means that there is no more order at this price level in the order book.

You can subscribe to multiple product feeds once:

{
  "type": "subscribe",
  "channels": [
    {
      "name": "level2",
      "product_id": "BTC-USD"
    },
    {
      "name": "level2",
      "product_id": "LGO-USD"
    }
  ]
}

You can also unsubscribe from one or many feeds:

{
  "type": "unsubscribe",
  "channels": [
    {
      "name": "level2",
      "product_id": "BTC-USD"
    },
    {
      "name": "level2",
      "product_id": "LGO-USD"
    }
  ]
}

Last platform trades

Open a websocket connection and connect to a trades channel by sending this message with the product of your choice:

{
  "type": "subscribe",
  "channels": [
    {
      "name": "trades",
      "product_id": "BTC-USD"
    }
  ]
}

On subscribe, the server will first send a snapshot of the 100 last trades for the selected product:

{
  "payload": [
    {
      "quantity": "1.00000000",
      "side": "S",
      "price": "100.0000",
      "trade_id": "222",
      "trade_creation_time": "2018-11-22T14:26:24.636Z"
    }
  ],
  "batch_id": 777,
  "timestamp": 1578665295204,
  "type": "snapshot",
  "channel": "trades",
  "product_id": "BTC-USD"
}

You will then receive updates for every batch. The update is limited to the last 100 trades of the batch for the given product.

{
  "payload": [
    {
      "quantity": "2.00000000",  (1)
      "side": "B",  (2)
      "price": "120.0000",  (3)
      "trade_id": "223",  (4)
      "trade_creation_time": "2018-11-22T14:27:23.735Z"  (5)
    },
    {
      "quantity": "0.50000000",
      "side": "S",
      "price": "153.0000",
      "trade_id": "224",
      "trade_creation_time": "2018-11-22T14:27:23.835Z"
    }
  ],
  "batch_id": 778,
  "timestamp": 1578665795204,
  "type": "update",
  "channel": "trades",
  "product_id": "BTC-USD"
}
1 quantity quantity of the match (base currency)
2 side B for buy/bid maker order, S for sell/ask maker order
3 price price of the match (quote currency)
4 trade_id identifier of the match
5 trade_creation_time instant of the match

You can unsubscribe from this feed by sending this message:

{
  "type": "unsubscribe",
  "channels": [
    {
      "name": "trades",
      "product_id": "BTC-USD"
    }
  ]
}