All Projects â†’ continuous-software â†’ Oxr

continuous-software / Oxr

💱 Node.js wrapper for the Open Exchange Rates API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Oxr

Fixer
A foreign exchange rates and currency conversion API
Stars: ✭ 2,545 (+3434.72%)
Mutual labels:  currencies, money
monetized
A lightweight solution for handling and storing money.
Stars: ✭ 46 (-36.11%)
Mutual labels:  money, currencies
Prices
Python price handling for humans.
Stars: ✭ 248 (+244.44%)
Mutual labels:  currencies, money
Django Prices
Django fields for the prices module
Stars: ✭ 135 (+87.5%)
Mutual labels:  currencies, money
EasyMoney-Widgets
The widgets (EditText and TextView) for support of money requirements like currency, number formatting, comma formatting etc.
Stars: ✭ 91 (+26.39%)
Mutual labels:  money, currencies
Nodamoney
NodaMoney provides a library that treats Money as a first class citizen and handles all the ugly bits like currencies and formatting.
Stars: ✭ 144 (+100%)
Mutual labels:  currencies, money
binaryapi
Binary.com & Deriv.com API for Python
Stars: ✭ 32 (-55.56%)
Mutual labels:  money, forex
latinum
Latinum is a framework for resource and currency calculations.
Stars: ✭ 109 (+51.39%)
Mutual labels:  money, currencies
SimpleTypes
The universal PHP library to convert any values and measures (money, weight, currency converter, length, etc.).
Stars: ✭ 56 (-22.22%)
Mutual labels:  money, currencies
django-prices-openexchangerates
openexchangerates.org support for django-prices
Stars: ✭ 33 (-54.17%)
Mutual labels:  money, currencies
Javamoney Lib
JavaMoney financial libraries, extending and complementing JSR 354
Stars: ✭ 104 (+44.44%)
Mutual labels:  currencies, money
currency-converter
💰 Easily convert between 32 currencies
Stars: ✭ 16 (-77.78%)
Mutual labels:  money, currencies
Countries
Countries - ISO 3166 (ISO3166-1, ISO3166, Digit, Alpha-2 and Alpha-3) countries codes and names (on eng and rus), ISO 4217 currency designators, ITU-T E.164 IDD calling phone codes, countries capitals, UN M.49 regions codes, ccTLD countries domains, IOC/NOC and FIFA letters codes, VERY FAST, NO maps[], NO slices[], NO init() funcs, NO external links/files/data, NO interface{}, NO specific dependencies, Databases/JSON/GOB/XML/CSV compatible, Emoji countries flags and currencies support, full support ISO-3166-1, ISO-4217, ITU-T E.164, Unicode CLDR and ccTLD standarts.
Stars: ✭ 85 (+18.06%)
Mutual labels:  currencies, money
Cash Cli
💰💰 Convert currency rates directly from your terminal!
Stars: ✭ 168 (+133.33%)
Mutual labels:  currencies, money
stockholm
💵 Modern Python library for working with money and monetary amounts. Human friendly and flexible approach for development. 100% test coverage + built-in support for GraphQL and Protocol Buffers transports using current best-practices.
Stars: ✭ 26 (-63.89%)
Mutual labels:  money, currencies
currency-conversion
Convert Money Amounts between currencies.
Stars: ✭ 19 (-73.61%)
Mutual labels:  money, currencies
react-local-currency
💵 💴Shows the price of your services in the customer's currency 💶 💷
Stars: ✭ 21 (-70.83%)
Mutual labels:  money, currencies
Ta4j
A Java library for technical analysis.
Stars: ✭ 948 (+1216.67%)
Mutual labels:  forex
Django Money
Money fields for Django forms and models.
Stars: ✭ 1,064 (+1377.78%)
Mutual labels:  money
Tic Tac
Client not paid ? This is the solution of your problem
Stars: ✭ 29 (-59.72%)
Mutual labels:  money

Build Status Coverage Status

Open eXchange Rates

A Node.js client for the Open Exchange Rates API.
Our client is designed to return Promises and provide a flexible caching capability.

Install

npm install --save oxr

Usage

Use the factory to create any number of client instances using your API keys

var oxr = require('oxr')
var service = oxr.factory({
  appId: process.env.OXR_APP_ID || '<YOUR_APP_ID>'
})

service.latest().then(function(result){
  var rates = result.rates
  console.log(rates)
})

Service API

latest(query, options)

@params query (optional) - A map of query string parameters to pass to the http call.
@params options (optional)- An object to merge with the http options sent to the remote API.
@returns - A promise with the latest rates from openexchangerates.org if resolved, reject with an Instance if the remote API returns an error response or with a standard Error otherwise.

historical(date, query, options)

@params date - Date object or a String which would result in a valid Date object if called with the Date constructor.
@params query (optional) - A map of query string parameters to pass to the http call.
@params options (optional) - An object to merge with the http options sent to the remote API.
@returns - A promise with the rates at the requested date from openexchangerates.org if resolved, reject with an Instance if the remote API returns an error response or with a standard Error otherwise.

currencies(query, options)

@params query (optional) - A map of query string parameters to pass to the http call.
@params options (optional) - An object to merge with the http options sent to the remote API.
@returns - A promise with the list of currency codes from openexchangerates.org if resolved, reject with an Instance if the remote API returns an error response or with a standard Error otherwise.

Cache Decorator

You can also decorate the service methods with a cache.

@params method (optional) - the method to decorate.
Defaults to latest

@params store

  • @params store.get(...methodArgs) - called before a request is sent to the remote API, use this getter to retrieve a value from the cache. can resolve a promise.
  • @params store.put(value, ...methodArgs) - called after the request completed, use this setter to store the value in cache. can resolve a promise.

@params tll (optional) - If the timestamp of the cached rates plus its time to live (ttl) in ms is higher than the current timestamp, the service will call the remote API, otherwise, it will take the value from the cache.
Defaults to 24 hours for latest and to Infinity for currencies and historical

If an error returned from the remote API, the service will fall back to the cached value if any, even if the cache has expired.

@returns - decorated service

var oxr = require('oxr')
var service = oxr.factory({
 appId: process.env.OXR_APP_ID || '<YOUR_APP_ID>'
})

service = oxr.cache({
 method: 'latest',
 ttl: 7 * 24 * 1000 * 3600,
 store: {
   get: function () {
     return Promise.resolve(this.value)
   },
   put: function (value) {
     this.value = value
     return Promise.resolve(this.value)
   }
 }
}, service)

You can decorate the service more than once, with different cache strategy for each method

service = oxr.cache({
  method: 'historical',
  store: {
    cache: {},
    get: function (date) {
      return this.cache[date];
    },
    put: function (value, date) {
      this.cache[date] = value;
    }
  }
}, service)


// note how the arguments that you pass to the decorated method
// are also passed to `get` and `put`
service.historical('2017-11-16')
  .then((value) => { ... })

Error Handling

If the remote service returns an error, Promises are rejected with an instance of OxrError.

var oxr = require('oxr')
var service = oxr.factory({
  appId: '<WRONG_APP_ID>'
})

service.latest().catch(function (error) {
  assert(error instanceof oxr.OxrError)
  assert.equal(error.status, 401)
  assert.equal(error.message, 'invalid_app_id')
  assert.equal(error.description, 'Invalid App ID provided - please sign up at https://openexchangerates.org/signup, or contact [email protected] Thanks!')
})

Contributing

js-standard-style

License

This module is distributed under the MIT license.

Copyright (C) 2014 Laurent Renard.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].