npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apilayer-fixer

v1.0.3

Published

Fixer API SDK

Downloads

70

Readme

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.