Socket
Book a DemoInstallSign in
Socket

apilayer-fixer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apilayer-fixer

Fixer API SDK

1.0.3
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Fixer SDK

A lightweight JavaScript SDK for interacting with the Fixer API. This SDK allows you to retrieve exchange rate data, convert currencies, and more, using the Fixer API.

Installation

Install the package using npm or yarn:

npm install apilayer-fixer
# or
yarn add apilayer-fixer

Usage

Import the SDK

import Fixer from "apilayer-fixer";

Initialize the SDK

const fixer = new Fixer("your_api_key");

Replace "your_api_key" with your actual API key from Fixer API.

Available Methods

1. symbols()

Retrieve available currency symbols.

fixer.symbols().then((data) => console.log(data));

2. latest(params)

Get the latest exchange rates.

  • Parameters: An object with optional parameters such as symbols (comma-separated list of currencies) and base (base currency).
fixer.latest({ symbols: "USD,EUR", base: "GBP" }).then((data) => console.log(data));

3. convert(params)

Convert an amount from one currency to another.

  • Parameters: An object with the following properties:
    • from: Source currency.
    • to: Target currency.
    • amount: Amount to convert.
fixer.convert({ from: "USD", to: "EUR", amount: 100 }).then((data) => console.log(data));

4. timeseries(params)

Get historical exchange rates for a specific date range.

  • Parameters: An object with the following properties:
    • start_date: Start date in YYYY-MM-DD format.
    • end_date: End date in YYYY-MM-DD format.
    • base (optional): Base currency.
    • symbols (optional): Comma-separated list of currencies.
fixer.timeseries({ start_date: "2023-01-01", end_date: "2023-01-31", base: "USD" }).then((data) => console.log(data));

5. fluctuation(params)

Get information about fluctuations in exchange rates.

  • Parameters: An object with the following properties:
    • start_date: Start date in YYYY-MM-DD format.
    • end_date: End date in YYYY-MM-DD format.
    • base (optional): Base currency.
    • symbols (optional): Comma-separated list of currencies.
fixer.fluctuation({ start_date: "2023-01-01", end_date: "2023-01-31" }).then((data) => console.log(data));

Error Handling

The SDK will throw errors if the API key is invalid or if there are issues with the API request. Ensure you handle errors in your code:

fixer
    .latest()
    .then((data) => console.log(data))
    .catch((error) => console.error("Error fetching data:", error));

API Documentation

For more information about available endpoints and parameters, refer to the Fixer API Documentation.

License

This package is licensed under the MIT License.

FAQs

Package last updated on 19 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.