REST API

我们API的一些通用地方,可以在这列做说明。我建议error_code和error_msg放到第一级,原因是客户端通常会这样判断返回结果是否有错误:if (result.error_code != 0) {...} else {...}

否则可能就需要这么写:if (result.error || result.error.error_code != 0) {...}

Response例子里面记得加注释,如果是重复项,只标注第一个item就行了。

Wrapping of Response Data

All REST APIs wrap their returned data in the following JSON wrapper:

{
"error_code": 0,
"error_msg": "some error message",
"data": {
...
}
}
  • error_code : this required field indicates whether the API invocation has encountered an error. In case of an error, the error_code field shall be non-zero and the error_msg field must be returned; otherwise, the error_msg field must NOT be returned.

  • error_msg : an optional field to return more information regarding the error.

  • data: this optional field is an object that wraps the API specific response. When error_code is zero, this field must NOT be returned.

Error Codes

The following error codes are defined:

  • 10001

  • 10002 -

HTTP Status Code

Please do not relay on HTTP status code to check API result status. Use the error_code instead.

get

https://lightcone.io/api/v1/timestamp
Request
Response
Path Parameters
optional
string
200: OK

get

https://lightcone.io/api/v1/tokens
Returns information for all or specific tokens. Please use ETH as the symbol for Ether and 0x0or0x00000000000000000000000000000000000000000as the address for Ether.
Request
Response
Query Parameters
tokens
optional
string
A list of comma separated token symbols or addresses which are case insensitive. If this parameter is missing, information for all supported tokens will be returned.
200: OK
Returns a list of token founded. If a specified token is not found, the symbol will be missing from the returned object.
{
"error_code": 0,
"data": {
"tokens": [{
"symbol": "LRC",
"id": 12,
"decimals": 18,
"address": "lrctoken.eth"
},{
"symbol": "LRC",
"id": 12,
"decimals": 18,
"address": "lrctoken.eth"
}]
}
}

get
Get Market Information

https://lightcone.io/api/v1/markets
Returns information for all or specific market pairs.
Request
Response
Query Parameters
markets
optional
string
A list of comma separated markets. The market names are case insensitive and should be formatted as ABC-XYZ where ABC is the base token and XYZ is the quote token.
baseToken
optional
string
The symbol or address of the base token. If markets is specified, this parameter will be ignored.
quoteToken
optional
string
The symbol or address of the quote token. If markets or baseToken is specified, this parameter will be ignored.
200: OK
The market pair string will be in upper-cases.
{
"error_code": 0,
"data": {
"markets": [{
"market": "LRC-ETH", // string, required
"baseToken": "0x123451234512345123451234512345", // string, required
"quoteToken": "0x123451234512345123451234512345", // string, required
"pricePrecision": 5, // integer, required
"baseTokenPrecision": 5, // integer, required
"quoteTokenPrecision": 5, // integer, required
"maxLevel": 2 // integer, required
},{
"market": "LRC-ETH",
"baseToken": "0x123451234512345123451234512345",
"quoteToken": "0x123451234512345123451234512345",
"pricePrecision": 5,
"baseTokenPrecision": 5,
"quoteTokenPrecision": 5,
"maxLevel": 2
}]
}
}