Get coin moving averages

Growth This endpoint requires the growth plan or higher. Free, Basic and Startup plans can use preview access.

Get the moving averages for a coin throughout time, in both the simple (SMA) and exponential (EMA) flavours. The supported windows are 20, 50, 100 and 200 periods, and a period is one candle of the interval you request — so interval=day gives the familiar 20/50/100/200-day averages, while interval=hour gives 20/50/100/200-hour ones.

A simple moving average (ma20 … ma200) weights every candle in its window equally. An exponential moving average (ema20 … ema200) weights the most recent candles more heavily, so it turns sooner when the price changes direction. Both are expressed in the reference currency, and both become available on the same candle — an EMA is seeded from the simple average of its first window.

The response also carries Bollinger Bands around the 20-period average: bbUpper20 and bbLower20 sit two standard deviations either side of it, so the band widens when the price is volatile and narrows when it settles. There is no middle-band field because a Bollinger middle band is the simple moving average of the same window — it is already published as ma20.

The band is published at two standard deviations, and that is not a limitation. The deviation itself is (bbUpper20 - ma20) / 2, so a band at any other width can be derived from the response without another request.

The window follows the interval rather than always meaning days. A request without an interval uses the default for the chosen timePeriod (see the table below), so pass interval=day explicitly if you want day-denominated averages. Note that interval=day is only available from timePeriod=7d upwards — the shorter periods (1h, 3h, 12h and 24h) do not span enough days to allow it.

https://api.coinranking.com/v2/indicators/:uuid/moving-averages

Preview access

Free, Basic and Startup plans can test this endpoint with five successful requests per account per UTC day. Use the documented endpoint URL with your existing API key. Preview access is applied automatically. The allowance resets at 00:00 UTC.

All API keys, resource IDs, query parameters and pagination requests share this endpoint's allowance for your account. Failed requests do not consume the preview allowance. Successful previews also count toward your normal API usage, and your plan's result, historical-window and rate limits still apply. See endpoint previews for limits, response headers and quota errors.

Path parameters

Parameter Description
uuid String UUID of the coin you want to request the moving averages for.

Query parameters

Parameter Description
timePeriod (optional) String

The time period for which the moving average data is returned. The number of data points and the default interval are determined by the time period.

Growth and higher plans can use every time period up to all. Preview requests follow your plan’s historical window: Free is limited to one year, Basic to five years, and Startup can use all available history.

Default value: 24h
Allowed values:
1h 3h 12h 24h 7d 30d 3m 1y 3y 5y 10y all

Example:
https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?timePeriod=7d
interval (optional) String

The interval determines the granularity of each data point. If not provided, a default interval is used based on the selected timePeriod. Only certain intervals are available per timePeriod — see the table below.


timePeriod Available intervals (default in bold)
1h minute, 5minutes
3h minute, 5minutes, hour
12h minute, 5minutes, hour
24h minute, 5minutes, hour, 8hours
7d hour, 8hours, day
30d hour, 8hours, day, week
3m hour, 8hours, day, week, month
1y day, week, month
3y day, week, month
5y day, week, month
10y day, week, month
all day, week, month

Example:
https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?timePeriod=7d&interval=day
referenceCurrencyUuid (optional) String

UUID of coin (either fiat or crypto), in which all the moving average values are calculated. Defaults to US Dollar, but you can use any coin. You can find UUIDs for reference currencies in any coin endpoint, including a convenient dedicated reference currency endpoint

Default value: yhjMzLPhuIDl

Example:
https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?referenceCurrencyUuid=5k-_VTxqtCEI

Code examples

curl
curl 'https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?timePeriod=7d&interval=hour&referenceCurrencyUuid=5k-_VTxqtCEI' \
  -H 'x-access-token: your-api-key' \
  -G
JavaScript
const options = {
  headers: {
    'x-access-token': 'your-api-key',
  },
};

fetch('https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?timePeriod=7d&interval=hour&referenceCurrencyUuid=5k-_VTxqtCEI', options)
  .then((response) => response.json())
  .then((result) => console.log(result));
PHP
<?php
  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?timePeriod=7d&interval=hour&referenceCurrencyUuid=5k-_VTxqtCEI",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "x-access-token: your-api-key"
      ),
  ));

  $response = curl_exec($curl);

  curl_close($curl);
  echo $response;
Python
import requests

headers = {
  'x-access-token': 'your-api-key'
}

response = requests.request("GET", "https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/moving-averages?timePeriod=7d&interval=hour&referenceCurrencyUuid=5k-_VTxqtCEI", headers=headers)

print(response.text)

Response

json
HTTP/1.1 200 OK
{
  "status": "success",
  "data": [
    {
      "startingAt": 1774936800,
      "ma20": "61051.50263116225",
      "ma50": "59938.44387892327",
      "ma100": "67917.84166179039",
      "ma200": "79262.68876699556",
      "ema20": "61204.88911204417",
      "ema50": "60312.77410038255",
      "ema100": "66984.31220149077",
      "ema200": "77105.44992018813",
      "bbUpper20": "62890.11447209318",
      "bbLower20": "59212.89079023132"
    },
    {
      "startingAt": 1774933200,
      "ma20": "61050.102576064244",
      "ma50": "59937.069348890385",
      "ma100": "67916.28414532698",
      "ma200": "79260.87108640283",
      "ema20": "61203.11764018829",
      "ema50": "60311.02218804471",
      "ema100": "66982.90116644302",
      "ema200": "77103.61884770195",
      "bbUpper20": "62888.42137705441",
      "bbLower20": "59211.78377507408"
    }
  ]
}

Response fields

Property Description
status String

Status of the request

Allowed values:
success
data Object[]

List of moving average data points

data.startingAt Number

An Epoch startingAt in seconds marking the start of the time period.

data.ma20 String/null

The 20-period simple moving average price in the reference currency: the mean closing price over the last 20 candles of the requested interval. null until 20 candles of history exist.

data.ma50 String/null

The 50-period simple moving average price in the reference currency: the mean closing price over the last 50 candles of the requested interval. null until 50 candles of history exist.

data.ma100 String/null

The 100-period simple moving average price in the reference currency: the mean closing price over the last 100 candles of the requested interval. null until 100 candles of history exist.

data.ma200 String/null

The 200-period simple moving average price in the reference currency: the mean closing price over the last 200 candles of the requested interval. null until 200 candles of history exist.

data.ema20 String/null

The 20-period exponential moving average price in the reference currency, over the last 20 candles of the requested interval. Weights recent candles more heavily than ma20, so it responds faster to a change in direction. null until 20 candles of history exist.

data.ema50 String/null

The 50-period exponential moving average price in the reference currency, over the last 50 candles of the requested interval. Weights recent candles more heavily than ma50, so it responds faster to a change in direction. null until 50 candles of history exist.

data.ema100 String/null

The 100-period exponential moving average price in the reference currency, over the last 100 candles of the requested interval. Weights recent candles more heavily than ma100, so it responds faster to a change in direction. null until 100 candles of history exist.

data.ema200 String/null

The 200-period exponential moving average price in the reference currency, over the last 200 candles of the requested interval. Weights recent candles more heavily than ma200, so it responds faster to a change in direction. null until 200 candles of history exist.

data.bbUpper20 String/null

The upper Bollinger Band: ma20 plus two standard deviations of the closing price over the same 20 candles. null until 20 candles of history exist, alongside ma20.

data.bbLower20 String/null

The lower Bollinger Band: ma20 minus the same two standard deviations. The band is centred exactly on ma20, which is why no middle-band field is returned and why the deviation can be recovered as (bbUpper20 - ma20) / 2.

Error response

json
HTTP/1.1 404 Not Found
{
  "status": "fail",
  "type": "COIN_NOT_FOUND",
  "message": "Coin not found"
}

Error responses

Error Description
COIN_NOT_FOUND Object The coin could not be found. Try another UUID
Error Description
VALIDATION_ERROR Object The request could not be validated. The response should provide more details.
REFERENCE_UNAVAILABLE Object The reference currency used in the request is not available. Choose another UUID.