Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.posadskiy:currency-converter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.posadskiy:currency-converter

Open Source library for converting currencies

  • 1.3.1
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Currency Converter

Java library receives current exchange rate

  • 165+ currencies
  • No dependencies

Supported sources

  • CurrencyConverterApi
  • CurrencyLayer
  • OpenExchangeRates
  • Fixer
  • CurrencyFreaks

Documentation

Download

Maven
<dependency>
  <groupId>com.posadskiy</groupId>
  <artifactId>currency-converter</artifactId>
  <version>1.3.1</version>
</dependency>
Gradle/Grails
compile 'com.posadskiy:currency-converter:1.3.1'
Scala SBT
libraryDependencies += "com.posadskiy" % "currency-converter" % "1.3.1"

How to init service

How to get API Key?

/**
 * Define your API keys
 * Use at least one key, but we recommend define three:
 * One or even two services can be off, but not three at the same time
*/
public static final String CURRENCY_CONVERTER_API_API_KEY = "YOUR API KEY FOR CurrencyConverterApi.Com";
public static final String CURRENCY_LAYER = "YOUR API KEY FOR CurrencyLayer.Com";
public static final String OPEN_EXCHANGE_RATES = "YOUR API KEY FOR OpenExchangeRates.Com";

// Init converter with your API key
CurrencyConverter converter = new CurrencyConverter(
    new ConfigBuilder()
        .currencyConverterApiApiKey(CURRENCY_CONVERTER_API_API_KEY)
        .currencyLayerApiKey(CURRENCY_LAYER)
        .openExchangeRatesApiKey(OPEN_EXCHANGE_RATES)
        .build()
);

Only one service using (recommended using at least two, it helps when one is unavailable)

public static final String OPEN_EXCHANGE_RATES = "YOUR API KEY FOR OpenExchangeRates.Com";

CurrencyConverter converter = new CurrencyConverter(
    new ConfigBuilder()
        .openExchangeRatesApiKey(OPEN_EXCHANGE_RATES)
        .build()
);

How it works

// Get rate with Currency Enum
Double gbrToChfRate = converter.rate(Currency.GBP, Currency.CHF);

// Get rate with half fixed method
Double usdToEuroRate = converter.rateFromUsd(Currency.EUR);

// Get rate with fixed method
Double usdToEuroRate = converter.rateFromUsdToEuro();

// Get rate with String parameters
Double usdToEuroRate = converter.rate("USD", "EUR");
ApiKey

Sign up on websites you are going to use:

and get key for use this services.

API key looks like symbolic string.

Android

The working process for Android is different from the usual Java application. Network requests from the main tread are prohibited for Android, so a possible way to call Currency Converter library is by creating AsyncTask wrapper. See Examples.

Also, it should be noted, Android application should have permissions to interaction with Network. Add to AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>

AsyncTask in Android

License

Currency Converter is available under the MIT license.

Powered by

Intellij IDEA

FAQs

Package last updated on 03 Mar 2023

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc