-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add oracles and prices docs for Ocean API (#885)
* refactor to use .mdx * added oracles.mdx * add prices.mdx
- Loading branch information
Showing
4 changed files
with
576 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
--- | ||
id: oracles | ||
title: Oracles Ocean REST API | ||
sidebar_label: Oracles | ||
slug: /oracles | ||
--- | ||
|
||
## List Oracle | ||
|
||
Get a list of Oracles | ||
|
||
#### Code Samples | ||
|
||
##### Shell | ||
|
||
```shell | ||
curl https://ocean.defichain.com/v0/mainnet/oracles | ||
``` | ||
|
||
##### JavaScript ([@defichain/whale-api-client](https://www.npmjs.com/package/@defichain/whale-api-client)) | ||
|
||
```javascript | ||
await api.oracles.list() | ||
``` | ||
|
||
##### Response | ||
|
||
```json | ||
{ | ||
"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 | ||
|
||
```typescript | ||
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 | ||
|
||
```shell | ||
https://ocean.defichain.com/v0/mainnet/oracles/f7a00f517a0201e2517a422c5d2b2807868b2615f17d8fc9d8d2bd6baab905b7/AAPL-USD/feed | ||
``` | ||
|
||
##### JavaScript ([@defichain/whale-api-client](https://www.npmjs.com/package/@defichain/whale-api-client)) | ||
|
||
```javascript | ||
await api.oracles.getPriceFeed('f7a00f517a0201e2517a422c5d2b2807868b2615f17d8fc9d8d2bd6baab905b7', 'AAPL', 'USD') | ||
``` | ||
|
||
##### Response | ||
|
||
```json | ||
{ | ||
"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 | ||
|
||
```typescript | ||
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 | ||
} | ||
} | ||
``` | ||
|
Oops, something went wrong.