# Yields API

## Get Yields

<mark style="color:blue;">`GET`</mark> `https://mainnet.staked.cloud/api/yields`

Get yield information for assets.

#### Request Headers

| Name      | Type   | Description                                                                                   |
| --------- | ------ | --------------------------------------------------------------------------------------------- |
| X-Api-Key | string | Your API key (preferred method of passing api key is now in headers rather than query params) |

#### Query Parameters

| Name       | Type    | Description                                                                                                                                                                |
| ---------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| api\_key   | string  | <p><strong>\[Deprecated since March '25</strong> (preferred method of passing api key is now in headers rather than query params)<strong>]</strong></p><p>Your API key</p> |
| date       | string  | Get data from a specific date, default is current day. Format: YYYY-MM-DD                                                                                                  |
| extended   | boolean | Get more staking data in the response such as inflation, staking rate, etc                                                                                                 |
| by\_key    | string  | Filters for assets associated with api\_key                                                                                                                                |
| currencies | array   | List of currencies to return, default is all                                                                                                                               |

{% tabs %}
{% tab title="200 Data successfully retrieved." %}

```javascript
// With 'extended' set to false
[
    ...
    {
        "currency": "Cosmos",
        "yield": "0.09647",
        "timestamp": "2019-09-03T12:00:06.559048",
    },
    {
        "currency": "Tezos",
        "yield": "0.07155",
        "timestamp": "2019-09-03T12:00:48.148923",
    }
    ...
]

// With 'extended' set to true
[
    ...
    {
        "currency": "Cosmos",
        "yield": "0.09647",
        "timestamp": "2019-09-03T12:00:06.559048",
        "total_supply": 243828455907213,
        "circulating_supply": 243828455907213,
        "staked_supply": 177578277871531,
        "staking_rate": "0.728290",
        "inflation": "0.070256",
        "inflation_total": "0.070256"
    },
    {
        "currency": "Tezos",
        "yield": "0.07155",
        "timestamp": "2019-09-03T12:00:48.148923",
        "total_supply": 806071727,
        "circulating_supply": 806071727,
        "staked_supply": 567656000,
        "staking_rate": "0.704220",
        "inflation": "0.050389",
        "inflation_total": "0.050389"
    }
    ...
]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="React w/ Axios" %}

```javascript
import axios from "axios";

const api_key = 'YOUR API KEY';

const api = axios.create({
  baseURL: "https://mainnet.staked.cloud/api",
  timeout: 1000000,
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": api_key
  }
});

api.get(`/yields?extended=true&by_key=false`)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error("Error fetching yields:", error);
  });
```

{% endtab %}

{% tab title="jQuery" %}

```javascript

const api_key = "YOUR API KEY";

let request = {
  url: "https://mainnet.staked.cloud/api/yields?extended=true&by_key=false",
  method: "GET",
  timeout: 0,
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": api_key
  }
};

$.ajax(request).done(function(response) {
  console.log(response);
});
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
var http = require('http');

const api_key = 'YOUR API KEY';

var options = {
  method: 'GET',
  hostname: 'mainnet.staked.cloud',
  path: `/api/yields?extended=true&by_key=false`,
  headers: {
    'Content-Type': 'application/json',
    'X-Api-Key': api_key
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
```

{% endtab %}

{% tab title="Swift" %}

```swift
import Alamofire

let api_key = "YOUR API KEY"

let headers: HTTPHeaders = [
    "Content-Type": "application/json",
    "X-Api-Key": api_key
]

AF.request("https://mainnet.staked.cloud/api/yields?extended=true&by_key=false", headers: headers).response { response in
    debugPrint(response)
}

```

{% endtab %}
{% endtabs %}

## Get Currency Yield Time Series

<mark style="color:blue;">`GET`</mark> `https://mainnet.staked.cloud/api/yields/currency/:currency/timeseries`

Get yield information for assets as a time series.

#### Path Parameters

| Name     | Type   | Description                 |
| -------- | ------ | --------------------------- |
| currency | string | Currency name. Ex: "Decred" |

#### Request Headers

| Name      | Type   | Description  |
| --------- | ------ | ------------ |
| X-Api-Key | string | Your API key |

#### Query Parameters

| Name         | Type    | Description                                                                |
| ------------ | ------- | -------------------------------------------------------------------------- |
| api\_key     | string  | <p><strong>\[Deprecated since March '25]</strong> </p><p>Your API key</p>  |
| interval     | integer | Interval, in days                                                          |
| num\_entries | string  | Number of entries                                                          |
| date         | string  | Timeseries start date, default is current day. Format: YYYY-MM-DD          |
| extended     | boolean | Get more staking data in the response such as inflation, staking rate, etc |

{% tabs %}
{% tab title="200 " %}

```javascript
// With 'extended' set to false
{
    "timeseries": [
        ...
        {
            "currency": "Decred",
            "yield": "0.09693",
            "timestamp": "2019-09-03T12:00:48.864127"
        },
        {
            "currency": "Decred",
            "yield": "0.09663",
            "timestamp": "2019-09-02T12:01:00.440379"
        }
        ...
    ],
    "missed": [
        ...
        "2019-09-04",
        ...
    ]
}

// with 'extended' set to true
{
    "timeseries": [
        ...
        {
            "currency": "Decred",
            "yield": "0.09674",
            "timestamp": "2019-09-05T12:00:27.535454",
            "total_supply": 10340411,
            "circulating_supply": 10340411,
            "staked_supply": 5209150,
            "staking_rate": "0.503770",
            "inflation": "0.051799",
            "inflation_total": "0.172663"
        },
        {
            "currency": "Decred",
            "yield": "0.09693",
            "timestamp": "2019-09-03T12:00:48.864127",
            "total_supply": 10330414,
            "circulating_supply": 10330414,
            "staked_supply": 5198821,
            "staking_rate": "0.503250",
            "inflation": "0.051847",
            "inflation_total": "0.172822"
        }
        ...
    ],
    "missed": [
        ...
        "2019-08-29",
        ...
    ]
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="React w/ Axios" %}

```javascript
import axios from "axios";

const api_key = 'YOUR API KEY';
const currency = 'CURRENCY NAME';
const interval = 1;
const num_entries = 10;

var api = axios.create({
  baseURL: "https://mainnet.staked.cloud/api",
  timeout: 1000000,
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": api_key
  }
});

api.get(`/yields/currency/${currency}/timeseries?interval=${interval}&num_entries=${num_entries}&extended=true`).then(response => {
  console.log(res);
})
```

{% endtab %}

{% tab title="jQuery" %}

```javascript
const api_key = 'YOUR API KEY';
const currency = 'CURRENCY NAME';
const interval = 1;
const num_entries = 10;

var request = {
  url: `https://mainnet.staked.cloud/api/yields/currency/${currency}/timeseries?interval=${interval}&num_entries=${num_entries}&extended=true`,
  method: "GET",
  timeout: 0,
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": api_key
  }
};

$.ajax(request).done(function (response) {
  console.log(response);
});
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
var http = require('http');

const api_key = 'YOUR API KEY';
const currency = 'CURRENCY NAME';
const interval = 1;
const num_entries = 10;

var options = {
  'method': 'GET',
  'hostname': 'mainnet.staked.cloud',
  'path': `/api/yields/currency/${currency}/timeseries?interval=${interval}&num_entries=${num_entries}&extended=true`,
  'headers': {
    'Content-Type': 'application/json',
    'X-Api-Key': api_key
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

req.end();
```

{% endtab %}

{% tab title="Swift" %}

```swift
import Alamofire

let api_key = 'YOUR API KEY';
let currency = 'CURRENCY NAME';
let interval = 1;
let num_entries = 10;

let headers: HTTPHeaders = [
    "Content-Type": "application/json",
    "X-Api-Key": api_key
]

AF.request("https://mainnet.staked.cloud/api/yields/currency/\(currency)/timeseries?interval=\(interval)&num_entries=\(num_entries)&extended=true", headers: headers).response { response in
    debugPrint(response)
}
```

{% endtab %}
{% endtabs %}
