Latest 1.1.3
License MIT
Platforms ios 8.0


YahooCurrencyApiWrapper is a easy API Wrapper from the Yahoo Currency API in order to retrieve data easily


A simple iOS Wrapper for the Yahoo Finance API that helping you :

  1. Getting currency rates from Yahoo Finance API between two currencies

  2. Getting currencies rates from multiples currencies regarding one base currency (for example EUR, GBP, AED from US Dollars in one single request)

  3. Gathering historical currencies rates from the past days (per default it’s USD).


I made that project as I really wanted to use currency conversion for a financial project, but I always found API for the stock exchange, but none of them on iOS was enough simple and useful only for currency purposes.


This library is compatible for iOS 8 + and written in Swift 3.0

Via CocoaPods :

Add the dependency in your podfile as below

pod 'YahooCurrencyApiWrapper'

Then, run the following command:

$ pod install

Code Samples

Currencies rates use case :

let base : String = "USD"
let other : String = "EUR"

YahooCurrencyApiWrapper.sharedInstance.getAllCurrencyFrom(base: base, other: other) { (rate : Double, time : String?, error : NSError?) in

guard error == nil else {

let errorCode : Int = (error?.code)!

switch errorCode
case ErrorType.currencyNotFound.rawValue :
print ("currency not found on the market")
case ErrorType.rateNotApplicable.rawValue :
print ("rate not applicable for the currency (other)")
default : return

//Everything is fine, we get the rate
print ("1 (base) = (rate) (other)")

You can have two kind of errors from the Yahoo API (Currency not existing or Rate not found),

All the others related to HTTP Response are handled as an classic NSError type.

public enum ErrorType : Int
case rateNotApplicable = 999,currencyNotFound

But this not enough, maybe you want to be able to get rates from different currencies regarding the same base currency !

In order to do that you have a specific method for it :

//create a list of currency as [String] 

let others : [String] = ["EUR","GBP","DZD","AED"]

//Then pass it with your base

YahooCurrencyApiWrapper.sharedInstance.getCurrenciesRates(base: base, others: others) { (exchanges : [Exchange]?, error : NSError?) in

guard error == nil else { return}

exchanges?.forEach {
let item : Exchange = $0
print("1 (item.from!) = (item.rate!) (!)")


It will return you a list of Exchanges object as below , if the currency rate is not available, it will return you a 0.0 value.

public class Exchange {

public var from : String?
public var to : String?
public var rate : Double?

Historitical rates use case :

YahooCurrencyApiWrapper.sharedInstance.getHistoricalCurrencies(currencyName: "GBP", days: 7) { (items : [HistoricalItem]?, error : NSError?) in

guard error == nil else { return}

items?.forEach {
let item : HistoricalItem = $0

print("open value for (currency) = (item.openValue!) the (")

This method return a list of item which describe for each day rate for the state (Open, Low, High, Close)

an Historical Item has this structure :

public struct HistoricalItem {

public var openValue : Double?
public var highValue : Double?
public var lowValue : Double?
public var closeValue : Double?
public var date : Date?


You can checkout the Example App inside the Example folder to use it.

More wille come, but for the basis feature, here we are.

What’s next ?

  1. Provide a way to convert currency directly
  2. Adding cache management


The license used is under MIT.


Mohamed ARRADI-ALAOUI – [email protected]

If you are using this library and you think some specific tools can be implemented please feel free to let me know

Latest podspec

    "name": "YahooCurrencyApiWrapper",
    "version": "1.1.3",
    "summary": "YahooCurrencyApiWrapper is a easy API Wrapper from the Yahoo Currency API. Help to retrieve data easily",
    "description": "This pods will help you to use the YahooCurrencyApi without bothering you about how we manage the API Call. nJust request and get the result.nnThis Cocoa Pods give you : nnt* Currency rates from Yahoo Currency APInt* A historical rates for a currency from the past days (the base comparaison is US Dollars)",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "MOHAMED ARRADI-ALAOUI": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.1.3"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "source_files": "YahooCurrencyApiWrapper/Classes/**/*",
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This