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

gatsby-source-fixer-io

v0.1.0

Published

A gatsby source plugin for fixer-io

Downloads

11

Readme

gatsby-source-fixer-io

Build Status

Description

This is a source plugin for Gatsby that will bring data (rates, conversion etc.) from Fixer to be available in GraphQL queries. This utility will be occasionaly maintained to keep up with the happenings to endpoints on fixer.io

Dependencies

NPM

This package has been published on NPM and is freely available according to the MIT license. To install via npm simply run npm install gatsby-source-fixer-io.

Gatsby Usage

Install the source plugin from your Command Line

npm i gatsby-source-fixer-io

or

yarn add gatsby-source-fixer-io

In your gatsby-config.js configure the following

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-fixer-io',
      options: {
        apiKey: 'YOUR_FIXER_IO_API_KEY', /* Required Field */
        endpoint: 'name of endpoint e.g. `latest`', /* Required Field */
        query: { /* Optional */
          base: 'base currency e.g. EUR',
        }
      }
    }
  ]
}

Configuration Options

The configuration for this plugin follows supports the requests listed on fixer

  1. The apiKey - This refers to the unique client api key generated at fixer.io. Register for an account and then navigate to your dashboard where you will find you API Key.

  2. The endpoint - This refers to the endpoint to which the call should be made. The available options at the moment of this writing are latest,symbols, convert, timeseries, fluctuation and dates e.g. YYYY-MM-DD. Kindly consult the official endpoint documentation for any endpoints not listed here, however the pluggin is flexible to support new endpoints without any changes needed whenever new plugins are available.

  3. The query - This refers to a javascript object constructed to match the require params in a key - value format. Kindly consult the official endpoint documentation for the available parameter fields that can be used. The format of the query object should always mimick same as in the official documentation.

Below is an example taken directly from the fixer.io Historical rates Endpoint documentation and converted into a gatsby configuration

From Fixer.io

http://data.fixer.io/api/2013-12-24
    ? access_key = API_KEY
    & base = GBP
    & symbols = USD,CAD,EUR

Representation in gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-fixer-io',
      options: {
        apiKey: '1234ABCD5678EFGH90IJ',
        endpoint: '2013-12-24',
        query: { 
          base: 'GBP',
          symbols: 'USD,CAD,EUR'
        }
      }
    }
  ]
}

Querying Fixer IO endpoints

Once the plugin is configured, two new queries are available in GraphQL: allFixerIoData<Endpoint> and fixerIoData<Endpoint>. It is important to note that regardless of how you specify the endpoint string, in the available GraphQL queries, the string is capitalized i.e. the first letter of the string will be converted to a capital letter except for dates e.g. 2013-12-24 as they will remain as is. Typically the queries should look thus fixerIODataLatest where latest is the endpoint or fixerIOData2013-12-24 where 2013-12-24 is the endpoint

An example GraphQL query should look to get the latest rate of EUR to USD should look thus

{
  fixerIoDataLatest {
    rates {
      USD
    }
  }
}

where the gatsby-config.js options field for the plugin are configured thus

options: {
  apiKey: "1234ABCD5678EFGH90IJ",
  endpoint: "latest",
  query: {base: "EUR"},
}

Disclaimer

I am in no way connected to those who work at fixer.io. Project is simply a side project which I use and will try to maintain and expand as much as I can.