get-market-history
Retrieve historical market data for a specific item in a region using the EVE Online API. Input region and item IDs to access detailed trade insights.
Instructions
Get market history for a specific item in a region
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region_id | Yes | Region ID to get market history from | |
| type_id | Yes | Item type ID to get history for |
Implementation Reference
- src/index.ts:330-341 (handler)Handler function that fetches market history data from the EVE Online ESI API endpoint `/markets/${region_id}/history/?type_id=${type_id}` using the shared makeESIRequest helper and returns it as a formatted JSON text content block.async ({ region_id, type_id }) => { const history = await makeESIRequest<Array<MarketHistory>>(`/markets/${region_id}/history/?type_id=${type_id}`); return { content: [ { type: "text", text: JSON.stringify(history, null, 2), }, ], }; }
- src/index.ts:326-329 (schema)Zod schema defining the required input parameters: region_id (number) and type_id (number).{ region_id: z.number().describe("Region ID to get market history from"), type_id: z.number().describe("Item type ID to get history for"), },
- src/index.ts:323-342 (registration)Tool registration via server.tool() call, including name 'get-market-history', description, input schema, and inline handler implementation.server.tool( "get-market-history", "Get market history for a specific item in a region", { region_id: z.number().describe("Region ID to get market history from"), type_id: z.number().describe("Item type ID to get history for"), }, async ({ region_id, type_id }) => { const history = await makeESIRequest<Array<MarketHistory>>(`/markets/${region_id}/history/?type_id=${type_id}`); return { content: [ { type: "text", text: JSON.stringify(history, null, 2), }, ], }; } );
- src/index.ts:44-51 (helper)TypeScript interface defining the structure of market history data items returned by the ESI API.interface MarketHistory { average: number; date: string; highest: number; lowest: number; order_count: number; volume: number; }
- src/index.ts:222-256 (helper)Shared helper function for making authenticated ESI API requests, handling rate limits, errors, and headers. Used by the get-market-history handler.async function makeESIRequest<T>(endpoint: string, token?: string): Promise<T> { if (!checkRateLimit(endpoint)) { throw new Error("Rate limit exceeded. Please try again later."); } const headers: Record<string, string> = { "User-Agent": USER_AGENT, "Accept": "application/json", }; if (token) { headers["Authorization"] = `Bearer ${token}`; } const response = await fetch(`${ESI_BASE_URL}${endpoint}`, { headers }); updateRateLimit(endpoint, response.headers); if (!response.ok) { let errorMessage = `HTTP error! status: ${response.status}`; try { const errorData = await response.json() as ESIError; if (errorData.error) { errorMessage = `ESI Error: ${errorData.error}`; if (errorData.error_description) { errorMessage += ` - ${errorData.error_description}`; } } } catch { // エラーJSONのパースに失敗した場合は、デフォルトのエラーメッセージを使用 } throw new Error(errorMessage); } return response.json() as Promise<T>; }