JavaScript
// Streams the levels for CMBIBTC index
ws = new WebSocket("wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?indexes=CMBIBTC&pretty=true&api_key=<your_key>")
ws.onmessage = m => console.log(m.data); ws.onclose = () => console.log("closed")
# Streams the levels for CMBIBTC index
import asyncio
import websockets
async def handle(uri):
async with websockets.connect(uri) as websocket:
while True:
print(await websocket.recv())
asyncio.get_event_loop().run_until_complete(handle('wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?indexes=CMBIBTC&pretty=true&api_key=<your_key>'))
curl --request GET \
--url 'wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key='<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key=")
.asString();require 'uri'
require 'net/http'
url = URI("wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key=")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"index": "CMBIWORK",
"level": "389473805.713838875",
"time": "2017-05-22T00:00:00.000000000Z",
"cm_sequence_id": "0"
}Timeseries stream
Index levels
Returns a stream of levels for specified indexes.
If you are falling behind (slow client) you will get warning message first, then error message and disconnect will happen.
GET
/
timeseries-stream
/
index-levels
JavaScript
// Streams the levels for CMBIBTC index
ws = new WebSocket("wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?indexes=CMBIBTC&pretty=true&api_key=<your_key>")
ws.onmessage = m => console.log(m.data); ws.onclose = () => console.log("closed")
# Streams the levels for CMBIBTC index
import asyncio
import websockets
async def handle(uri):
async with websockets.connect(uri) as websocket:
while True:
print(await websocket.recv())
asyncio.get_event_loop().run_until_complete(handle('wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?indexes=CMBIBTC&pretty=true&api_key=<your_key>'))
curl --request GET \
--url 'wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key='<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key=")
.asString();require 'uri'
require 'net/http'
url = URI("wss://api.coinmetrics.io/v4/timeseries-stream/index-levels?api_key=")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"index": "CMBIWORK",
"level": "389473805.713838875",
"time": "2017-05-22T00:00:00.000000000Z",
"cm_sequence_id": "0"
}Authorizations
Query Parameters
Comma separated list of indexes.
Use the /catalog-all-v2/index-levels endpoint for the full list of supported indexes.
Example:
"CMBIBE"
Response
Index levels WebSocket message.
Information about index level.

