-
Notifications
You must be signed in to change notification settings - Fork 0
API v2.0.0 market
Tiny_Murky edited this page Mar 14, 2024
·
7 revisions
- description: available tickers provide by TideBit-DeFi, all tickers' base unit is USDT
GET /api/v2/market/tickers
name | type | description | required | default |
---|---|---|---|---|
instId | string | If an instId is provided in the query, the system will return ticker data for that specific instId. If no instId is specified, ticker data for all instIds will be returned. | false | undefined |
begin | timestamp | API will return tickers which was after this timestamp, timestamp present by second is recommended, if timestamp isprecent by millisecond, it will be floor down to second | false | 0 (1970/1/1 0:0:0) |
end. | timestamp | API will return tickers which was before this timestamp, timestamp present by second is recommended, if timestamp isprecent by millisecond, it will be floor down to second | false | Infinity |
timespan | string | current support timespan: 1m/3m/5m/15m/30m/1H/4H/12H/1D | false | 1m |
limit | integer | maximum length of ticker linegraph data array. maximum: Infinity, minimum: 0. | false | 50 |
list available tickers
GET /api/v1/market/tickers?instId=ETH-USDT&timeSpan=1m&begin=1710382500&end=1710382598&limit=10
name | type | description |
---|---|---|
success | boolean | request 成功或失敗 |
code | string | response code |
data | 如下所示] | response data |
Data
{
"beginTimestamp": timestamp(單位為秒),
"ticker" :ITickerData[]
}[]
如果不填入
instId
(或是填入系統不存在的instId
) 都會回傳全部instId
種類的ticker
/api/v2/market/tickers
{
"success": true,
"code": "00000000",
"data": [
{
"beginTimestamp": 1710388255,
"ticker": {
"instId": "ETH-USDT",
"currency": "ETH",
"name": "Ethereum",
"tokenImg": "/asset_icon/eth.svg",
"whitePaperLink": "https://ethereum.org/en/whitepaper/",
"websiteLink": "https://ethereum.org",
"publishTime": "2015-07-30",
"publishAmount": 115000000,
"decimal": 18,
"rank": 2,
"baseUnit": "ETH",
"quoteUnit": "USDT",
"price": "3992.11",
"priceChange": "-50.49",
"upOrDown": "DOWN",
"fluctuating": "-1.2644942148387699",
"tradingVolume": "138702.65769",
"star": false,
"starred": false,
"lineGraphProps": {
"dataArray": [
3994.8,
3992.81,
3994.6,
3995.46,
3995.46,
3994.03,
3992.27,
3992.26
]
}
}
},
{
"beginTimestamp": 1710388256,
"ticker": {
"instId": "BTC-USDT",
"currency": "BTC",
"name": "Bitcoin",
"tokenImg": "/asset_icon/btc.svg",
"whitePaperLink": "https://bitcoin.org/bitcoin.pdf",
"websiteLink": "https://bitcoin.org",
"publishTime": "2009-01-09",
"publishAmount": 21000000,
"decimal": 8,
"rank": 1,
"baseUnit": "BTC",
"quoteUnit": "USDT",
"price": "73241.1",
"priceChange": "1213",
"upOrDown": "UP",
"fluctuating": "1.6561739242037597",
"tradingVolume": "12021.21135493",
"star": false,
"starred": false,
"lineGraphProps": {
"dataArray": [
73241.4,
73231.9,
73267.9,
73251.1,
73228.4,
73216,
73198.5,
73238.3
]
}
}
}
]
}
如果填入
instId
/api/v2/market/tickers?instId=ETH-USDT&timeSpan=1m&begin=1710383000&limit=10&end=1710383143
{
"success": true,
"code": "00000000",
"data": [
{
"instId": "ETH-USDT",
"currency": "ETH",
"name": "Ethereum",
"tokenImg": "/asset_icon/eth.svg",
"whitePaperLink": "https://ethereum.org/en/whitepaper/",
"websiteLink": "https://ethereum.org",
"publishTime": "2015-07-30",
"publishAmount": 115000000,
"decimal": 18,
"rank": 2,
"baseUnit": "ETH",
"quoteUnit": "USDT",
"price": "3996.7",
"priceChange": "-23.32",
"upOrDown": "DOWN",
"fluctuating": "-0.5832311657117222",
"tradingVolume": "139024.583546",
"star": false,
"starred": false,
"lineGraphProps": {
"dataArray": [
3991.5,
3991.6
]
}
}
]
}
limit
,begin
,end
輸入數字以外的type會有以下錯誤提示
/api/v2/market/tickers?instId=ETH-USDT&timeSpan=1s&begin=1710388201&end=1710388301
{
"statusCode": 400,
"message": [
"begin must be a number conforming to the specified constraints",
"end must be a number conforming to the specified constraints",
"limit must be a number conforming to the specified constraints"
],
"error": "Bad Request"
}
timestamp
沒有使用開放的間距會提供特殊錯誤提示
/api/v2/market/tickers?timeSpan=1ma
{
"statusCode": 400,
"message": [
"timeSpan must be one of the following values: 1s, 15s, 30s, 1m, 3m, 5m, 15m, 30m, 1h, 4h, 12h, 1d"
],
"error": "Bad Request"
}
- description: Retrieve the candlestick chart data of a ticker. Charts are returned in groups based on the requested bar.
GET /api/v1/candlesticks/:instId
name | type | description | required | default |
---|---|---|---|---|
instId | string | certain instId to be search | true | null |
name | type | description | required | default |
---|---|---|---|---|
timeSpan | string | current support timespan: 5m/15m/30m/1H/4H/12H/1D | true | undefined |
limit | integer | maximum length of candlestick data. maximum: 300, minimum: 0 | false | undefined |
begin | timestamp | API will return tickers which was after this timestamp, timestamp is in millisecond form | false | undefined |
end. | timestamp | API will return tickers which was before this timestamp, timestamp is in millisecond form | false | undefined |
get Candlestick Data
GET /api/v1/candlesticks/ETH-USDT?timeSpan=5m&end=1710404888999&begin=1710404088000&limit=2
name | type | description |
---|---|---|
code | string | response code |
success | boolean | request 成功或失敗 |
data | (ICandlestick | null | response data |
/api/v2/candlesticks/ETH-USDT?timeSpan=1d
{
"code": "00000000",
"success": true,
"data": {
"beginTimestamp": 1710381600,
"candlesticks": {
"instId": "ETH-USDT",
"candlesticks": [
{
"x": "2024-03-14T08:35:00.000Z",
"y": {
"open": 3983.99,
"high": 4000.53,
"low": 3940,
"close": 3975.28,
"volume": 20757.778300999344,
"value": 82431290.06516539
}
}
]
}
}
}
/api/v2/candlesticks/ETH-USDT?timeSpan=5m&begin=1710404088000&end=1710404888999&limit=2
{
"code": "00000000",
"success": true,
"data": {
"beginTimestamp": 1710404100,
"candlesticks": {
"instId": "ETH-USDT",
"candlesticks": [
{
"x": "2024-03-14T08:20:00.000Z",
"y": {
"open": 3967.35,
"high": 3976.18,
"low": 3967,
"close": 3973.6,
"volume": 318.6946490000002,
"value": 1265914.1086076566
}
},
{
"x": "2024-03-14T08:25:00.000Z",
"y": {
"open": 3973.6,
"high": 3980.16,
"low": 3971.69,
"close": 3979.14,
"volume": 781.0167269999897,
"value": 3105226.043263105
}
},
{
"x": "2024-03-14T08:30:00.000Z",
"y": {
"open": 3979.15,
"high": 3982.56,
"low": 3979.02,
"close": 3979.4,
"volume": 522.4882019999969,
"value": 2080073.2535250094
}
}
]
}
}
}
- 失敗的回傳
#### 失敗的回傳
> `limit`, `begin`, `end` 輸入數字以外的type會有以下錯誤提示
/api/v2/candlesticks/ETH-USDT?timeSpan=1d&begin=aaa&end=aaa&limit=aaa
```json
{
"statusCode": 400,
"message": [
"begin must be a number conforming to the specified constraints",
"end must be a number conforming to the specified constraints",
"limit must be a number conforming to the specified constraints"
],
"error": "Bad Request"
}
timestamp
沒有使用開放的間距或是未提供會提供特殊錯誤提示
# 沒有 timeSpan
/api/v2/candlesticks/ETH-USDT?begin=1710404088000&end=1710404888999&limit=2
# 使用未開放的timeSpam (目前只開放到5m)
/api/v2/candlesticks/ETH-USDT?timeSpan=1s&begin=1710404088000&end=1710404888999&limit=2
{
"statusCode": 400,
"message": [
"timeSpan must be one of the following values: 5m, 15m, 30m, 1h, 4h, 12h, 1d"
],
"error": "Bad Request"
}