ws = new WebSocket("wss://api.coinmetrics.io/v4/timeseries-stream/market-openinterest?markets=binance-BTCUSDT-future&pretty=true&api_key=<your_key>")
ws.onmessage = m => console.log(m.data); ws.onclose = () => console.log("closed")
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/market-openinterest?markets=binance-BTCUSDT-future&pretty=true&api_key=<your_key>'))
curl --request GET \
--url 'wss://api.coinmetrics.io/v4/timeseries-stream/market-openinterest?api_key='<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "wss://api.coinmetrics.io/v4/timeseries-stream/market-openinterest?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/market-openinterest?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/market-openinterest?api_key=")
.asString();require 'uri'
require 'net/http'
url = URI("wss://api.coinmetrics.io/v4/timeseries-stream/market-openinterest?api_key=")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"error": {
"type": "unauthorized",
"message": "Requested resource requires authorization."
}
}Market open interest
Returns a WebSocket stream of open interests for specified markets.
If you are falling behind (slow client) you will get warning message first, then error message and disconnection will happen.
Note: The value_usd field in this endpoint was previously calculated using hardcoded logic that no longer reflects current contract specifications across all exchanges.
To address this, we have deprecated the value_usd field and introduced new, more accurate metrics available via the /timeseries/market-metrics endpoint.
These two metrics should be used as a replacement for the value_usd field going forward:
- open_interest_reported_future_usd to represent the notional value of open interest in U.S. dollars for futures markets
- open_interest_reported_option_notional_usd to represent the notional value of open interest in U.S. dollars for options markets
We also introduced open_interest_reported_option_market_value_usd to represent the market value of open interest in U.S. dollars for options markets.
ws = new WebSocket("wss://api.coinmetrics.io/v4/timeseries-stream/market-openinterest?markets=binance-BTCUSDT-future&pretty=true&api_key=<your_key>")
ws.onmessage = m => console.log(m.data); ws.onclose = () => console.log("closed")
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/market-openinterest?markets=binance-BTCUSDT-future&pretty=true&api_key=<your_key>'))
curl --request GET \
--url 'wss://api.coinmetrics.io/v4/timeseries-stream/market-openinterest?api_key='<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "wss://api.coinmetrics.io/v4/timeseries-stream/market-openinterest?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/market-openinterest?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/market-openinterest?api_key=")
.asString();require 'uri'
require 'net/http'
url = URI("wss://api.coinmetrics.io/v4/timeseries-stream/market-openinterest?api_key=")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"error": {
"type": "unauthorized",
"message": "Requested resource requires authorization."
}
}
