### Installation with NPM Source: https://github.com/metalpriceapi/metalpriceapi-nodejs/blob/main/README.md Installs the metalpriceapi Node.js package using npm. ```javascript npm i metalpriceapi ``` -------------------------------- ### Basic Usage Example Source: https://github.com/metalpriceapi/metalpriceapi-nodejs/blob/main/README.md Demonstrates setting the API key and fetching live metal prices for specified currencies. ```javascript const api = require('metalpriceapi'); api.setAPIKey('SET_YOUR_API_KEY_HERE'); await api.fetchLive('USD', ['XAU', 'XAG', 'XPD', 'XPT']); ``` -------------------------------- ### MetalpriceAPI API Documentation Source: https://github.com/metalpriceapi/metalpriceapi-nodejs/blob/main/README.md Provides details on various API methods for fetching metal prices, exchange rates, and related data. Includes method signatures, parameters, and usage examples. ```APIDOC setAPIKey(apiKey) - Sets the API key for authentication. - Parameters: - apiKey : Your MetalpriceAPI.com API Key. - Usage: api.setAPIKey('SET_YOUR_API_KEY_HERE'); fetchSymbols() - Fetches a list of available currency symbols. - Returns: A promise that resolves to an object containing currency symbols. - Usage: await api.fetchSymbols(); - Related: [Link](https://metalpriceapi.com/documentation#api_symbol) fetchLive(base, currencies) - Fetches live metal prices. - Parameters: - base : Optional. The base currency (defaults to USD). - currencies >: Optional. An array of currency codes to fetch prices for. - Usage: await api.fetchLive('USD', ['XAU', 'XAG', 'XPD', 'XPT']); - Related: [Link](https://metalpriceapi.com/documentation#api_realtime) fetchHistorical(date, base, currencies) - Fetches historical metal prices for a specific date. - Parameters: - date : Required. The date in 'YYYY-MM-DD' format. - base : Optional. The base currency (defaults to USD). - currencies >: Optional. An array of currency codes to fetch prices for. - Usage: await api.fetchHistorical('2024-02-05', 'USD', ['XAU', 'XAG', 'XPD', 'XPT']); - Related: [Link](https://metalpriceapi.com/documentation#api_historical) ohlc(base, currency, date, unit, dateType) - Fetches Open, High, Low, Close data for a given currency and date. - Parameters: - base : Optional. The base currency (defaults to USD). - currency : Required. The currency code to get OHLC data for. - date : Required. The date in 'YYYY-MM-DD' format. - unit : Optional. The unit of measurement (defaults to 'troy_oz'). - dateType : Optional. Overrides the date parameter if provided. - Usage: await api.ohlc('USD', 'XAU', '2024-02-06', 'troy_oz', null); - Related: [Link](https://metalpriceapi.com/documentation#api_ohlc) convert(from, to, amount, date) - Converts an amount from one currency to another. - Parameters: - from : Optional. The base currency (defaults to USD). - to : Required. The target currency code. - amount : Required. The amount to convert. - date : Optional. The date in 'YYYY-MM-DD' format for historical conversion. - Usage: await api.convert('USD', 'EUR', 100, '2024-02-05'); - Related: [Link](https://metalpriceapi.com/documentation#api_convert) timeframe(start_date, end_date, base, currencies) - Fetches metal prices over a specified timeframe. - Parameters: - start_date : Required. The start date in 'YYYY-MM-DD' format. - end_date : Required. The end date in 'YYYY-MM-DD' format. - base : Optional. The base currency (defaults to USD). - currencies >: Optional. An array of currency codes. - Usage: await api.timeframe('2024-02-05', '2024-02-06', 'USD', ['XAU', 'XAG', 'XPD', 'XPT']); - Related: [Link](https://metalpriceapi.com/documentation#api_timeframe) change(start_date, end_date, base, currencies) - Fetches the change in metal prices over a specified timeframe. - Parameters: - start_date : Required. The start date in 'YYYY-MM-DD' format. - end_date : Required. The end date in 'YYYY-MM-DD' format. - base : Optional. The base currency (defaults to USD). - currencies >: Optional. An array of currency codes. - Usage: await api.change('2024-02-05', '2024-02-06', 'USD', ['XAU', 'XAG', 'XPD', 'XPT']); - Related: [Link](https://metalpriceapi.com/documentation#api_change) carat(base, date) - Fetches Carat data, potentially related to gold or other precious metals. - Parameters: - base : Optional. The base currency (defaults to USD). - date : Optional. The date in 'YYYY-MM-DD' format for specific Carat data (defaults to live rates). - Usage: await api.carat('USD', '2024-02-06'); - Related: [Link](https://metalpriceapi.com/documentation#api_carat) usage() - Fetches information about API usage limits and statistics. - Usage: await api.usage(); - Related: [Link](https://metalpriceapi.com/documentation#api_usage) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.