Prices Ocean REST API
List Price Ticker
Get a list of available Price Ticker.
Code Samples
Shell
curl https://ocean.defichain.com/v0/mainnet/prices
@defichain/whale-api-client)
JavaScript (await api.prices.list()
Response
{
"data": [
{
"id": "TWTR-USD",
"sort": "0000000a00161998TWTR-USD",
"price": {
"block": {
"hash": "1f9bf56159b32aa7510cbfeb88ddeba54916d9bdb614d023dbbf6474bdfd412a",
"height": 1448344,
"medianTime": 1639460653,
"time": 1639460825
},
"aggregated": {
"amount": "44.60571429",
"weightage": 70,
"oracles": {
"active": 7,
"total": 10
}
},
"currency": "USD",
"token": "TWTR",
"id": "TWTR-USD-1448344",
"key": "TWTR-USD",
"sort": "61b82f2d00161998"
}
}
],
"page": {
"next": "0000000a00161998TWTR-USD"
}
}
TypeScript Definitions
export interface PriceTicker {
id: string
sort: string
price: PriceFeed
}
export interface PriceFeed {
id: string
key: string
sort: string
token: string
currency: string
aggregated: {
amount: string
weightage: number
oracles: {
active: number
total: number
}
}
block: {
hash: string
height: number
time: number
medianTime: number
}
}
Get Price Ticker
Get a single Price Ticker.
Code Samples
Shell
curl https://ocean.defichain.com/v0/mainnet/prices/DFI-USD
@defichain/whale-api-client)
JavaScript (await api.prices.get('DFI', 'USD')
Response
{
"data": {
"id": "DFI-USD",
"sort": "00000003001619aeDFI-USD",
"price": {
"block": {
"hash": "7900d0080c89adaa2fd391cda3ec21811495d3fd81bcc1cc0e330dde778a55ad",
"height": 1448366,
"medianTime": 1639461633,
"time": 1639461808
},
"aggregated": {
"amount": "3.74965901",
"weightage": 30,
"oracles": {
"active": 3,
"total": 3
}
},
"currency": "USD",
"token": "DFI",
"id": "DFI-USD-1448366",
"key": "DFI-USD",
"sort": "61b83301001619ae"
}
}
}
TypeScript Definitions
export interface PriceTicker {
id: string
sort: string
price: PriceFeed
}
export interface PriceFeed {
id: string
key: string
sort: string
token: string
currency: string
aggregated: {
amount: string
weightage: number
oracles: {
active: number
total: number
}
}
block: {
hash: string
height: number
time: number
medianTime: number
}
}
List Price Feed
Get a list of Price Feed by Price Ticker.
Code Samples
Shell
curl https://ocean.defichain.com/v0/mainnet/prices/DFI-USD/feed
@defichain/whale-api-client)
JavaScript (await api.prices.getFeed('DFI', 'USD')
Response
{
"data": [
{
"block": {
"hash": "7900d0080c89adaa2fd391cda3ec21811495d3fd81bcc1cc0e330dde778a55ad",
"height": 1448366,
"medianTime": 1639461633,
"time": 1639461808
},
"aggregated": {
"amount": "3.74965901",
"weightage": 30,
"oracles": {
"active": 3,
"total": 3
}
},
"currency": "USD",
"token": "DFI",
"id": "DFI-USD-1448366",
"key": "DFI-USD",
"sort": "61b83301001619ae"
}
],
"page": {
"next": "61b83301001619ae"
}
}
TypeScript Definitions
export interface PriceFeed {
id: string
key: string
sort: string
token: string
currency: string
aggregated: {
amount: string
weightage: number
oracles: {
active: number
total: number
}
}
block: {
hash: string
height: number
time: number
medianTime: number
}
}
List Oracle
Get a list of Oracles by Price Ticker.
Code Samples
Shell
curl https://ocean.defichain.com/v0/mainnet/prices/DFI-USD/oracles
@defichain/whale-api-client)
JavaScript (await api.prices.getFeed('DFI', 'USD')
Response
{
"data": [
{
"id": "DFI-USD-d96d04bd4b5b35d12d20d9c6b70809f8e83118ccffff307b82459dd42a6b5f07",
"key": "DFI-USD",
"oracleId": "d96d04bd4b5b35d12d20d9c6b70809f8e83118ccffff307b82459dd42a6b5f07",
"token": "DFI",
"currency": "USD",
"weightage": 10,
"block": {
"hash": "455610bc121667976c88606c248ec23570a0fcde8464f047bda68e6ef41123bf",
"height": 1087280,
"medianTime": 1628565877,
"time": 1628566178
},
"feed": {
"id": "DFI-USD-d96d04bd4b5b35d12d20d9c6b70809f8e83118ccffff307b82459dd42a6b5f07-42010ed00d12849cc71025ae3457f90647f6a85c8db08ae6d687118df4f1ee8f",
"key": "DFI-USD-d96d04bd4b5b35d12d20d9c6b70809f8e83118ccffff307b82459dd42a6b5f07",
"sort": "001619ae42010ed00d12849cc71025ae3457f90647f6a85c8db08ae6d687118df4f1ee8f",
"amount": "3.79434271",
"currency": "USD",
"block": {
"hash": "7900d0080c89adaa2fd391cda3ec21811495d3fd81bcc1cc0e330dde778a55ad",
"height": 1448366,
"medianTime": 1639461633,
"time": 1639461808
},
"oracleId": "d96d04bd4b5b35d12d20d9c6b70809f8e83118ccffff307b82459dd42a6b5f07",
"time": 1639461717,
"token": "DFI",
"txid": "42010ed00d12849cc71025ae3457f90647f6a85c8db08ae6d687118df4f1ee8f"
}
}
],
"page": {
"next": "d96d04bd4b5b35d12d20d9c6b70809f8e83118ccffff307b82459dd42a6b5f07"
}
}
TypeScript Definitions
export interface PriceOracle {
id: string
key: string
token: string
currency: string
oracleId: string
weightage: number
/**
* Optional as OraclePriceFeed might not be available e.g. newly initialized Oracle
*/
feed?: OraclePriceFeed
block: {
hash: string
height: number
time: number
medianTime: number
}
}
export interface OraclePriceFeed {
id: string
key: string
sort: string
token: string
currency: string
oracleId: string
txid: string
time: number
amount: string
block: {
hash: string
height: number
time: number
medianTime: number
}
}