### Install velo-python Library Source: https://github.com/velodataorg/velo-python/blob/main/README.md Install the velo-python library using pip. This is the first step to using the Velo API in your Python projects. ```bash pip install velodata ``` -------------------------------- ### Get News by Story ID (Pagination) Source: https://context7.com/velodataorg/velo-python/llms.txt Fetches news stories starting from a specific story ID, useful for paginating through news archives. An initialized Velo client is necessary. ```python from velodata import lib as velo client = velo.client('your_api_key') # Get news starting from a specific story ID (pagination) older_stories = client.get_news(begin=100) print(older_stories) ``` -------------------------------- ### Get Options Products Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves a list of all available options products across supported exchanges. Returns product metadata for options contracts. ```APIDOC ## Get Options Products Retrieves a list of all available options products. Returns product metadata for options contracts across supported exchanges. ### Method GET ### Endpoint `/options` ### Response Example ```json [ {'exchange': 'deribit', 'product': 'BTC-29DEC23-40000-C', 'coin': 'BTC', ...}, ... ] ``` ### Request Example ```python from velodata import lib as velo client = velo.client('your_api_key') # Get all options products options = client.get_options() print(options) ``` ``` -------------------------------- ### Complete Data Analysis Workflow Source: https://context7.com/velodataorg/velo-python/llms.txt A comprehensive example combining multiple Velo API methods to discover products, fetch historical futures data, and perform basic analysis. Requires velodata, pandas, and an initialized Velo client. ```python from velodata import lib as velo import pandas as pd client = velo.client('your_api_key') # 1. Discover available products futures = client.get_futures() btc_futures = [f for f in futures if f['coin'] == 'BTC'] print(f"Found {len(btc_futures)} BTC futures products") # 2. Get available columns columns = client.get_futures_columns() selected_columns = ['close_price', 'dollar_volume', 'funding_rate', 'dollar_open_interest_close'] # 3. Fetch historical data params = { 'type': 'futures', 'columns': selected_columns, 'exchanges': ['binance'], 'products': ['BTCUSDT'], 'begin': client.timestamp() - 1000 * 60 * 60 * 24 * 7, # 7 days 'end': client.timestamp(), 'resolution': '1h' } df = client.get_rows(params) print(f"Retrieved {len(df)} hourly candles") # 4. Analyze the data print(f"Price range: ${df['close_price'].min():,.2f} - ${df['close_price'].max():,.2f}") print(f"Total volume: ${df['dollar_volume'].sum():,.0f}") print(f"Avg funding rate: {df['funding_rate'].mean():.6f}") print(f"Max open interest: ${df['dollar_open_interest_close'].max():,.0f}") # 5. Get current market caps for context caps = client.get_market_caps(['BTC', 'ETH']) print(f"Current BTC market cap: ${caps[caps['coin'] == 'BTC']['market_cap'].values[0]:,.0f}") ``` -------------------------------- ### Get Spot Columns Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves a list of available data columns for spot market queries, including OHLCV and trade metrics. ```APIDOC ## Get Spot Columns ### Description Returns the list of available data columns for spot market queries including OHLCV and trade metrics. ### Method GET ### Endpoint /spot/columns ### Parameters None ### Request Example None ### Response #### Success Response (200) - **columns** (list[string]) - A list of available spot market data columns. #### Response Example ```json [ "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" ] ``` ``` -------------------------------- ### Get Current Market Caps Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves current market capitalization data for specified cryptocurrencies. Pass a list of coin symbols. ```python from velodata import lib as velo client = velo.client('your_api_key') # Get market caps for multiple coins coins = ['BTC', 'ETH', 'SOL', 'AVAX'] market_caps = client.get_market_caps(coins) print(market_caps) # Output: # coin market_cap # 0 BTC 700000000000 # 1 ETH 250000000000 # 2 SOL 30000000000 # 3 AVAX 10000000000 ``` -------------------------------- ### Initialize Velo Client and Fetch Futures Data Source: https://github.com/velodataorg/velo-python/blob/main/README.md Initialize the Velo client with an API key. This snippet demonstrates how to get futures, select specific columns, and retrieve historical data for a given future within a specified time range and resolution. ```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)) ``` -------------------------------- ### Get Spot Market Columns Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves a list of available data columns for spot market queries. This includes OHLCV and trade metrics. ```python from velodata import lib as velo client = velo.client('your_api_key') columns = client.get_spot_columns() print(columns) # Output: [ # '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' # ] ``` -------------------------------- ### Get Options Columns Source: https://context7.com/velodataorg/velo-python/llms.txt Returns the list of available data columns for options queries, including implied volatility, greeks, and volume metrics. ```APIDOC ## Get Options Columns Returns the list of available data columns for options queries including implied volatility, greeks, and volume metrics. ### Method GET ### Endpoint `/options/columns` ### Response Example ```json [ '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' ] ``` ### Request Example ```python from velodata import lib as velo client = velo.client('your_api_key') columns = client.get_options_columns() print(columns) ``` ``` -------------------------------- ### Get Market Caps Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves current market capitalization data for specified cryptocurrencies. ```APIDOC ## Get Market Caps ### Description Retrieves current market capitalization data for specified cryptocurrencies. ### Method GET ### Endpoint /market_caps ### Parameters #### Query Parameters - **coins** (list[string]) - Required - A list of cryptocurrency symbols (e.g., ['BTC', 'ETH']). ### Request Example `GET /market_caps?coins=BTC,ETH,SOL,AVAX` ### Response #### Success Response (200) - **DataFrame** - A pandas DataFrame with 'coin' and 'market_cap' columns. #### Response Example ``` coin market_cap 0 BTC 700000000000 1 ETH 250000000000 2 SOL 30000000000 3 AVAX 10000000000 ``` ``` -------------------------------- ### Get Recent News Stories Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves a list of recent cryptocurrency news stories. Requires an initialized Velo client with an API key. ```python from velodata import lib as velo client = velo.client('your_api_key') # Get recent news stories stories = client.get_news() print(stories) ``` -------------------------------- ### Get Spot Products Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves a list of all available spot trading pairs. The `delisted` parameter can be used to include pairs that are no longer actively traded. ```APIDOC ## Get Spot Products Retrieves a list of all available spot trading pairs. Returns product metadata for spot markets across supported exchanges. ### Method GET ### Endpoint `/spot` ### Query Parameters - **delisted** (boolean) - Optional - If True, includes delisted spot pairs. ### Response Example ```json [ {'exchange': 'binance', 'product': 'BTCUSDT', 'coin': 'BTC', ...}, ... ] ``` ### Request Example ```python from velodata import lib as velo client = velo.client('your_api_key') # Get all active spot products spot = client.get_spot() print(spot) # Include delisted spot pairs all_spot = client.get_spot(delisted=True) ``` ``` -------------------------------- ### Get Futures Products Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves a list of all available futures products across supported exchanges. The `delisted` parameter can be used to include products that are no longer actively traded. ```APIDOC ## Get Futures Products Retrieves a list of all available futures products across supported exchanges. Returns a list of dictionaries containing product metadata including exchange, product name, and listing status. ### Method GET ### Endpoint `/futures` ### Query Parameters - **delisted** (boolean) - Optional - If True, includes delisted products. ### Response Example ```json [ {'exchange': 'binance', 'product': 'BTCUSDT', 'coin': 'BTC', ...}, {'exchange': 'bybit', 'product': 'ETHUSDT', 'coin': 'ETH', ...}, ... ] ``` ### Request Example ```python from velodata import lib as velo client = velo.client('your_api_key') # Get all active futures products futures = client.get_futures() print(futures) # Include delisted products all_futures = client.get_futures(delisted=True) print(f"Total futures (including delisted): {len(all_futures)}") ``` ``` -------------------------------- ### Get Futures Columns Source: https://context7.com/velodataorg/velo-python/llms.txt Returns the list of available data columns for futures queries. These column names are used in the `get_rows()` parameters to specify which metrics to retrieve. ```APIDOC ## Get Futures Columns Returns the list of available data columns for futures queries. These column names are used in the get_rows() params to specify which metrics to retrieve. ### Method GET ### Endpoint `/futures/columns` ### Response Example ```json [ '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' ] ``` ### Request Example ```python from velodata import lib as velo client = velo.client('your_api_key') columns = client.get_futures_columns() print(columns) ``` ``` -------------------------------- ### Get Term Structure Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves futures term structure data, showing the relationship between futures prices across different expiration dates. ```APIDOC ## Get Term Structure ### Description Retrieves futures term structure data showing the relationship between futures prices across different expiration dates. ### Method GET ### Endpoint /term_structure ### Parameters #### Query Parameters - **coins** (list[string]) - Required - A list of cryptocurrency symbols (e.g., ['BTC', 'ETH']). ### Request Example `GET /term_structure?coins=BTC,ETH` ### Response #### Success Response (200) - **DataFrame** - A pandas DataFrame with term structure data including expiration dates, basis, and annualized basis rates. #### Response Example ``` (DataFrame output will vary based on data) ``` ``` -------------------------------- ### Get Historical Order Book Depth Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves historical order book depth data, showing liquidity at various price levels over time. Supports aggregated (by coin) and specific product queries. ```python from velodata import lib as velo client = velo.client('your_api_key') ``` -------------------------------- ### Get Futures Term Structure Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves futures term structure data, showing the relationship between futures prices across different expiration dates. Accepts a list of coin symbols. ```python from velodata import lib as velo client = velo.client('your_api_key') # Get term structure for BTC and ETH coins = ['BTC', 'ETH'] term_structure = client.get_term_structure(coins) print(term_structure) # Output: DataFrame with term structure data including # expiration dates, basis, and annualized basis rates ``` -------------------------------- ### Get Rows - Historical Data Query Source: https://context7.com/velodataorg/velo-python/llms.txt Fetches historical market data for futures and other types. Supports various parameters to specify data type, columns, products, time range, and resolution. ```APIDOC ## Get Rows - Historical Data Query ### Description The primary method for fetching historical market data. Accepts a params dictionary specifying the data type, columns, products, time range, and resolution. Returns a pandas DataFrame with the requested data. ### Method POST ### Endpoint /rows ### Parameters #### Request Body - **type** (string) - Required - Type of data to query (e.g., 'futures', 'spot'). - **columns** (list[string]) - Required - List of columns to retrieve. - **exchanges** (list[string]) - Optional - List of exchanges to query. - **products** (list[string]) - Optional - List of products to query (e.g., 'BTCUSDT'). - **coins** (list[string]) - Optional - List of coins to query (aggregated across exchanges). - **begin** (integer) - Required - Start timestamp of the query range. - **end** (integer) - Required - End timestamp of the query range. - **resolution** (string) - Required - Data resolution (e.g., '1m', '5m', '1h', '1d'). ### Request Example ```json { "type": "futures", "columns": ["open_price", "close_price", "dollar_volume", "funding_rate"], "exchanges": ["binance"], "products": ["BTCUSDT"], "begin": 1699892400, "end": 1699896000, "resolution": "5m" } ``` ### Response #### Success Response (200) - **DataFrame** - A pandas DataFrame containing the historical market data. #### Response Example ``` timestamp exchange product open_price close_price dollar_volume funding_rate 0 1699896000 binance BTCUSDT 36500.50 36520.30 15000000.0 0.0001 1 1699896300 binance BTCUSDT 36520.30 36480.10 12500000.0 0.0001 ``` ``` -------------------------------- ### Query Depth by Product and Exchange Source: https://context7.com/velodataorg/velo-python/llms.txt Fetches depth snapshots for a specific product (e.g., BTCUSDT) on a particular exchange within a defined time frame and resolution. Requires an initialized client. ```python params_product = { 'product': 'BTCUSDT', 'exchange': 'binance', 'begin': client.timestamp() - 1000 * 60 * 30, 'end': client.timestamp(), 'resolution': 1 # 1-minute snapshots } for depth_snapshot in client.depth(params_product): print(depth_snapshot) ``` -------------------------------- ### Initialize Velo Data Client Source: https://context7.com/velodataorg/velo-python/llms.txt The client requires an API key for authentication and supports optional retry configuration. ```python from velodata import lib as velo # Initialize client with API key client = velo.client('your_api_key') # Initialize with custom retry count (default is 2) client = velo.client('your_api_key', retry=3) # Check API status status = client.get_status() print(status) # Get library version print(client.version()) # Returns: '1.5.5' # Get current timestamp in milliseconds current_time = client.timestamp() print(current_time) # Returns: 1699900000000 ``` -------------------------------- ### Retrieve Options Products Source: https://context7.com/velodataorg/velo-python/llms.txt Fetches metadata for available options contracts across supported exchanges. ```python from velodata import lib as velo client = velo.client('your_api_key') # Get all options products options = client.get_options() print(options) # Output: [ # {'exchange': 'deribit', 'product': 'BTC-29DEC23-40000-C', 'coin': 'BTC', ...}, # ... # ] ``` -------------------------------- ### Retrieve Options Data Columns Source: https://context7.com/velodataorg/velo-python/llms.txt Returns the list of available metrics for options queries, including Greeks and implied volatility. ```python from velodata import lib as velo client = velo.client('your_api_key') columns = client.get_options_columns() print(columns) # Output: [ # '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' # ] ``` -------------------------------- ### Retrieve Spot Products Source: https://context7.com/velodataorg/velo-python/llms.txt Fetches metadata for spot trading pairs, with an option to include delisted pairs. ```python from velodata import lib as velo client = velo.client('your_api_key') # Get all active spot products spot = client.get_spot() print(spot) # Output: [ # {'exchange': 'binance', 'product': 'BTCUSDT', 'coin': 'BTC', ...}, # ... # ] # Include delisted spot pairs all_spot = client.get_spot(delisted=True) ``` -------------------------------- ### Client Initialization Source: https://context7.com/velodataorg/velo-python/llms.txt Initialize the Velo Data client with your API key. You can also specify a custom retry count for failed requests. ```APIDOC ## Client Initialization The client class is the main entry point for all API interactions. It requires an API key for authentication and optionally accepts a retry count for failed requests. ```python from velodata import lib as velo # Initialize client with API key client = velo.client('your_api_key') # Initialize with custom retry count (default is 2) client = velo.client('your_api_key', retry=3) # Check API status status = client.get_status() print(status) # Get library version print(client.version()) # Returns: '1.5.5' # Get current timestamp in milliseconds current_time = client.timestamp() print(current_time) # Returns: 1699900000000 ``` ``` -------------------------------- ### Retrieve Futures Products Source: https://context7.com/velodataorg/velo-python/llms.txt Fetches metadata for futures products, with an option to include delisted items. ```python from velodata import lib as velo client = velo.client('your_api_key') # Get all active futures products futures = client.get_futures() print(futures) # Output: [ # {'exchange': 'binance', 'product': 'BTCUSDT', 'coin': 'BTC', ...}, # {'exchange': 'bybit', 'product': 'ETHUSDT', 'coin': 'ETH', ...}, # ... # ] # Include delisted products all_futures = client.get_futures(delisted=True) print(f"Total futures (including delisted): {len(all_futures)}") ``` -------------------------------- ### Query Depth by Coin (Aggregated) Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves aggregated depth snapshots for a specific coin over a given time range and resolution. Ensure the client is initialized. ```python params_coin = { 'coin': 'BTC', 'begin': client.timestamp() - 1000 * 60 * 60, # 1 hour ago 'end': client.timestamp(), 'resolution': 5 # 5-minute snapshots } for depth_snapshot in client.depth(params_coin): if depth_snapshot: print(f"Timestamp: {depth_snapshot['timestamp']}") print(f"Mid Price: {depth_snapshot['midprice']}") # Price levels as keys with volume as values for price, volume in depth_snapshot.items(): if price not in ('timestamp', 'midprice'): print(f" Level {price}: {volume}") ``` -------------------------------- ### Stream News with Programmatic Close Source: https://context7.com/velodataorg/velo-python/llms.txt Demonstrates streaming news with a mechanism to close the WebSocket connection programmatically after receiving the first news story. Requires an initialized Velo client and asyncio. ```python from velodata import lib as velo import asyncio import json client = velo.client('your_api_key') async def stream_with_timeout(): async for message in client.news.stream_news(): if message == 'connected': print('Connected') elif message not in ('heartbeat', 'closed'): story = json.loads(message) print(story) # Close after receiving first story await client.close_stream() break asyncio.run(stream_with_timeout()) ``` -------------------------------- ### Stream Real-time News Updates Source: https://context7.com/velodataorg/velo-python/llms.txt Establishes a WebSocket connection to stream real-time news updates. Handles connection status messages and parses incoming news story JSON. Requires an initialized Velo client and asyncio. ```python from velodata import lib as velo import asyncio import json client = velo.client('your_api_key') async def stream_news(): async for message in client.news.stream_news(): if message == 'connected': print('WebSocket connected to news feed') elif message == 'heartbeat': print('Heartbeat received') elif message == 'closed': print('WebSocket connection closed') break else: # Parse news story JSON story = json.loads(message) print(f"Breaking: {story['headline']}") print(f"Content: {story['content']}") # Run the async stream asyncio.run(stream_news()) ``` -------------------------------- ### Retrieve Futures Data Columns Source: https://context7.com/velodataorg/velo-python/llms.txt Returns the list of available metrics for futures queries, used to specify parameters in get_rows(). ```python from velodata import lib as velo client = velo.client('your_api_key') columns = client.get_futures_columns() print(columns) # Output: [ # '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 and Stream Large Data Queries Source: https://context7.com/velodataorg/velo-python/llms.txt Handles large data requests by automatically batching queries. Use batch_rows() to configure batches and stream_rows() to process data incrementally. ```python from velodata import lib as velo client = velo.client('your_api_key') # Large historical query params = { 'type': 'futures', 'columns': ['close_price', 'dollar_volume'], 'exchanges': ['binance'], 'products': ['BTCUSDT'], 'begin': client.timestamp() - 1000 * 60 * 60 * 24 * 30, # 30 days 'end': client.timestamp(), 'resolution': '1m' # 1-minute resolution = ~43,200 rows } # Get batch configuration batches = client.batch_rows(params) print(f"Query split into {len(batches)} batches") # Stream data batch by batch for df in client.stream_rows(batches): if not df.empty: print(f"Received {len(df)} rows") # Process each batch immediately print(df.head()) ``` -------------------------------- ### Order Book Depth Source: https://context7.com/velodataorg/velo-python/llms.txt Retrieves historical order book depth data, showing liquidity at various price levels over time. Supports both aggregated (by coin) and specific product queries. ```APIDOC ## Order Book Depth ### Description Retrieves historical order book depth data showing liquidity at various price levels over time. Supports both aggregated (by coin) and specific product queries. ### Method GET ### Endpoint /orderbook/depth ### Parameters #### Query Parameters - **type** (string) - Required - Type of data ('futures' or 'spot'). - **coins** (list[string]) - Optional - List of coins to query (aggregated). - **exchanges** (list[string]) - Optional - List of exchanges to query. - **products** (list[string]) - Optional - List of specific products to query. - **begin** (integer) - Required - Start timestamp. - **end** (integer) - Required - End timestamp. - **resolution** (string) - Optional - Data resolution (e.g., '1m', '5m'). ### Request Example `GET /orderbook/depth?type=futures&coins=BTC,ETH&begin=1677638400&end=1677638400 + 3600` ### Response #### Success Response (200) - **DataFrame** - A pandas DataFrame containing historical order book depth data. #### Response Example ``` (DataFrame output will vary based on data and query parameters) ``` ``` -------------------------------- ### Fetch Historical Futures Data Source: https://context7.com/velodataorg/velo-python/llms.txt Fetches historical market data for futures products. Specify data type, columns, products, time range, and resolution. Returns a pandas DataFrame. ```python from velodata import lib as velo client = velo.client('your_api_key') # Get a futures product future = client.get_futures()[0] # Define query parameters params = { 'type': 'futures', 'columns': ['open_price', 'close_price', 'dollar_volume', 'funding_rate'], 'exchanges': [future['exchange']], 'products': [future['product']], 'begin': client.timestamp() - 1000 * 60 * 60, # 1 hour ago 'end': client.timestamp(), 'resolution': '5m' # 5-minute candles } # Fetch data as DataFrame df = client.get_rows(params) print(df) # Output: # timestamp exchange product open_price close_price dollar_volume funding_rate # 0 1699896000 binance BTCUSDT 36500.50 36520.30 15000000.0 0.0001 # 1 1699896300 binance BTCUSDT 36520.30 36480.10 12500000.0 0.0001 # ... # Query with different resolutions # Supported: '1m', '5m', '15m', '30m', '1h', '4h', '1d', '1w', '1M' params_daily = { 'type': 'futures', 'columns': ['close_price', 'dollar_open_interest_close'], 'exchanges': ['binance', 'bybit'], 'products': ['BTCUSDT', 'ETHUSDT'], 'begin': client.timestamp() - 1000 * 60 * 60 * 24 * 7, # 7 days ago 'end': client.timestamp(), 'resolution': '1d' } df_daily = client.get_rows(params_daily) print(df_daily) # Query by coin (aggregated across exchanges) params_coin = { 'type': 'futures', 'columns': ['dollar_volume', 'liquidations_dollar_volume'], 'exchanges': ['binance', 'bybit', 'okx'], 'coins': ['BTC', 'ETH'], 'begin': client.timestamp() - 1000 * 60 * 60 * 24, 'end': client.timestamp(), 'resolution': '1h' } df_coin = client.get_rows(params_coin) print(df_coin) ``` -------------------------------- ### Batch and Stream Rows Source: https://context7.com/velodataorg/velo-python/llms.txt Provides methods for handling large data requests by batching queries and streaming data incrementally. ```APIDOC ## Batch and Stream Rows ### Description For large data requests, the library automatically batches queries. Use batch_rows() and stream_rows() to process data incrementally without waiting for all batches to complete. ### Method POST ### Endpoint /rows/batch, /rows/stream ### Parameters #### Request Body (for batch_rows) - **type** (string) - Required - Type of data to query (e.g., 'futures', 'spot'). - **columns** (list[string]) - Required - List of columns to retrieve. - **exchanges** (list[string]) - Optional - List of exchanges to query. - **products** (list[string]) - Optional - List of products to query (e.g., 'BTCUSDT'). - **begin** (integer) - Required - Start timestamp of the query range. - **end** (integer) - Required - End timestamp of the query range. - **resolution** (string) - Required - Data resolution (e.g., '1m', '5m', '1h', '1d'). ### Request Example (batch_rows) ```json { "type": "futures", "columns": ["close_price", "dollar_volume"], "exchanges": ["binance"], "products": ["BTCUSDT"], "begin": 1677638400, "end": 1677638400 + 1000 * 60 * 60 * 24 * 30, "resolution": "1m" } ``` ### Response #### Success Response (200) - **batch_rows**: Returns a list of batch configurations. - **stream_rows**: Iterates over pandas DataFrames, yielding data batch by batch. #### Response Example (stream_rows iteration) ``` Received 1000 rows timestamp exchange product close_price dollar_volume 0 1677638400 binance BTCUSDT 24000.0 50000000.0 1 1677638460 binance BTCUSDT 24010.0 51000000.0 ... ``` ``` -------------------------------- ### Stream Batched Row Data from Velo API Source: https://github.com/velodataorg/velo-python/blob/main/README.md Process row requests that are broken into batches. This method allows you to receive and process data incrementally as it becomes available, rather than waiting for all requests to complete. ```python batches = client.batch_rows(params) for df in client.stream_rows(batches): print(df) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.