getPoolOHLCV
Retrieve historical OHLCV data for a specific liquidity pool to analyze price trends, backtest strategies, and visualize market behavior. Specify network, pool address, time range, and interval for precise insights.
Instructions
Get historical price data (OHLCV) for a pool - essential for price analysis, backtesting, and visualization. Requires network and pool address.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | No | End time for historical data (max 1 year from start) | |
| interval | No | Interval granularity: 1m, 5m, 10m, 15m, 30m, 1h, 6h, 12h, 24h | 24h |
| inversed | No | Whether to invert the price ratio for alternative pair perspective (e.g., ETH/USDC vs USDC/ETH) | |
| limit | No | Number of data points to retrieve (max 366) - adjust for different analysis needs | |
| network | Yes | Network ID from getNetworks (e.g., "ethereum", "solana") | |
| poolAddress | Yes | Pool address or identifier | |
| start | Yes | Start time for historical data (Unix timestamp, RFC3339 timestamp, or yyyy-mm-dd format) |
Implementation Reference
- src/index.js:207-214 (handler)Handler function that constructs the DexPaprika API endpoint for pool OHLCV data based on input parameters and fetches the data using the fetchFromAPI helper, returning formatted MCP response.async ({ network, poolAddress, start, end, limit, interval, inversed }) => { let endpoint = `/networks/${network}/pools/${poolAddress}/ohlcv?start=${encodeURIComponent(start)}&interval=${interval}&limit=${limit}&inversed=${inversed}`; if (end) { endpoint += `&end=${encodeURIComponent(end)}`; } const data = await fetchFromAPI(endpoint); return formatMcpResponse(data); }
- src/index.js:198-206 (schema)Zod input schema defining parameters for the getPoolOHLCV tool: network, poolAddress, start, end, limit, interval, inversed.{ network: z.string().describe('Network ID from getNetworks (e.g., "ethereum", "solana")'), poolAddress: z.string().describe('Pool address or identifier'), start: z.string().describe('Start time for historical data (Unix timestamp, RFC3339 timestamp, or yyyy-mm-dd format)'), end: z.string().optional().describe('End time for historical data (max 1 year from start)'), limit: z.number().optional().default(1).describe('Number of data points to retrieve (max 366) - adjust for different analysis needs'), interval: z.string().optional().default('24h').describe('Interval granularity: 1m, 5m, 10m, 15m, 30m, 1h, 6h, 12h, 24h'), inversed: z.boolean().optional().default(false).describe('Whether to invert the price ratio for alternative pair perspective (e.g., ETH/USDC vs USDC/ETH)') },
- src/index.js:195-215 (registration)Registration of the getPoolOHLCV tool using server.tool(), specifying name, description, input schema, and handler function.server.tool( 'getPoolOHLCV', 'Get historical price data (OHLCV) for a pool - essential for price analysis, backtesting, and visualization. Requires network and pool address.', { network: z.string().describe('Network ID from getNetworks (e.g., "ethereum", "solana")'), poolAddress: z.string().describe('Pool address or identifier'), start: z.string().describe('Start time for historical data (Unix timestamp, RFC3339 timestamp, or yyyy-mm-dd format)'), end: z.string().optional().describe('End time for historical data (max 1 year from start)'), limit: z.number().optional().default(1).describe('Number of data points to retrieve (max 366) - adjust for different analysis needs'), interval: z.string().optional().default('24h').describe('Interval granularity: 1m, 5m, 10m, 15m, 30m, 1h, 6h, 12h, 24h'), inversed: z.boolean().optional().default(false).describe('Whether to invert the price ratio for alternative pair perspective (e.g., ETH/USDC vs USDC/ETH)') }, async ({ network, poolAddress, start, end, limit, interval, inversed }) => { let endpoint = `/networks/${network}/pools/${poolAddress}/ohlcv?start=${encodeURIComponent(start)}&interval=${interval}&limit=${limit}&inversed=${inversed}`; if (end) { endpoint += `&end=${encodeURIComponent(end)}`; } const data = await fetchFromAPI(endpoint); return formatMcpResponse(data); } );
- src/index.js:10-34 (helper)Helper function fetchFromAPI used by getPoolOHLCV to make API requests to DexPaprika, handling specific error codes like 410 (deprecated endpoint) and 429 (rate limit).async function fetchFromAPI(endpoint) { try { const response = await fetch(`${API_BASE_URL}${endpoint}`); if (!response.ok) { if (response.status === 410) { throw new Error( 'This endpoint has been permanently removed. Please use network-specific endpoints instead. ' + 'For example, use /networks/{network}/pools instead of /pools. ' + 'Get available networks first using the getNetworks function.' ); } if (response.status === 429) { throw new Error( 'Rate limit exceeded. You have reached the maximum number of requests allowed for the free tier. ' + 'To increase your rate limits and access additional features, please consider upgrading to a paid plan at https://docs.dexpaprika.com/' ); } throw new Error(`API request failed with status ${response.status}`); } return await response.json(); } catch (error) { console.error(`Error fetching from API: ${error.message}`); throw error; } }
- src/index.js:37-46 (helper)Helper function formatMcpResponse used by getPoolOHLCV to format the API data into the MCP response structure with JSON stringified content.function formatMcpResponse(data) { return { content: [ { type: "text", text: JSON.stringify(data) } ] }; }