### Get Supported Options Source: https://docs.velo.xyz/api/http Retrieves a list of supported options instruments. ```APIDOC ## GET /options ### Description Retrieves a list of supported options instruments. ### Method GET ### Endpoint /options ``` -------------------------------- ### Python: Get News Source: https://docs.velo.xyz/api/news-api Fetches past news stories starting from a specified millisecond timestamp. Defaults to fetching all news if no timestamp is provided. ```python news.get_news(begin) ``` -------------------------------- ### Quick Start with Velo NodeJS Client Source: https://docs.velo.xyz/api/nodejs Demonstrates how to initialize the Velo client, fetch futures data, select specific columns and products, and iterate through historical rows. Ensure you have your 'api_key' to instantiate the client. ```javascript const velo = require('velo-node') async function doWork() { const futures = await client.futures() const future = futures[0] const columns = client.futuresColumns() const twoColumns = columns.slice(0, 2) const params = { type: 'futures', columns: twoColumns, exchanges: [future.exchange], products: [future.product], begin: Date.now() - 1000 * 60 * 60 * 11, // 10 minutes end: Date.now(), resolution: '1m' // 1 minute } const rows = client.rows(params) for await (const row of rows) { console.log(row) } } const client = new velo.Client('api_key') doWork() ``` -------------------------------- ### Quick Start: Fetch Market Data with cURL Source: https://docs.velo.xyz/api/http Use this command to quickly fetch market data for specified coins. Ensure you replace 'api_key' with your actual API key. ```bash $ curl -v --user "api:api_key" "https://api.velo.xyz/api/v1/caps?coins=BTC,ETH" ``` -------------------------------- ### Get Supported Spot Pairs Source: https://docs.velo.xyz/api/http Retrieves a list of supported spot trading pairs. ```APIDOC ## GET /spot ### Description Retrieves a list of supported spot trading pairs. ### Method GET ### Endpoint /spot ``` -------------------------------- ### Get Supported Futures Source: https://docs.velo.xyz/api/http Retrieves a list of supported futures instruments. ```APIDOC ## GET /futures ### Description Retrieves a list of supported futures instruments. ### Method GET ### Endpoint /futures ``` -------------------------------- ### Quick Start with Velo Python Client Source: https://docs.velo.xyz/api/python Initializes the Velo client and demonstrates fetching futures data, including selecting specific futures and their columns, and retrieving historical data for the last 10 minutes. ```python from velodata import lib as velo # new velo client client = velo.client('api_key') # get futures and pick one future = client.get_futures()[0] # get futures columns and pick two columns = client.get_futures_columns()[:2] # last 10 minutes in 1 minute resolution params = { 'type': 'futures', 'columns': columns, 'exchanges': [future['exchange']], 'products': [future['product']], 'begin': client.timestamp() - 1000 * 60 * 11, 'end': client.timestamp(), 'resolution': '1m' } # returns dataframe print(client.get_rows(params)) ``` -------------------------------- ### Python Quick Start: News API Source: https://docs.velo.xyz/api/news-api Initializes the Velo client with an API key to fetch past news stories or stream new ones. Requires the velodata library and asyncio. ```python import asyncio from velodata import lib as velo # new velo client client = velo.client('api_key') # get past stories print(client.news.get_news()) # stream new stories async def stream(): async for message in client.news.stream_news(): if(message in ('connected', 'heartbeat', 'closed')): print(message) else: print(json.loads(message)) asyncio.run(stream()) ``` -------------------------------- ### NodeJS: Get News Source: https://docs.velo.xyz/api/news-api Fetches a list of past news stories, optionally starting from a specified millisecond timestamp. Returns a list of news objects. ```javascript news.stories({begin}) ``` -------------------------------- ### NodeJS Quick Start: News API Source: https://docs.velo.xyz/api/news-api Initializes the Velo NodeJS client with an API key to retrieve past news stories or subscribe to a real-time stream. Handles connection events and incoming messages. ```javascript const velo = require('velo-node') async function doWork() { // get past stories const stories = await client.news.stories() console.log(stories) // stream new stories const socket = client.news.stream() socket.on('open', () => console.log('connected')) socket.on('close', () => console.log('closed')) socket.on('error', (err) => { console.log('error', err) socket.close() }) socket.on('message', (data) => { const json = JSON.parse(data.toString()) if (json.heartbeat) { console.log('heartbeat') return } console.log(json) }) } const client = new velo.Client('api_key') doWork() ``` -------------------------------- ### Get Status Source: https://docs.velo.xyz/api/http Retrieves the current status of the API. ```APIDOC ## GET /status ### Description Retrieves the current status of the API. ### Method GET ### Endpoint /status ``` -------------------------------- ### Get Market Caps Source: https://docs.velo.xyz/api/python Retrieves the latest market capitalization data for specified coins. ```APIDOC ## get_market_caps(coins) ### Description Retrieves the latest market capitalization data for specified coins. ### Parameters #### Query Parameters - **coins** (list) - Required - A list of coin identifiers. ### Response Returns a DataFrame containing the latest market capitalization data. ``` -------------------------------- ### HTTP: Get News Source: https://docs.velo.xyz/api/news-api Retrieves news data using an HTTP GET request to the /news endpoint. Supports filtering by a 'begin' timestamp to fetch news published after a certain time. ```bash $ curl -v --user "api:api_key" "https://api.velo.xyz/api/n/news?begin=0" ``` -------------------------------- ### Get Market Caps Source: https://docs.velo.xyz/api/http Retrieves the latest market capitalization data for specified coins. Returns data in CSV format. ```APIDOC ## GET /caps ### Description Retrieves the latest market capitalization data for specified coins. Returns data in CSV format. ### Method GET ### Endpoint /caps ### Parameters #### Query Parameters - **coins** (string) - Required - Comma-separated list of coins ### Response #### Success Response (200) - Returns text in CSV format. ``` -------------------------------- ### Get Rows Source: https://docs.velo.xyz/api/python Retrieves historical data rows for futures, options, or spot markets. ```APIDOC ## get_rows(params) ### Description Retrieves historical data rows for futures, options, or spot markets. ### Parameters #### Query Parameters - **type** (string) - Required - Specifies the data type: 'futures', 'options', or 'spot'. - **exchanges** (list) - Optional - A list of exchange identifiers. - **products** (list) - Optional - A list of product identifiers. If both 'coins' and 'products' are specified, only 'products' will be used. - **coins** (list) - Optional - A list of coin identifiers. - **columns** (list) - Optional - A list of column names to retrieve. - **begin** (millisecond timestamp) - Required - The start of the time period. - **end** (millisecond timestamp) - Required - The end of the time period. - **resolution** (minutes (integer) or resolution (string)) - Required - The data resolution. ### Response Returns a DataFrame containing the requested data. ``` -------------------------------- ### NodeJS - Get News Source: https://docs.velo.xyz/api/news-api Retrieves past news stories. Accepts an optional 'begin' parameter, which is a millisecond timestamp to filter news published after that time. ```APIDOC ## Get News ### Description Retrieves past news stories. Accepts an optional 'begin' parameter, which is a millisecond timestamp to filter news published after that time. ### Method Signature `news.stories({begin})` ### Parameters - **begin** (optional, defaults to 0): millisecond timestamp to only fetch news after ### Returns List of news Objects ``` -------------------------------- ### Python - Get News Source: https://docs.velo.xyz/api/news-api Fetches past news stories. Accepts an optional millisecond timestamp to retrieve news published after a specific time. ```APIDOC ## Get News ### Description Fetches past news stories. Accepts an optional millisecond timestamp to retrieve news published after a specific time. ### Method Signature `news.get_news(begin)` ### Parameters - **begin** (optional, defaults to 0): millisecond timestamp to only fetch news after ### Returns List of news objects (dicts) ``` -------------------------------- ### Get Options Term Structure Source: https://docs.velo.xyz/api/python Retrieves the latest term structure data for specified options coins. ```APIDOC ## get_term_structure(coins) ### Description Retrieves the latest term structure data for specified options coins. ### Parameters #### Query Parameters - **coins** (list) - Required - A list of coin identifiers. ### Response Returns a DataFrame containing the latest term structure data. ``` -------------------------------- ### HTTP - Get News Source: https://docs.velo.xyz/api/news-api Retrieves news articles. Accepts an optional 'begin' query parameter, which is a millisecond timestamp to filter news published after that time. ```APIDOC ## Get News ### Description Retrieves news articles. Accepts an optional 'begin' query parameter, which is a millisecond timestamp to filter news published after that time. ### Method GET ### Endpoint /news ### Query Parameters - **begin** (optional, defaults to 0): millisecond timestamp to only fetch news after ### Returns JSON ``` -------------------------------- ### Get Options Term Structure Source: https://docs.velo.xyz/api/http Retrieves the latest options term structure data for specified coins. Returns data in CSV format. ```APIDOC ## GET /terms ### Description Retrieves the latest options term structure data for specified coins. Returns data in CSV format. ### Method GET ### Endpoint /terms ### Parameters #### Query Parameters - **coins** (string) - Required - Comma-separated list of coins ### Response #### Success Response (200) - Returns text in CSV format. ``` -------------------------------- ### Get Rows Source: https://docs.velo.xyz/api/http Retrieves data rows for futures, options, or spot markets. Returns data in CSV format. Supports filtering by exchanges, products, coins, columns, and time range. Batching is recommended for large datasets. ```APIDOC ## GET /rows ### Description Retrieves data rows for futures, options, or spot markets. Returns data in CSV format. Supports filtering by exchanges, products, coins, columns, and time range. Batching is recommended for large datasets. ### Method GET ### Endpoint /rows ### Parameters #### Query Parameters - **type** (string) - Required - 'futures', 'options', or 'spot' - **exchanges** (string) - Optional - Comma-separated list of exchanges - **products** (string) - Optional - Comma-separated list of products - **coins** (string) - Optional - Comma-separated list of coins - **columns** (string) - Optional - Comma-separated list of columns - **begin** (integer) - Optional - Millisecond timestamp for the start of the range - **end** (integer) - Optional - Millisecond timestamp for the end of the range - **resolution** (string) - Optional - Resolution string (e.g., '1min', '1h') *Note: If both `coins` and `products` are specified, only `products` will be used.* ### Response #### Success Response (200) - Returns text in CSV format. ``` -------------------------------- ### Get Orderbook Data Source: https://docs.velo.xyz/api/python Retrieves orderbook depth data in snapshots with the specified resolution over a given time period. This function yields objects containing timestamp, midprice, and price-value pairs. ```APIDOC ## depth(params) ### Description Retrieves orderbook depth data in snapshots with the specified resolution over the specified time period. ### Parameters #### Query Parameters - **exchange** (string) - Required - The exchange the product is listed on. - **product** (string) - Required - The product identifier. - **coin** (string) - Optional - Use only for aggregated orderbook data. If specified, 'product' and 'exchange' are ignored. - **begin** (millisecond timestamp) - Required - The start of the time period. - **end** (millisecond timestamp) - Required - The end of the time period. - **resolution** (minutes (integer) or resolution (string)) - Required - The data resolution. ### Response Yields objects with `timestamp`, `midprice`, and `price:value` pairs. ### Request Example ```python from velodata import lib as velo day_in_ms = 1000 * 60 * 60 * 24 # new velo client client = velo.client('api_key') # pick a supported future utures = client.get_futures() utures_with_orderbook_data = [f for f in futures if f['depth']] future = futures_with_orderbook_data[0] # last 24 hours in 5 minute resolution params = { 'exchange': future['exchange'], 'product': future['product'], 'begin': client.timestamp() - day_in_ms, 'end': client.timestamp(), 'resolution': '5m' } # prints orderbook at each timestamp as it finishes for df in client.depth(params): print(df) ``` ``` -------------------------------- ### Spot-Volume Correlation Analysis Source: https://docs.velo.xyz/api/python Fetches options data including delta-volume and index price, calculates the percentage change for both, and then computes the rolling 24-hour correlation between them. ```python from velodata import lib as velo day_in_ms = 1000 * 60 * 60 * 24 # new velo client client = velo.client('api_key') # from 5 days ago in 1 hour resolution params = { 'type': 'options', 'columns': ['dvol_close', 'index_price'], 'exchanges': ['deribit'], 'products': ['BTC'], 'begin': client.timestamp() - day_in_ms * 5, 'end': client.timestamp(), 'resolution': '1h' } # returns dataframe df = client.get_rows(params) # simple rolling 24 hour correlation print( df['dvol_close'].pct_change().rolling(24).corr(df['index_price'].pct_change()) ) ``` -------------------------------- ### Helper Methods Source: https://docs.velo.xyz/api/nodejs Provides methods to retrieve status information and lists of supported financial instruments and their associated columns. ```APIDOC ## Helper Methods ### `status()` Retrieves the current status of the API. ### `futures(delisted=False)` Retrieves a list of supported futures contracts. The `delisted` parameter can be used to include delisted contracts. ### `options()` Retrieves a list of supported options contracts. ### `spot(delisted=False)` Retrieves a list of supported spot trading pairs. The `delisted` parameter can be used to include delisted pairs. ### `futuresColumns()` Retrieves the available columns for futures data. ### `optionsColumns()` Retrieves the available columns for options data. ### `spotColumns()` Retrieves the available columns for spot data. ``` -------------------------------- ### Helper Methods Source: https://docs.velo.xyz/api/python Provides access to various utility functions for retrieving status information, supported assets, and formatting timestamps. ```APIDOC ## Helper Methods ### get_status() Returns the key status information. ### get_futures(delisted=False) Returns a list of supported futures contracts. `delisted` (boolean, optional) defaults to `False`. ### get_options() Returns a list of supported options contracts. ### get_spot(delisted=False) Returns a list of supported spot trading pairs. `delisted` (boolean, optional) defaults to `False`. ### get_futures_columns() Returns a list of supported columns for futures data. ### get_options_columns() Returns a list of supported columns for options data. ### get_spot_columns() Returns a list of supported columns for spot data. ### timestamp() Returns the current millisecond timestamp. ``` -------------------------------- ### Options Columns Source: https://docs.velo.xyz/api/columns List of available columns for options data. Refer to the provided link for details on how options values are calculated. ```text 'iv_1w', 'iv_1m', 'iv_3m', 'iv_6m', 'skew_1w', 'skew_1m', 'skew_3m', 'skew_6m', 'vega_coins', 'vega_dollars', 'call_delta_coins', 'call_delta_dollars', 'put_delta_coins', 'put_delta_dollars', 'gamma_coins', 'gamma_dollars', 'call_volume', 'call_premium', 'call_notional', 'put_volume', 'put_premium', 'put_notional', 'dollar_volume', 'dvol_open', 'dvol_high', 'dvol_low', 'dvol_close', 'index_price' ``` -------------------------------- ### Fetch Futures Data with Python Source: https://docs.velo.xyz/api/intro Use the velodata Python library to fetch futures data. Ensure you have an API key and specify parameters like columns, exchanges, products, time range, and resolution. ```python from velodata import lib as velo client = velo.client('api_key') ten_minutes_ms = 1000 * 60 * 10 params = { 'type': 'futures', 'columns': ['close_price', 'funding_rate'], 'exchanges': ['binance-futures', 'bybit'], 'products': ['BTCUSDT'], 'begin': client.timestamp() - ten_minutes_ms, 'end': client.timestamp(), 'resolution': '1m' } print(client.get_rows(params)) ``` -------------------------------- ### Spot Columns Source: https://docs.velo.xyz/api/columns List of available columns for spot data. ```text 'open_price', 'high_price', 'low_price', 'close_price', 'coin_volume', 'dollar_volume', 'buy_trades', 'sell_trades', 'total_trades', 'buy_coin_volume', 'sell_coin_volume', 'buy_dollar_volume', 'sell_dollar_volume', ``` -------------------------------- ### OI-Weighted Funding Rate Calculation Source: https://docs.velo.xyz/api/python Retrieves funding rate and open interest data for futures, calculates the OI-weighted funding rate by summing the product of funding rate and open interest, and then dividing by the sum of open interest. ```python from velodata import lib as velo hour_in_ms = 1000 * 60 * 60 # new velo client client = velo.client('api_key') # from one hour ago in 1 minute resolution params = { 'type': 'futures', 'columns': ['funding_rate', 'coin_open_interest_close'], 'exchanges': ['binance-futures', 'bybit', 'okex-swap'], 'coins': ['SOL'], 'begin': client.timestamp() - hour_in_ms, 'end': client.timestamp(), 'resolution': '1m' } # returns dataframe df = client.get_rows(params) # oi-weighted funding = SUM(funding*OI) / SUM(OI) df['funding_rate'] = df['funding_rate'] * df['coin_open_interest_close'] df = df.groupby(df['time']).sum(numeric_only=True) df['funding_rate'] = df['funding_rate'] / df['coin_open_interest_close'] print(df['funding_rate']) ``` -------------------------------- ### Handling Large Data Requests with stream_rows Source: https://docs.velo.xyz/api/python Demonstrates how to handle potentially large data requests by using `batch_rows` and `stream_rows`. This approach allows processing data in batches as they become available, rather than waiting for a single large DataFrame. ```python from velodata import lib as velo day_in_ms = 1000 * 60 * 60 * 24 # new velo client client = velo.client('api_key') # from 5 days ago in 1 minute resolution # 2 columns * 4 products * 1 exchange * 7200 rows = 57600 values params = { 'type': 'futures', 'columns': ['open_price', 'close_price'], 'exchanges': ['binance-futures'], 'products': ['LTCUSDT', 'ETCUSDT', 'BCHUSDT', 'SOLUSDT'], 'begin': client.timestamp() - day_in_ms * 5, 'end': client.timestamp(), 'resolution': '1m' } # creates 3 batches (57600 values / 22500 limit) batches = client.batch_rows(params) # prints each batch as it finishes for df in client.stream_rows(batches): print(df) ``` -------------------------------- ### Futures Columns Source: https://docs.velo.xyz/api/columns List of available columns for futures data. All funding rates are normalized to per 8 hours. A special case exists for '3m_basis_ann' which requires no additional parameters. ```text 'open_price', 'high_price', 'low_price', 'close_price', 'coin_volume', 'dollar_volume', 'buy_trades', 'sell_trades', 'total_trades', 'buy_coin_volume', 'sell_coin_volume', 'buy_dollar_volume', 'sell_dollar_volume', 'coin_open_interest_high', 'coin_open_interest_low', 'coin_open_interest_close', 'dollar_open_interest_high', 'dollar_open_interest_low', 'dollar_open_interest_close', 'funding_rate', 'funding_rate_avg', 'premium', 'buy_liquidations', 'sell_liquidations', 'buy_liquidations_coin_volume', 'sell_liquidations_coin_volume', 'liquidations_coin_volume', 'buy_liquidations_dollar_volume', 'sell_liquidations_dollar_volume', 'liquidations_dollar_volume' ``` -------------------------------- ### Batch Rows Source: https://docs.velo.xyz/api/python Prepares batches of historical data rows for futures, options, or spot markets, suitable for streaming. ```APIDOC ## batch_rows(params) ### Description Prepares batches of historical data rows for futures, options, or spot markets, suitable for streaming. ### Parameters #### Query Parameters - **type** (string) - Required - Specifies the data type: 'futures', 'options', or 'spot'. - **exchanges** (list) - Optional - A list of exchange identifiers. - **products** (list) - Optional - A list of product identifiers. If both 'coins' and 'products' are specified, only 'products' will be used. - **coins** (list) - Optional - A list of coin identifiers. - **columns** (list) - Optional - A list of column names to retrieve. - **begin** (millisecond timestamp) - Required - The start of the time period. - **end** (millisecond timestamp) - Required - The end of the time period. - **resolution** (minutes (integer)) - Required - The data resolution. ### Response Returns a list of batches for use in `stream_rows`. ``` -------------------------------- ### Python: Stream News Source: https://docs.velo.xyz/api/news-api Establishes a WebSocket connection to stream new news stories in real-time. Returns a generator that yields connection status messages or news objects. ```python news.stream_news() ``` -------------------------------- ### Futures Basis Data Request Source: https://docs.velo.xyz/api/python Requests the '3m_basis_ann' for specified coins, suitable for BTC and ETH. Note that for this specific metric, products and exchanges should not be specified. ```python from velodata import lib as velo day_in_ms = 1000 * 60 * 60 * 24 # new velo client client = velo.client('api_key') # from 5 days ago in 1 hour resolution params = { 'type': 'futures', 'columns': ['3m_basis_ann'], 'coins': ['BTC', 'ETH'], 'begin': client.timestamp() - day_in_ms * 5, 'end': client.timestamp(), 'resolution': '1h' } # returns dataframe print(client.get_rows(params)) ``` -------------------------------- ### Fetch Orderbook Data Snapshots Source: https://docs.velo.xyz/api/python Retrieves orderbook depth data in snapshots with a specified resolution over a given time period. Requires a Velo client instance and parameters specifying the future, time range, and resolution. ```python from velodata import lib as velo day_in_ms = 1000 * 60 * 60 * 24 # new velo client client = velo.client('api_key') # pick a supported future utures = client.get_futures() utures_with_orderbook_data = [f for f in futures if f['depth']] future = futures_with_orderbook_data[0] # last 24 hours in 5 minute resolution params = { 'exchange': future['exchange'], 'product': future['product'], 'begin': client.timestamp() - day_in_ms, 'end': client.timestamp(), 'resolution': '5m' } # prints orderbook at each timestamp as it finishes for df in client.depth(params): print(df) ``` -------------------------------- ### Aggregated Spot CVD Calculation Source: https://docs.velo.xyz/api/python Fetches spot data for multiple exchanges and products, aggregates it by time, and calculates the volume delta (buy volume - sell volume) and its cumulative sum over a 24-hour period. ```python from velodata import lib as velo day_in_ms = 1000 * 60 * 60 * 24 # new velo client client = velo.client('api_key') # from one day ago in 10 minute resolution params = { 'type': 'spot', 'columns': ['buy_dollar_volume', 'sell_dollar_volume'], 'exchanges': ['coinbase', 'binance', 'bybit-spot'], 'products': ['ETHUSDT', 'ETH-USD'], 'begin': client.timestamp() - day_in_ms, 'end': client.timestamp(), 'resolution': '10m' } # returns dataframe df = client.get_rows(params) # aggregate all exchanges df = df.groupby(df['time']).sum(numeric_only=True) # compute volume delta df['delta'] = df['buy_dollar_volume'] - df['sell_dollar_volume'] # cumulative print(df['delta'].cumsum()) ``` -------------------------------- ### Data Methods Source: https://docs.velo.xyz/api/nodejs Provides methods for fetching time-series and real-time financial data, including rows, term structure, market caps, and orderbook data. ```APIDOC ## Data Methods ### `rows(params)` Asynchronously returns individual rows (Objects) for futures, options, or spot data. **Parameters:** * `params` (Object) - An object containing query parameters. * `type` (string) - Required. The data type: 'futures', 'options', or 'spot'. * `exchanges` (array) - Optional. An array of exchange identifiers. * `products` (array) - Optional. An array of product identifiers. * `coins` (array) - Optional. An array of coin identifiers. * `columns` (array) - Optional. An array of column names to retrieve. * `begin` (number) - Optional. The start timestamp in milliseconds. * `end` (number) - Optional. The end timestamp in milliseconds. * `resolution` (string|number) - Optional. The data resolution (e.g., '1m' for 1 minute, or an integer representing minutes). *Note: If both `coins` and `products` are specified, only `products` will be used.* ### `termStructure(params)` Returns the latest values for options term structure. **Parameters:** * `params` (Object) - An object containing query parameters. * `coins` (array) - Required. An array of coin identifiers. **Response:** * Returns an Object containing the term structure data. ### `marketCaps(params)` Returns the latest market capitalization values for specified coins. **Parameters:** * `params` (Object) - An object containing query parameters. * `coins` (array) - Required. An array of coin identifiers. **Response:** * Returns an Object containing the market cap data. ### `depth(params)` Asynchronously returns orderbook data. **Parameters:** * `params` (Object) - An object containing query parameters. * `exchange` (string) - Required for specific product orderbook. The exchange identifier. * `product` (string) - Required for specific product orderbook. The product identifier. * `coin` (string) - Required for aggregated orderbook. The coin identifier. * `begin` (number) - Optional. The start timestamp in milliseconds. * `end` (number) - Optional. The end timestamp in milliseconds. * `resolution` (string|number) - Optional. The data resolution (e.g., '5m' for 5 minutes, or an integer representing minutes). **Response:** * Returns an Object with `time`, `mid`, and `price:value` pairs. *Note: Use 'coin' only for aggregated orderbook data. Use 'product' and 'exchange' for a specific product.* ``` -------------------------------- ### Fetch Orderbook Data with Velo NodeJS Client Source: https://docs.velo.xyz/api/nodejs Shows how to retrieve orderbook data for a specific future. It filters futures to find one with depth information, sets a time range, and iterates through the orderbook entries. Replace 'api_key' with your actual API key. ```javascript const velo = require('velo-node') async function doWork() { const futures = await client.futures() const future = futures.filter((f) => f.depth)[0] const dayInMs = 1000 * 60 * 60 * 24 const params = { exchange: future.exchange, product: future.product, begin: Date.now() - dayInMs, end: Date.now(), resolution: '5m' } const iter = client.depth(params) for await (const depth of iter) { console.log(depth) } } const client = new velo.Client('api_key') doWork() ``` -------------------------------- ### NodeJS - Stream News Source: https://docs.velo.xyz/api/news-api Establishes a WebSocket stream for real-time news updates. Emits connection status events and news objects. ```APIDOC ## Stream News ### Description Establishes a WebSocket stream for real-time news updates. Emits connection status events and news objects. ### Method Signature `news.stream()` ### Returns WebSocket instance that emits 'connected', 'heartbeat', 'closed', or news Object ``` -------------------------------- ### HTTP: News Endpoint Source: https://docs.velo.xyz/api/news-api The /news endpoint is used to fetch news data. It accepts an optional 'begin' parameter for time-based filtering and returns data in JSON format. ```plaintext /news * begin (optional, defaults to 0): millisecond timestamp to only fetch news after Returns JSON ``` -------------------------------- ### NodeJS: Stream News Source: https://docs.velo.xyz/api/news-api Initiates a WebSocket stream for real-time news updates. The stream emits connection status events and news objects. ```javascript news.stream() ``` -------------------------------- ### Python: Close News Stream Source: https://docs.velo.xyz/api/news-api Closes the active WebSocket connection for streaming news, terminating the generator. ```python news.close_stream() ``` -------------------------------- ### News API Object Structure Source: https://docs.velo.xyz/api/news-api Defines the structure of a news object returned by the API, including fields like id, time, headline, source, priority, coins, summary, and link. Edit and delete events have specific structures. ```json { id: 55, // unique identifier time: 1704085200000, // timestamp the news was published effectiveTime: 1704085200000, // timestamp the news happened headline: "Hello world", source: "Velo", priority: 2, // 1 = top priority only, 2 = everything else coins: ['BTC'], // list of relevant coins summary: "# Hello world", // may include markdown link: "https://velo.xyz" // source link } ``` -------------------------------- ### Stream Rows Source: https://docs.velo.xyz/api/python Streams historical data rows as DataFrames using pre-defined batches. ```APIDOC ## stream_rows(batches) ### Description Streams historical data rows as DataFrames using pre-defined batches. ### Parameters #### Query Parameters - **batches** (list) - Required - A list of batches returned from the `batch_rows` function. ### Response Yields DataFrames containing the requested data. ``` -------------------------------- ### Python - Stream News Source: https://docs.velo.xyz/api/news-api Streams new news stories in real-time. Returns a generator that yields connection status messages or news objects. ```APIDOC ## Stream News ### Description Streams new news stories in real-time. Returns a generator that yields connection status messages or news objects. ### Method Signature `news.stream_news()` ### Returns Generator yielding 'connected', 'heartbeat', 'closed', or news object (dict) ``` -------------------------------- ### Python - Close Stream Source: https://docs.velo.xyz/api/news-api Closes the active WebSocket connection and terminates the news stream generator. ```APIDOC ## Close Stream ### Description Closes the active WebSocket connection and terminates the news stream generator. ### Method Signature `news.close_stream()` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.