Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
fixer
✓ import * as fixer from 'fixer-api';
✗ const fixer = require('fixer-api');
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.
fixer (CommonJS)
✓ const fixer = require('fixer-api');
✗ import fixer from 'fixer-api';
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.
FixerOptions (Type)
✓ import { FixerOptions } from 'fixer-api';
Import types explicitly for full type safety in TypeScript projects. Other types like `LatestResponse`, `HistoricalResponse`, `ConvertResponse` are also available.
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.
import * as fixer from 'fixer-api';
const API_KEY = process.env.FIXER_API_KEY ?? '';
if (!API_KEY) {
console.error('Environment variable FIXER_API_KEY is not set. Please obtain a key from fixer.io.');
process.exit(1);
}
// Set your API key globally for all subsequent requests
fixer.set({ accessKey: API_KEY });
async function fetchCurrencyData() {
try {
console.log('Fetching latest exchange rates...');
// Get latest exchange rates, specifying base and symbols
const latestRates = await fixer.latest({ base: 'USD', symbols: ['EUR', 'GBP', 'JPY'] });
console.log('Latest Rates (USD base):', latestRates);
console.log('\nFetching historical data...');
// Fetch historical data for a specific date (e.g., January 1, 2023)
const historicalDate = '2023-01-01';
const historicalRates = await fixer.forDate(historicalDate, { base: 'EUR', symbols: ['USD', 'JPY'] });
console.log(`Historical Rates (${historicalDate}, EUR base):`, historicalRates);
// Example for currency conversion (requires a paid fixer.io plan)
// console.log('\nAttempting currency conversion (requires paid plan)...');
// const convertResult = await fixer.convert('GBP', 'USD', 100, '2023-05-15');
// console.log('100 GBP to USD on 2023-05-15:', convertResult);
console.log('\nFetching available currency symbols...');
// List all supported currency symbols
const symbols = await fixer.symbols();
console.log('Supported Symbols (first 5):', Object.keys(symbols.symbols).slice(0, 5));
} catch (error: any) {
console.error('\nError fetching data:', error.message);
if (error.message.includes('not supplied an API Access Key')) {
console.error('Ensure your FIXER_API_KEY is correct and active.');
} else if (error.message.includes('not available on your current subscription plan')) {
console.error('The requested feature might require a paid fixer.io plan.');
}
}
}
fetchCurrencyData();
Errors
Common errors & fixes
You have not supplied an API Access Key.
The fixer.io API requires a valid API key for all requests, which was either missing or incorrect in your configuration.
fixEnsure your `FIXER_API_KEY` environment variable is set, or explicitly pass the `accessKey` option when initializing the client or making requests.
Function 'convert' is not available on your current subscription plan. Please upgrade your subscription to use this feature.
Attempted to use a premium endpoint (like `convert` or `timeseries`) with a fixer.io API key associated with a free or insufficient subscription plan.
fixReview your fixer.io account and upgrade your subscription to a plan that includes the desired API features.
ReferenceError: require is not defined in ES module scope
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`).
fixUpdate your import statement to use `import * as fixer from 'fixer-api';` for ESM compatibility.
Error: The fixer-api package requires Node.js version 18 or higher.
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.
fixUpgrade your Node.js environment to version 18 or newer. Check your installed Node.js version with `node -v`.
Audit
Dependencies
No dependency data recorded yet.