Skip to content

Commit

Permalink
add oracles and prices docs for Ocean API (#885)
Browse files Browse the repository at this point in the history
* refactor to use .mdx

* added oracles.mdx

* add prices.mdx
  • Loading branch information
fuxingloh authored Dec 14, 2021
1 parent 88fe301 commit b624b09
Show file tree
Hide file tree
Showing 4 changed files with 576 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/ocean/01-overview.md → docs/ocean/01-overview.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: overview
title: Ocean REST API
sidebar_label: Overview
id: overview
title: Ocean REST API
sidebar_label: Overview
slug: /
---

Expand Down
4 changes: 2 additions & 2 deletions docs/ocean/REFERENCES/address.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ sidebar_label: Address
slug: /address
---

With the Address API, you can query address related resources such as UTXO balances, Token Balances, Vaults and
Transactions.
With the Address API, you can query address related resources such as UTXO balances, Token Balances, Vaults and
Transactions.

## Balance

Expand Down
200 changes: 200 additions & 0 deletions docs/ocean/REFERENCES/oracles.mdx
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
}
}
```

Loading

0 comments on commit b624b09

Please sign in to comment.