Registry / http-networking / fixer-api

fixer-api

JSON →
library2.3.0jsnpmunverified

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.

npm install fixer-api
INSTALL
IMPORT
SIG · FIXER-API
F
fixer-api
http-networkingjavascriptv2.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 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();
Debug
Known issues
breakingThe 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.
fix
Upgrade your Node.js runtime environment to version 18 or higher. Use a version manager like `nvm` for easy switching.
affects: >=2.3.0
breakingThe 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.
fix
If `node-fetch` was a critical dependency for your project, ensure it is explicitly installed and managed in your `package.json`.
affects: >=2.3.0
gotchaAn 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.
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.
affects: >=1.0.0
gotchaCertain 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.
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.
affects: >=1.0.0
gotchaVersion 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.
fix
Update `fixer-api` to v2.2.4 or newer to ensure the `node-fetch` dependency is updated or removed, mitigating potential security risks.
affects: <2.2.4
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.
fix
Ensure 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.
fix
Review 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`).
fix
Update 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.
fix
Upgrade your Node.js environment to version 18 or newer. Check your installed Node.js version with `node -v`.
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
fixer-api — npm install fixer-api · libregistry