### Fetch OHLCV Data (Python) Source: https://docs.amberdata.io/http/market/spot-batch-ohlcv Example of how to fetch OHLCV data using the Python client library. Ensure you have the library installed and your API key configured. ```python from amberdata import AmberData api_key = "YOUR_API_KEY" client = AmberData(api_key=api_key) # Fetch OHLCV data for Bitcoin (BTC) on Binance (BN) for a specific date range # Pair: BTC-USD # Exchange: BN # Start Date: 2023-01-01 # End Date: 2023-01-02 response = client.market.spot.ohlcv.batch( exchange='BN', pair='BTC-USD', start_date='2023-01-01', end_date='2023-01-02' ) print(response) ``` -------------------------------- ### Fetch OHLCV Data (JavaScript) Source: https://docs.amberdata.io/http/market/spot-batch-ohlcv Example of how to fetch OHLCV data using the JavaScript client library. Ensure you have the library installed and your API key configured. ```javascript const { AmberData } = require('amberdata'); const apiKey = 'YOUR_API_KEY'; const client = new AmberData(apiKey); // Fetch OHLCV data for Bitcoin (BTC) on Binance (BN) for a specific date range // Pair: BTC-USD // Exchange: BN // Start Date: 2023-01-01 // End Date: 2023-01-02 client.market.spot.ohlcv.batch({ exchange: 'BN', pair: 'BTC-USD', startDate: '2023-01-01', endDate: '2023-01-02' }) .then(response => { console.log(response); }) .catch(error => { console.error(error); }); ``` -------------------------------- ### Install wscat Source: https://docs.amberdata.io/real-time/websocket-getting-started Install the `wscat` command-line tool globally using npm. This tool is used for interacting with WebSocket services. ```bash npm install -g wscat ``` -------------------------------- ### OpenAPI Specification for Futures Tickers Information Source: https://docs.amberdata.io/http/market/futures-tickers-information This OpenAPI 3.1.0 specification defines the GET /futures/tickers/information endpoint. It includes details on parameters, request headers, and response schemas for successful (200) and error (400) scenarios. The example response shows metadata and a list of instruments with their start and end dates. ```yaml openapi: 3.1.0 info: title: market-api version: '2' servers: - url: https://api.amberdata.com/markets security: - ApiKeyAuth: [] paths: /futures/tickers/information: get: summary: Information description: >- Provides available date ranges for ticker data on futures instruments across exchanges, including start and end timestamps for each instrument. operationId: futures-tickers-information parameters: - name: exchange in: query description: >- **[Optional]** The exchange(s) for which to retrieve the most current data (comma separated). **[Default]** All available exchanges. schema: type: string - name: instrument in: query description: Only return data for the given pair. schema: type: string - name: includeInactive in: query description: >- **[Optional]** If true, endpoint returns all instruments, including delisted ones. schema: type: boolean default: false - name: timeFormat in: query description: '**[Optional]** Time format of the timestamps in the response.' schema: type: string enum: - milliseconds - ms* - iso - iso8601 - hr - human_readable default: hr - name: Accept-Encoding in: header required: true description: '' schema: type: string default: gzip, deflate, br - name: api-version in: header schema: type: string responses: '200': description: '200' content: application/json: examples: Result: value: status: 200 title: OK description: Successful request payload: metadata: next: >- https://api.amberdata.com/markets/futures/tickers/information?cursor=N4IglgdgxgNgrgEwKYEkIEMoBcwDckgBcAZujAM5IA0408yAqhOXAA6sD2ATlkggKIAPKAAt0EAOZJyRUhWogcAWyQAxbkvRYiIJWBgwwlKBwgIZNYhq06AVuVMgardFKIBGGuTAAvAoQBWAAYggF8gA api-version: '2023-09-30' data: - exchange: binance instrument: 1000BONKUSDC startDate: 1714635454117 endDate: 1717604699662 - exchange: binance instrument: 1000BONKUSDT startDate: 1700662147849 endDate: 1717604699631 - exchange: binance instrument: 1000FLOKIUSDT startDate: 1683391092423 endDate: 1717604699817 schema: type: object properties: status: type: integer title: type: string description: type: string payload: type: object properties: metadata: type: object properties: next: type: string api-version: type: string data: type: array items: type: object properties: exchange: type: string instrument: type: string startDate: type: integer endDate: type: integer '400': description: '400' content: application/json: examples: Result: value: '{}' schema: type: object properties: {} deprecated: false security: - ApiKeyAuth: [] components: securitySchemes: ApiKeyAuth: type: apiKey in: header name: x-api-key ``` -------------------------------- ### WebSocket Connection and Subscription Example Source: https://docs.amberdata.io/real-time/market/websocket-market-options This example demonstrates how to establish a WebSocket connection to the Amberdata API and subscribe to market options ticker snapshots. It shows the necessary headers, the JSON-RPC message format for subscription, and how to handle incoming messages. ```APIDOC ## WebSocket Connection and Subscription ### Description Connect to the WebSocket endpoint to receive real-time market data. Use the `subscribe` method with the appropriate topic and parameters to get specific data feeds. ### Method WebSocket Connection ### Endpoint `wss://ws.amberdata.com/options` ### Headers - `x-api-key`: Your Amberdata API key. ### Request Example (Subscription) ```json { "jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": [ "market:options:tickers:snapshots", { "instrument": "ETH-30SEP22-9000-P", "exchange": "deribit" } ] } ``` ### Parameters (for `market:options:tickers:snapshots`) #### Subscription Parameters - **instrument** (`string`) - Required - The asset instrument (e.g., "ETH-30SEP22-9000-P"). - **exchange** (`string`) - Required - The exchange for which to retrieve asset instruments (e.g., "deribit"). ### Response Example (Ticker Snapshot) ```json { "jsonrpc": "2.0", "method": "subscription", "params": { "subscription": "cd9738ab-54e9-4bcf-a3f8-be3c7976e694", "result": { "exchange": "deribit", "instrument": "BTC-12APR24-71000-C", "timestamp": 1711571450748, "exchangeTimestamp": 1711571450748, "exchangeTimestampNanoseconds": 0, "bid": 0.0475, "ask": 0.0485, "mid": 0.048, "last": 0.049, "baseVolume": null, "quoteVolume": null, "bidVolume": 4.7, "askVolume": 26.4, "sequence": null, "metadata": null, "underlyingPrice": 69593.63, "underlyingIndex": "SYN.BTC-12APR24", "stats": { "volume_usd": 376871.48, "volume": 88.7, "price_change": -16.9492, "low": 0.049, "high": 0.0669 }, "state": "open", "settlementPrice": 0.05367167, "openInterest": 293.2, "minPrice": 0.017, "maxPrice": 0.1, "markPrice": 0.0477, "markIv": 69.03, "interestRate": 0, "indexPrice": 68916.13, "greeks": { "rho": 12.52907, "theta": -127.19004, "vega": 57.0353, "gamma": 0.00004, "delta": 0.47224 }, "estimatedDeliveryPrice": 68916.13, "bidIv": 68.79, "askIv": 70.01 } } } ``` ### Response Fields #### Result Fields - **exchange** (`string`) - The exchange. - **instrument** (`string`) - The instrument. - **exchangeTimestamp** (`number` | `null`) - Timestamp that the exchange returned. - **exchangeTimestampNanoseconds** (`number` | `null`) - Nanoseconds part of `exchangeTimestamp`. ``` -------------------------------- ### Get Spot Data Source: https://docs.amberdata.io/http/analytics/spot/openapi.yaml Retrieves historical spot trading data for a given currency pair and exchange. You can filter the results by a start date. ```APIDOC ## GET /websites/amberdata_io/analytics/spot ### Description Retrieves historical spot trading data, including total volume, TWAP, and VWAP, for a specified currency pair and exchange. Data can be filtered by a start date. ### Method GET ### Endpoint /websites/amberdata_io/analytics/spot ### Parameters #### Query Parameters - **pair** (string) - Required - The currency pair for the spot instrument. Examples: `btc_usd | btc_usdc | eth_usd` - **exchange** (string) - Required - The exchange for which to retrieve listed spot instruments. Examples: `gdax | okex | binance | binanceus` - **startDate** (string) - Optional - Payload only includes data after this date (inclusive). Formats: `seconds | milliseconds | iso8601` ### Response #### Success Response (200) - **status** (integer) - Example: 200 - **title** (string) - Example: OK - **description** (string) - Example: Successful request - **payload** (object) - **data** (array) - **exchange** (string) - Example: gdax - Exchange hosting the pair for VWAP/TWAP calculations - **pair** (string) - Example: btc_usd - Underlying pair for VWAP/TWAP calculations - **timestamp** (string) - Example: 2025-06-08 23:00:00 000 - Timestamp reflecting the VWAP/TWAP calculations - **totalVolumeUSD** (number) - Example: 17077624.10253145 - Raw total volume in quote terms (often USD) - **twap** (number) - Example: 105726.12016666665 - Time-weighted average price. Underlying time increments are in minutes - **vwap** (number) - Example: 105724.81842395054 - Trade-weighted average price #### Response Example ```json { "status": 200, "title": "OK", "description": "Successful request", "payload": { "data": [ { "exchange": "gdax", "pair": "btc_usd", "timestamp": "2025-06-08 23:00:00 000", "totalVolumeUSD": 17077624.10253145, "twap": 105726.12016666665, "vwap": 105724.81842395054 } ] } } ``` ``` -------------------------------- ### Authentication Example Source: https://docs.amberdata.io/http/http-api-fundamentals Demonstrates how to authenticate requests using an API key in the request header. ```APIDOC ## Authentication All requests to our servers require a unique user-specific API Key. Requests without a valid API Key will be refused. ### Usage Every request (*with the exception of WebSockets*) requires the `x-api-key` header: ```bash curl --request GET \ --url 'https://api.amberdata.com/markets/spot/trades/eth_usd' \ --header 'Accept-Encoding: gzip, deflate, br' \ --header 'Accept: application/json' \ --header 'x-api-key: YOUR_API_KEY' ``` ``` -------------------------------- ### Get Historical Exchange Metrics Source: https://docs.amberdata.io/http/defi-market/openapi.yaml Retrieves historical daily exchange metrics for a specified decentralized exchange. You can filter by start and end dates. ```APIDOC ## GET /metrics/exchanges/{exchange}/historical ### Description Retrieves historical daily exchange metrics for the specified decentralized exchange. ### Method GET ### Endpoint https://api.amberdata.com/market/defi/metrics/exchanges/{exchange}/historical ### Parameters #### Path Parameters - **exchange** (string) - Required - Exchange for which to return the global metrics - can be specified as: - a name: `uniswapv2` - an id: `0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f` #### Query Parameters - **startDate** (string) - Optional - Payload only includes data after this date (inclusive). Formats: `seconds | milliseconds | iso8601`. Examples: `1578531600 | 1578531600000 | 2020-09-01T01:00:00` - **endDate** (string) - Optional - Payload only includes data before this date (exclusive). Formats: `seconds | milliseconds | iso8601`. Examples: `1578531600 | 1578531600000 | 2020-09-01T01:00:00` - **timeFormat** (string) - Optional - Time format of the timestamps in the return payload. Defaults to `milliseconds | ms* | iso | iso8601 | hr | human_readable`. ### Response #### Success Response (200) - **status** (integer) - Example: 200 - **title** (string) - Example: OK - **description** (string) - Example: Successful request - **payload** (array) - Array of historical exchange metrics objects. ``` -------------------------------- ### OpenAPI Instrument Example (Binance) Source: https://docs.amberdata.io/http/arc/exchange-statistics Example of how instrument data might be represented in an OpenAPI specification, specifically for Binance spot instruments. ```yaml instrumentsSpot: type: integer example: 2832 default: 0 deprecated: false ``` -------------------------------- ### Get Realized Funding Rates Cumulated Source: https://docs.amberdata.io/http/analytics/derivatives/funding-realized-accumulated This OpenAPI definition describes the GET request for the realized funding rates cumulated endpoint. It specifies required parameters such as asset, margin type, start date, and end date, along with optional time format. ```yaml openapi: 3.1.0 info: title: derivatives-api version: '2' servers: - url: https://api.amberdata.com/markets/derivatives security: - sec0: [] paths: /analytics/futures-perpetuals/realized-funding-rates-cumulated: get: summary: Funding Realized/Accumulated description: >- This endpoint returns funding realized/accumulated data, which refers to the payments made between traders holding long and short positions in perpetual futures contracts. Accumulated funding is the total series of payments made between selected dates. operationId: derivatives-futures-perpetuals-funding-realized-accumulated parameters: - name: asset in: query description: >- **[Required]** The underlying currency for which there are futures contracts/instruments. **[Examples]** ` BTC | ETH ` required: true schema: type: string default: BTC - name: marginType in: query description: >- **[Required]** This is the type of margin for the perpetuals. Perpetuals are either settled in stable coins or underlying currency coins.. **[Examples]** ` coins | stables ` required: true schema: type: string default: coins - name: startDate in: query description: >- **[Required]** Payload only includes data after this date (inclusive). **[Formats]** `seconds | milliseconds | iso8601` **[Examples]** `1578531600 | 1578531600000 | 2020-09-01T01:00:00` required: true schema: type: string format: date-time default: '2024-05-21' - name: endDate in: query description: >- **[Required]** Payload only includes data before this date (exclusive). **[Formats]** `seconds | milliseconds | iso8601` **[Examples]** `1578531600 | 1578531600000 | 2020-09-01T01:00:00` required: true schema: type: string default: '2024-06-01' - name: timeFormat in: query description: >- **[Optional]** Time format of the timestamps in the return payload. **[Defaults]** `milliseconds | ms* | iso | iso8601 | hr | human_readable` schema: type: string responses: '200': description: '200' content: application/json: schema: type: object properties: status: type: integer example: 200 title: type: string example: OK description: type: string example: Successful request payload: type: object properties: data: type: array items: type: object properties: symbol: type: string example: binance BTCUSD_PERP description: The exchange and perpetual contract symbol timestamp: type: string example: 1704067200000 description: The timestamp for the funding data point realizedFunding: type: number example: 0.037711 description: The realized funding payment for the period accumulatedRealizedFunding: type: number example: 0.037711 description: >- The cumulative total of realized funding payments examples: Result: value: status: 200 title: OK ``` -------------------------------- ### Market Data Subscription Examples Source: https://docs.amberdata.io/real-time/websocket-getting-started Examples of how to subscribe to different types of market data, including spot trades for specific exchanges and pairs, multiple instruments, and exchange-wide subscriptions. ```APIDOC ### Market Data Subscription Examples **Spot Market Data:** ```json { "jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["market:spot:trades", {"exchange": "coinbase", "pair": "btc_usd"}] } ``` **Multiple Instruments (make separate requests):** ```json { "jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["market:spot:trades", {"exchange": "binance", "pair": "btc_usdt"}] } ``` ```json { "jsonrpc": "2.0", "id": 2, "method": "subscribe", "params": ["market:spot:trades", {"exchange": "binance", "pair": "eth_usdt"}] } ``` **Exchange-wide Subscription (Spot only):** ```json { "jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["market:spot:trades", {"pair": "btc_usdt"}] } ``` ``` -------------------------------- ### GET /futures/tickers/information Source: https://docs.amberdata.io/http/market/openapi.yaml Provides available date ranges for ticker data on futures instruments across exchanges, including start and end timestamps for each instrument. ```APIDOC ## GET /futures/tickers/information ### Description Provides available date ranges for ticker data on futures instruments across exchanges, including start and end timestamps for each instrument. ### Method GET ### Endpoint /futures/tickers/information ### Parameters #### Query Parameters - **exchange** (string) - Optional - The exchange(s) for which to retrieve the most current data (comma separated). [Default] All available exchanges. - **instrument** (string) - Optional - Only return data for the given pair. - **includeInactive** (boolean) - Optional - If true, endpoint returns all instruments, including delisted ones. Default: false - **timeFormat** (string) - Optional - Time format of the timestamps in the response. Allowed values: milliseconds, ms*, iso, iso8601, hr, human_readable. Default: hr #### Header Parameters - **Accept-Encoding** (string) - Required - Default: gzip, deflate, br - **api-version** (string) - Optional ### Responses #### Success Response (200) - **status** (integer) - - **title** (string) - - **description** (string) - - **payload** (object) - - **metadata** (object) - - **requestedStartDate** (integer) - - **requestedEndDate** (integer) - - **returnedStartDate** (integer) - - **returnedEndDate** (integer) - - **next** (string) - - **api-version** (string) - - **data** (array) - - **exchange** (string) - - **instrument** (string) - - **timestamp** (integer) - - **exchangeTimestamp** (integer) - - **exchangeTimestampNanoseconds** (integer) - - **sequence** (string) - - **currentFunding** (string) - - **ask** (array) - - **price** (number) - - **volume** (integer) - - **numOrders** (string) - - **bid** (array) - - **price** (number) - - **volume** (integer) - - **numOrders** (string) - #### Error Response (400) - **description**: '400' - **content**: - **application/json**: - **schema**: - **type**: object - **properties**: {} ``` -------------------------------- ### OpenAPI Example: BTC Options Trade Source: https://docs.amberdata.io/http/market/options-trades-information Illustrates an example options trade for Bitcoin (BTC) with specific parameters like strike price, expiration date, and type. ```yaml example: BTC-16AUG24-50000-P underlying: type: string example: BTC startDate: type: integer example: 1721916316594 default: 0 endDate: type: integer example: 1722412049804 default: 0 deprecated: false ``` -------------------------------- ### Subscribe to Exchange-wide Spot Trades Source: https://docs.amberdata.io/real-time/websocket-getting-started This example demonstrates how to subscribe to all spot trades for a specific trading pair across an entire exchange. Note that this is only applicable for spot data. ```json { "jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["market:spot:trades", {"pair": "btc_usdt"}] } ``` -------------------------------- ### JavaScript WebSocket Client for Instrument Prices Source: https://docs.amberdata.io/real-time/price/websocket-price-spot This JavaScript example shows how to establish a WebSocket connection, authenticate using an API key, and subscribe to real-time instrument price updates. Remember to replace '' with your valid API key. ```javascript const WebSocket = require('ws'); const ws = new WebSocket('wss://analytics-ws.amberdata.com/prices', { headers: { 'x-api-key': '' } }); ws.on('open', () => { ws.send(JSON.stringify({ jsonrpc: '2.0', method: 'subscribe', params: ['prices:spot:instrument', { instrument: 'all' }], id: 1 })); }); ws.on('message', data => { console.log(JSON.stringify(JSON.parse(data), null, 2)); }); ``` -------------------------------- ### Get Asset Market Cap Source: https://docs.amberdata.io/http/blockchain/analytics-asset-marketcap Retrieves the market cap timeseries for a specific asset identified by its arcId. You can optionally filter the results by a start and end date. ```APIDOC ## GET /analytics/assets/{arcId}/marketcap ### Description Retrieves the market cap timeseries for a specific asset. ### Method GET ### Endpoint /analytics/assets/{arcId}/marketcap ### Parameters #### Path Parameters - **arcId** (string) - Required - The arcId of the asset (e.g., AMB:BTC000000000). Use the associated information endpoint to retrieve the arcId. #### Query Parameters - **startDate** (string) - Optional - Inclusive start date (default now() - 7 days). - **endDate** (string) - Optional - Exclusive end date (default today). ### Response #### Success Response (200) - **status** (integer) - HTTP status code - **title** (string) - Status title - **description** (string) - Status description - **payload** (object) - **data** (array) - **arcId** (string) - The unique identifier for the asset - **arcName** (string) - The full name of the asset - **arcSymbol** (string) - The symbol/ticker of the asset - **circulatingSupply** (number) - The circulating supply of the asset - **priceUSD** (number) - The price of the asset in USD - **marketCap** (number) - The market capitalization in USD - **timestamp** (string) - The timestamp of the data point - **metadata** (object) - **next** (string) - The url to request for the next page of results #### Response Example { "status": 200, "title": "OK", "description": "Successful request", "payload": { "data": [ { "arcId": "AMB:BTC000000000", "arcName": "Bitcoin", "arcSymbol": "BTC", "circulatingSupply": 19594996.16066135, "priceUSD": 46189.23640263, "marketCap": 905077909973.43, "timestamp": "2024-01-10T00:00:00.000Z" } ], "metadata": { "next": null } } } ``` -------------------------------- ### List Classifications OpenAPI Specification Source: https://docs.amberdata.io/http/arc/list-classifications This OpenAPI specification defines the GET /classifications endpoint for retrieving asset classifications. It includes details on parameters, responses, and example payloads. ```yaml openapi: 3.1.0 info: title: Asset Reference & Classification API version: '2' servers: - url: https://api.amberdata.com/arc security: - sec0: [] paths: /classifications: get: summary: List Classifications description: Retrieve the **latest** known classifications for assets in ARC. operationId: asset-reference-classification-list-classifications responses: '200': description: '200' content: application/json: examples: Result: value: status: 200 title: OK description: Successful request payload: metadata: next: null data: - tagName: Proof-of-Work tagDescription: >- Assets that require validation of block transactions where miners are solving computationally expensive cryptographic problems - tagName: Proof-of-Stake tagDescription: >- Assets that require validation of block transactions by participants who offer their holdings of said asset as collateral to validate transactions - tagName: Stablecoin tagDescription: >- Assets that are intended to offer participants in the digital asset ecosystem access to blockchain applications and decentralized protocols without being exposed to volatile price action in digitally native tokens - tagName: Real World Asset tagDescription: >- Assets that are an on-chain tokenized representation of off-chain assets and are pegged to the performance of the underlying off-chain asset - tagName: Machine Learning & AI tagDescription: >- Assets native to protocols that facilitate model training, inference, predictions, and generative artificial intelligence - tagName: Gaming tagDescription: >- Assets native to applications for blockchain-based gaming and their communities. Decentralized gaming applications often include a native token to incentivize players with monetary rewards based on their participation and success in the game - tagName: Metaverse tagDescription: >- Assets native to applications and protocols associated with a loose network of virtual worlds where social connections and interactions are the primary function - tagName: Advertising tagDescription: >- Assets native to applications that facilitate the tokenization of impressions for interacting with ads and marketing campaigns. These tokens correspond with the user's viewership whereby they are rewarded in the token for their time and attention - tagName: Content & Streaming tagDescription: >- Assets native to applications that support the creation and broadcasting of creative content, such as video, music, or art, and enable social interactions between users and communities. The networks are powered by the asset, allowing creators to communicate and distribute content autonomously - tagName: Staking tagDescription: >- Assets native to decentralized applications that provide the user with yield for locking up their ``` -------------------------------- ### 24-Hour Volatility Metrics Example Source: https://docs.amberdata.io/http/analytics/derivatives/volatility-metrics-24-hr This example shows the structure of the data returned for 24-hour volatility metrics. It includes key pricing and risk indicators. ```json { daysToExpiration: 295.40972222222223, underlyingPrice: 79327.298125, underlyingPriceChange: 4074.202291666661, riskReversal25: 5.460199250748275, riskReversal25Change: 1.2529280066827084, riskReversal15: 7.697929291244478, riskReversal15Change: 1.688653918489564, butterfly25: 3.7752032129429267, butterfly25Change: 0.36651114091668546, butterfly15: 6.012933253439144, butterfly15Change: 0.3426408855064551 } ``` -------------------------------- ### JavaScript WebSocket Client for Asset Prices Source: https://docs.amberdata.io/real-time/price/websocket-price-spot This JavaScript example demonstrates how to connect to the WebSocket endpoint, authenticate with an API key, and subscribe to real-time asset price updates. Ensure you replace '' with your actual API key. ```javascript const WebSocket = require('ws'); const ws = new WebSocket('wss://analytics-ws.amberdata.com/prices', { headers: { 'x-api-key': '' } }); ws.on('open', () => { ws.send(JSON.stringify({ jsonrpc: '2.0', method: 'subscribe', params: ['prices:spot:asset', { asset: 'all' }], id: 1 })); }); ws.on('message', data => { console.log(JSON.stringify(JSON.parse(data), null, 2)); }); ``` -------------------------------- ### Get Futures Liquidations Information Source: https://docs.amberdata.io/http/market/futures-liquidations-information Fetches available date ranges for liquidation data on futures instruments across exchanges, including start and end timestamps for each instrument. ```APIDOC ## GET /futures/liquidations/information ### Description Provides available date ranges for liquidation data on futures instruments across exchanges, including start and end timestamps for each instrument. ### Method GET ### Endpoint /futures/liquidations/information ### Parameters #### Query Parameters - **exchange** (string) - Optional - The exchange(s) for which to retrieve the most current data (comma separated). Default: All available exchanges. - **instrument** (string) - Optional - Only return data for the given pair. - **includeInactive** (boolean) - Optional - If true, endpoint returns all instruments, including delisted ones. Default: false - **timeFormat** (string) - Optional - Time format of the timestamps in the response. Allowed values: milliseconds, ms*, iso, iso8601, hr, human_readable. Default: hr #### Header Parameters - **Accept-Encoding** (string) - Required - Default: gzip, deflate, br - **api-version** (string) - Optional ### Response #### Success Response (200) - **status** (integer) - HTTP status code - **title** (string) - HTTP status title - **description** (string) - Description of the response - **payload** (object) - **metadata** (object) - **next** (string) - URL for the next page of results - **api-version** (string) - The API version used for the response - **data** (array) - **exchange** (string) - The name of the exchange - **instrument** (string) - The trading pair - **startDate** (integer) - The start timestamp for liquidation data - **endDate** (integer) - The end timestamp for liquidation data #### Response Example (200) ```json { "status": 200, "title": "OK", "description": "Successful request", "payload": { "metadata": { "next": "https://api.amberdata.com/markets/futures/liquidations/information?cursor=N4IglgdgxgNgrgEwKYEkIEMoBcwDckgBcAZujAM5IA0408yAqhOXAA6sD2ATlkggKIAPKAAt0EAOZJyRUhWogcAWyQAxbkvRYiIJWBgwwlKBwgIZNYhq06AVuVMgardFKIBGGuTAAvAoQBWAAYggF8gA", "api-version": "2023-09-30" }, "data": [ { "exchange": "binance", "instrument": "1000BONKUSDC", "startDate": 1714639265467, "endDate": 1717596728610 }, { "exchange": "binance", "instrument": "1000BONKUSDT", "startDate": 1700661767295, "endDate": 1717603600409 } ] } } ``` #### Error Response (400) ```json { "status": 400, "title": "Bad Request", "description": "Error message" } ``` ``` -------------------------------- ### Subscribe to Futures Liquidations Source: https://docs.amberdata.io/real-time/market/websocket-market-futures This example demonstrates how to establish a WebSocket connection and subscribe to real-time futures liquidation data for a specific instrument and exchange. ```APIDOC ## Subscribe to Futures Liquidations ### Description This endpoint allows you to subscribe to real-time liquidation events for futures contracts on a specified exchange. You can filter by instrument to receive only relevant data. ### Method WebSocket `SUBSCRIBE` ### Parameters #### Subscription Parameters - **topic** (string) - Required - The topic to subscribe to. For futures liquidations, use `market:futures:liquidations`. - **options** (object) - Required - An object containing subscription options. - **instrument** (string) - Required - The asset instrument (e.g., `BTCUSDT`). - **exchange** (string) - Required - The exchange for which to retrieve asset instruments (e.g., `binance`). ### Request Example ```json { "jsonrpc" : "2.0", "id" : 1, "method" : "subscribe", "params" : [ "market:futures:liquidations", { "instrument": "BTCUSDT", "exchange": "binance" } ] } ``` ### Response #### Subscription Confirmation Upon successful subscription, you will receive a confirmation message. #### Real-time Liquidations When a liquidation occurs, you will receive a message with the following structure: ```json { "jsonrpc": "2.0", "method": "subscription", "params": { "subscription": "", "result": { "exchange": "binance", "instrument": "AEVOUSDT", "timestamp": 1711571204802, "price": 2.9643448, "side": "SELL", "status": "FILLED", "type": "LIMIT", "timeInForce": "IOC", "action": null, "orderId": null, "volume": 31 } } } ``` #### Response Fields - **exchange** (string) - The exchange name. - **instrument** (string) - The instrument name. - **timestamp** (number) - The time at which the liquidation took place. - **price** (number) - The price at which the liquidation occurred. - **side** (string) - Indicates whether the liquidated position was a buy or sell. - **status** (string) - The status of the order at the time of the message. - **type** (string) - The type of order that was liquidated. - **timeInForce** (string) - Describes how long an order will remain active before it is executed or expires. - **action** (string) - This field will show as `null` for all exchanges except Bitmex. - **orderId** (string) - An identifier for the specific order that was liquidated (this field will show as `null` for most exchanges except Deribit and Bitmex). - **volume** (number) - The amount of the asset that was liquidated. #### Example Usage (Node.js) ```javascript const WebSocket = require('ws'); const ws = new WebSocket('wss://ws.amberdata.com/futures', {headers: {'x-api-key':''}}); ws.on('open', () => { ws.send(JSON.stringify({ jsonrpc: '2.0', method: 'subscribe', params: ['market:futures:liquidations', {'instrument': 'XRPUSDT', 'exchange': 'binance'}], id: 1, })); }); ws.on('message', data => { console.log(JSON.stringify(JSON.parse(data), null, 2)); }); ``` ``` -------------------------------- ### Get Futures OHLCV Information Source: https://docs.amberdata.io/http/market/futures-ohlcv-information Fetches available date ranges for OHLCV data on futures instruments across exchanges, including start and end dates for each instrument. ```APIDOC ## GET /futures/ohlcv/information ### Description Provides available date ranges for OHLCV (Open, High, Low, Close, Volume) data on futures instruments across exchanges, including start and end dates for each instrument. ### Method GET ### Endpoint /futures/ohlcv/information ### Parameters #### Query Parameters - **exchange** (string) - Optional - The exchange(s) for which to retrieve the most current data (comma separated). [Default] All available exchanges. - **instrument** (string) - Optional - Only return data for the given pair. - **includeInactive** (boolean) - Optional - If true, endpoint returns all instruments, including delisted ones. [Defaults] `True | False*`. - **timeFormat** (string) - Optional - Time format of the timestamps in the return payload. [Defaults] `milliseconds | ms* | iso | iso8601 | hr | human_readable` - **timeInterval** (string) - Optional - Time interval. [Defaults] `minutes* | hours | days` #### Header Parameters - **Accept-Encoding** (string) - Required - Default: `gzip, deflate, br` - **api-version** (string) - Optional ### Response #### Success Response (200) - **status** (integer) - Description: Successful request status code. - **title** (string) - Description: Title of the response. - **description** (string) - Description: Description of the response. - **payload** (object) - Contains metadata and data. - **metadata** (object) - Metadata about the response. - **next** (string) - URL for the next page of results. - **api-version** (string) - The API version used for the request. - **data** (array) - Array of OHLCV information. - **exchange** (string) - The name of the exchange. - **instrument** (string) - The instrument identifier. - **startDate** (integer) - The start date of the OHLCV data in milliseconds. - **endDate** (integer) - The end date of the OHLCV data in milliseconds. ### Response Example ```json { "status": 200, "title": "OK", "description": "Successful request", "payload": { "metadata": { "next": "https://api.amberdata.com/markets/futures/ohlcv/information?cursor=N4IglgdgxgNgrgEwKYEkIEMoBcwDckgBcAZujAM5IA0408yAqhOXAA6sD2ATlkggKIAPKAAt0EAOZJyRUhWogcAW1QReXXGSKgMKoiAToAnjJrkAjjABy6PYQPGQZyzZUAFeFy33DYGEacDJFI4GCwiAGYARgA2ACY4gBYABlTUmiV0QSIYiKTEgA409JAYDg4AawAjTAq3JC4wDgQiOOSAXxplJAAxbkzw%2ByU-GDBKKA4IBFMQYn70QZAAK3JJwNZ0KSIoszAALwJCAFZU9qA", "api-version": "2023-09-30" }, "data": [ { "exchange": "binance", "instrument": "1000BONKUSDC", "startDate": 1714608000000, "endDate": 1722297600000 } ] } } ``` ```