Get coin MACD
Get the Moving Average Convergence Divergence (MACD) for a coin throughout time: the MACD line, its signal line, and the histogram between them. MACD tracks the gap between a fast and a slow exponential moving average of the price, and reads that gap against an average of itself — crossings between the two lines, and the histogram's changes of sign, are read as shifts in momentum.
The lengths are the conventional 12, 26 and 9, and a length counts candles of the interval you request — so interval=day gives the familiar 12/26/9-day MACD, while interval=hour gives an hourly one.
The signal line is an exponential average of the MACD line, not of the price. That is what makes the crossings meaningful: both lines are then in the same units, and macdHistogram is exactly their difference. Because two exponential averages are chained, we read a long run of earlier candles before the first one we return so that both have converged by the time you see them.
https://api.coinranking.com/v2/indicators/:uuid/macd
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 MACD for. |
Query parameters
| Parameter | Description | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
timePeriod (optional) String | The time period for which the MACD data is returned. The number of data points and the default interval are determined by the time period. Default value: 24hAllowed values: 1h 3h 12h 24h 7d 30d 3m 1y 3y 5y 10y all Example:
https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/macd?timePeriod=7d
| ||||||||||||||||||||||||||
interval (optional) String | The interval determines the granularity of each data point, and therefore what one MACD length means. If not provided, a default interval is used based on the selected timePeriod. Only certain intervals are available per timePeriod — see the table below.
Example:
https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/macd?timePeriod=7d&interval=day
| ||||||||||||||||||||||||||
referenceCurrencyUuid (optional) String | UUID of coin (either fiat or crypto), in whose terms the price is measured before the MACD is 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 All three values are expressed in the reference currency, and the conversion happens before the calculation rather than after — so a MACD priced in Bitcoin is a genuinely different series from one priced in US Dollars, not the same numbers rescaled. Default value: yhjMzLPhuIDlExample:
https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/macd?referenceCurrencyUuid=5k-_VTxqtCEI
|
Code examples
curl 'https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/macd?timePeriod=7d&interval=hour&referenceCurrencyUuid=5k-_VTxqtCEI' \
-H 'x-access-token: your-api-key' \
-G const options = {
headers: {
'x-access-token': 'your-api-key',
},
};
fetch('https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/macd?timePeriod=7d&interval=hour&referenceCurrencyUuid=5k-_VTxqtCEI', options)
.then((response) => response.json())
.then((result) => console.log(result)); <?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/macd?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; import requests
headers = {
'x-access-token': 'your-api-key'
}
response = requests.request("GET", "https://api.coinranking.com/v2/indicators/Qwsogvtv82FCd/macd?timePeriod=7d&interval=hour&referenceCurrencyUuid=5k-_VTxqtCEI", headers=headers)
print(response.text) Response
HTTP/1.1 200 OK
{
"status": "success",
"data": [
{
"startingAt": 1774936800,
"macd": "412.7719284471",
"macdSignal": "355.1042938810",
"macdHistogram": "57.6676345661"
},
{
"startingAt": 1774933200,
"macd": "398.2214005593",
"macdSignal": "340.7873602395",
"macdHistogram": "57.4340403198"
}
]
} Response fields
| Property | Description |
|---|---|
status String | Status of the request Allowed values:success |
data Object[] | List of MACD data points, newest first |
data.startingAt Number | An Epoch startingAt in seconds marking the start of the time period. |
data.macd String | The MACD line in the reference currency: the 12-candle exponential moving average minus the 26-candle one, over candles of the requested |
data.macdSignal String/null | The signal line: a 9-candle exponential moving average of |
data.macdHistogram String/null |
|
Error response
HTTP/1.1 404 Not Found
{
"status": "fail",
"type": "COIN_NOT_FOUND",
"message": "Coin not found"
} Error responses
| Error | Description |
|---|---|
FORBIDDEN Object | Production access requires the Growth plan or higher. Free, Basic and Startup plans can use preview access. |
| 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. |