{"id":13187,"library":"fixer-api","title":"fixer.io API Client","description":"The `fixer-api` library provides a robust and type-safe client for the fixer.io currency exchange rate API, supporting both Node.js and browser environments. The current stable version is v2.3.0. This package primarily sees maintenance releases to update dependencies and ensure compatibility, with new features (like `timeseries` or `symbols` endpoint support) arriving less frequently. Its key differentiators include zero runtime dependencies (as of v2.3.0, after dropping `node-fetch`), full TypeScript support for type safety and autocomplete, and a universal design that works across different JavaScript runtimes.","status":"active","version":"2.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/svlapin/fixer-api","tags":["javascript","currency","convert","exchange","rates","typescript"],"install":[{"cmd":"npm install fixer-api","lang":"bash","label":"npm"},{"cmd":"yarn add fixer-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add fixer-api","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"For modern Node.js environments (v18+) and browser applications, use ESM imports. While the quickstart shows CommonJS 'require', ESM is preferred for new projects, especially with TypeScript. The package is bundled for both ESM and CommonJS.","wrong":"const fixer = require('fixer-api');","symbol":"fixer","correct":"import * as fixer from 'fixer-api';"},{"note":"This CommonJS import style is compatible with older Node.js projects or environments that do not support ESM natively, or when specifically targeting a CommonJS bundle. Using `import` in a strict CommonJS context may lead to unexpected behavior.","wrong":"import fixer from 'fixer-api';","symbol":"fixer (CommonJS)","correct":"const fixer = require('fixer-api');"},{"note":"Import types explicitly for full type safety in TypeScript projects. Other types like `LatestResponse`, `HistoricalResponse`, `ConvertResponse` are also available.","symbol":"FixerOptions (Type)","correct":"import { FixerOptions } from 'fixer-api';"}],"quickstart":{"code":"import * as fixer from 'fixer-api';\n\nconst API_KEY = process.env.FIXER_API_KEY ?? '';\n\nif (!API_KEY) {\n  console.error('Environment variable FIXER_API_KEY is not set. Please obtain a key from fixer.io.');\n  process.exit(1);\n}\n\n// Set your API key globally for all subsequent requests\nfixer.set({ accessKey: API_KEY });\n\nasync function fetchCurrencyData() {\n  try {\n    console.log('Fetching latest exchange rates...');\n    // Get latest exchange rates, specifying base and symbols\n    const latestRates = await fixer.latest({ base: 'USD', symbols: ['EUR', 'GBP', 'JPY'] });\n    console.log('Latest Rates (USD base):', latestRates);\n\n    console.log('\\nFetching historical data...');\n    // Fetch historical data for a specific date (e.g., January 1, 2023)\n    const historicalDate = '2023-01-01';\n    const historicalRates = await fixer.forDate(historicalDate, { base: 'EUR', symbols: ['USD', 'JPY'] });\n    console.log(`Historical Rates (${historicalDate}, EUR base):`, historicalRates);\n\n    // Example for currency conversion (requires a paid fixer.io plan)\n    // console.log('\\nAttempting currency conversion (requires paid plan)...');\n    // const convertResult = await fixer.convert('GBP', 'USD', 100, '2023-05-15');\n    // console.log('100 GBP to USD on 2023-05-15:', convertResult);\n\n    console.log('\\nFetching available currency symbols...');\n    // List all supported currency symbols\n    const symbols = await fixer.symbols();\n    console.log('Supported Symbols (first 5):', Object.keys(symbols.symbols).slice(0, 5));\n\n  } catch (error: any) {\n    console.error('\\nError fetching data:', error.message);\n    if (error.message.includes('not supplied an API Access Key')) {\n      console.error('Ensure your FIXER_API_KEY is correct and active.');\n    } else if (error.message.includes('not available on your current subscription plan')) {\n      console.error('The requested feature might require a paid fixer.io plan.');\n    }\n  }\n}\n\nfetchCurrencyData();","lang":"typescript","description":"Demonstrates setting a global API key, fetching latest exchange rates with specific symbols, retrieving historical data for a given date, and listing available currency symbols. Includes robust error handling and notes for paid features."},"warnings":[{"fix":"Upgrade your Node.js runtime environment to version 18 or higher. Use a version manager like `nvm` for easy switching.","message":"The minimum required Node.js version has been updated to `>=18.0.0` as of v2.3.0. Users on older Node.js versions will encounter compatibility issues and need to upgrade their runtime.","severity":"breaking","affected_versions":">=2.3.0"},{"fix":"If `node-fetch` was a critical dependency for your project, ensure it is explicitly installed and managed in your `package.json`.","message":"The internal `node-fetch` dependency was explicitly dropped in v2.3.0, making the package have zero runtime dependencies. While this improves performance and reduces bundle size, projects that might have indirectly relied on `node-fetch` being a transitive dependency of `fixer-api` could be affected.","severity":"breaking","affected_versions":">=2.3.0"},{"fix":"Obtain an API key from fixer.io and provide it via `fixer.set({ accessKey: 'YOUR_API_KEY' })` or as an option in each request `{ access_key: 'YOUR_API_KEY' }`. It's recommended to use environment variables for keys.","message":"An API Access Key from fixer.io is mandatory for all requests to the API. Failing to provide a valid key will result in authentication errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Verify your fixer.io subscription plan supports the desired endpoints, or upgrade your subscription if necessary. Check the fixer.io product page for plan details.","message":"Certain endpoints, specifically `convert`, `timeseries`, and others that involve advanced features, require a paid subscription plan on fixer.io. Attempting to use these endpoints with a free API key will result in an error indicating plan limitations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update `fixer-api` to v2.2.4 or newer to ensure the `node-fetch` dependency is updated or removed, mitigating potential security risks.","message":"Version 2.2.4 included a security bump for the `node-fetch` dependency (to `2.6.7`) to mitigate an information exposure bug. Although `node-fetch` was later removed, users on `fixer-api` versions prior to `2.2.4` might have been exposed to this vulnerability through the transitive dependency.","severity":"gotcha","affected_versions":"<2.2.4"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure your `FIXER_API_KEY` environment variable is set, or explicitly pass the `accessKey` option when initializing the client or making requests.","cause":"The fixer.io API requires a valid API key for all requests, which was either missing or incorrect in your configuration.","error":"You have not supplied an API Access Key."},{"fix":"Review your fixer.io account and upgrade your subscription to a plan that includes the desired API features.","cause":"Attempted to use a premium endpoint (like `convert` or `timeseries`) with a fixer.io API key associated with a free or insufficient subscription plan.","error":"Function 'convert' is not available on your current subscription plan. Please upgrade your subscription to use this feature."},{"fix":"Update your import statement to use `import * as fixer from 'fixer-api';` for ESM compatibility.","cause":"Using `const fixer = require('fixer-api');` within an ECMAScript Module (ESM) context (e.g., in a `.mjs` file or a project with `\"type\": \"module\"` in `package.json`).","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"Upgrade your Node.js environment to version 18 or newer. Check your installed Node.js version with `node -v`.","cause":"The `fixer-api` package, starting from v2.3.0, has a minimum Node.js requirement of 18, and your current Node.js version is older.","error":"Error: The fixer-api package requires Node.js version 18 or higher."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}