Git Product home page Git Product logo

npm-exchange-rates's Introduction

Open Exchange Rates npm/nodeJS module

nodeJS/npm wrapper for the Open Exchange Rates API service. Loads up-to-date or historical currency/exchange rate data from the API, for seamless server-side integration.

Requires a free or paid App ID to connect to the service, available here.

Introduction

$ npm install open-exchange-rates

To install, type npm install open-exchange-rates in the terminal.

Requires: http-agent

Example Usage:

See the example.js script in this repository for a basic, working example.

Load the module:

var oxr = require('open-exchange-rates');

Load the latest rates from https://openexchangerates.org:

var oxr = require('open-exchange-rates');
oxr.set({ app_id: 'YOUR_APP_ID' })

oxr.latest(function() {
	// You can now use `oxr.rates`, `oxr.base` and `oxr.timestamp`
});

Get historical rates ("YYYY-MM-DD"):

var oxr = require('open-exchange-rates');
oxr.set({ app_id: 'YOUR_APP_ID' })

oxr.historical('2001-02-03', function() {
	// You can now use `oxr.rates`, `oxr.base` and `oxr.timestamp`
});

Currency conversion with money.js (fx) module:

money.js (npm install money) is a tiny JavaScript currency-conversion library for web and nodeJS.

var oxr = require('open-exchange-rates'),
	fx = require('money');

oxr.set({ app_id: 'YOUR_APP_ID' })

oxr.latest(function() {
	// Apply exchange rates and base rate to `fx` library object:
	fx.rates = oxr.rates;
	fx.base = oxr.base;
	
	// money.js is ready to use:
	fx(100).from('HKD').to('GBP'); // ~8.0424
});

Advanced API Features:

Advanced API features (such as Time Series requests and real-time value conversion) will be added to this module in future.

More Info

For more information, documentation, examples and showcase, check out the Open Exchange Rates homepage

Roadmap

  • Support HTTPS connections
  • Support advanced API queries/features
  • Support Time Series data requests
  • Support Date objects for historical queries

Changelog

0.3

  • Now maintained by openexchangerates.org
  • Tidied up library, readme and example

0.2

  • Updated to work with Open Exchange Rates App IDs
  • Renamed to 'open-exchange-rates'

0.1 - first version

npm-exchange-rates's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.