Socket
Book a DemoInstallSign in
Socket

gatsby-source-exchange-rates-api

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-source-exchange-rates-api

A Gatsby source plugin for retrieving data from the exchangeratesapi.io API

2.0.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

NPM version

Description

A Gatsby source plugin for retrieving data from the exchangeratesapi.io API.

How to install

Install the package as a dependency

yarn add gatsby-source-exchange-rates-api

Add the plugin to your gatsby-config.js file

// gatsby-config.js
{
  plugins: [
    {
      resolve: 'gatsby-source-exchange-rates-api',
    }
  ]
}

How to query data

You can select the endpoint to fetch from by specifying endpoint in the plugins options object. The default is the endpoint latest. You can also specify query parameters as a query object (default is no query).

Exchange Rates API documentation: (Github) (Website)

// gatsby-config.js
{
  resolve: 'gatsby-source-exchange-rates-api',
  options: {
    endpoint: 'history', // (optional) default is "latest"
    query: { // (optional)
      base: 'SEK',
      symbols: 'EUR,USD',
      start_at: '2019-02-01',
      end_at: '2019-02-03',
    },
  }
}

If you use the default endpoint latest you will get one node with the latest rates. If you use the endpoint history there will be multiple rates returned as an array instead.

Latest endpoint usage example

// Get the latest rates
useStaticQuery(graphql`
  query {
    exchangeRates {
      id
      date
      USD
    }
  }
`)

History endpoint usage example

// Get an array of history rates
useStaticQuery(graphql`
  query {
    allExchangeRates {
      edges {
        node {
          id
          date
          USD
          EUR
        }
      }
    }
  }
`)

Credits

Madis Väin, creator of the Exchange Rates API

https://exchangeratesapi.io/

Keywords

gatsby

FAQs

Package last updated on 05 Jul 2019

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.