Oracles Ocean REST API
List Oracle
Get a list of Oracles
Code Samples
Shell
curl https://ocean.defichain.com/v0/mainnet/oracles
@defichain/whale-api-client)
JavaScript (await api.oracles.list()
Response
{
"data": [
{
"id": "f7a00f517a0201e2517a422c5d2b2807868b2615f17d8fc9d8d2bd6baab905b7",
"ownerAddress": "df1q02jh2rkymd6ncl75ql3f267u3guja9nzqj2qmn",
"weightage": 10,
"priceFeeds": [
{
"token": "AAPL",
"currency": "USD"
},
{
"token": "AMD",
"currency": "USD"
},
{
"token": "AMZN",
"currency": "USD"
},
{
"token": "COIN",
"currency": "USD"
},
{
"token": "FB",
"currency": "USD"
},
{
"token": "GME",
"currency": "USD"
},
{
"token": "GOOGL",
"currency": "USD"
},
{
"token": "MSTR",
"currency": "USD"
},
{
"token": "NVDA",
"currency": "USD"
},
{
"token": "OTGLY",
"currency": "USD"
},
{
"token": "SQNXF",
"currency": "USD"
},
{
"token": "TSLA",
"currency": "USD"
},
{
"token": "TWTR",
"currency": "USD"
},
{
"token": "UBER",
"currency": "USD"
}
],
"block": {
"hash": "923fe2d3f5920163d2401095de5647ce25ee3463863fad04e76eec48719fb8a3",
"height": 1398516,
"medianTime": 1637921787,
"time": 1637921973
}
}
],
"page": {
"next": "508beb786a51a6dfab3013e777e7b46a213668a2175f535dbe7296fb27bf3656"
}
}
TypeScript Definitions
export interface Oracle {
id: string
weightage: number
ownerAddress: string
priceFeeds: Array<{
token: string
currency: string
}>
block: {
hash: string
height: number
time: number
medianTime: number
}
}
Get Oracle Price Feed
Get Price Feed for each Oracle by Price Ticker.
Code Samples
Shell
https://ocean.defichain.com/v0/mainnet/oracles/f7a00f517a0201e2517a422c5d2b2807868b2615f17d8fc9d8d2bd6baab905b7/AAPL-USD/feed
@defichain/whale-api-client)
JavaScript (await api.oracles.getPriceFeed('f7a00f517a0201e2517a422c5d2b2807868b2615f17d8fc9d8d2bd6baab905b7', 'AAPL', 'USD')
Response
{
"data": [
{
"id": "AAPL-USD-f7a00f517a0201e2517a422c5d2b2807868b2615f17d8fc9d8d2bd6baab905b7-2628b115639b31eb8ed9a71761de9c117e4044daf0c430597aeccccd838caa05",
"key": "AAPL-USD-f7a00f517a0201e2517a422c5d2b2807868b2615f17d8fc9d8d2bd6baab905b7",
"sort": "001619842628b115639b31eb8ed9a71761de9c117e4044daf0c430597aeccccd838caa05",
"amount": "175.74",
"currency": "USD",
"block": {
"hash": "ed2000856e1a1c5d6d2bf6f916896a7dc736a39005f755be43efae8122f87340",
"height": 1448324,
"medianTime": 1639459804,
"time": 1639459967
},
"oracleId": "f7a00f517a0201e2517a422c5d2b2807868b2615f17d8fc9d8d2bd6baab905b7",
"time": 1639459804,
"token": "AAPL",
"txid": "2628b115639b31eb8ed9a71761de9c117e4044daf0c430597aeccccd838caa05"
}
],
"page": {
"next": "001619842628b115639b31eb8ed9a71761de9c117e4044daf0c430597aeccccd838caa05"
}
}
TypeScript Definitions
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
}
}