Free Swift Exchange Rate API

Welcome to the UniRate API Swift documentation. Our free exchange rate API lets you add real-time and historical currency conversion to any Swift application — iOS, macOS, tvOS, watchOS, or server-side Swift. Whether you're building a finance app, a travel tool, or a multi-currency checkout, the API is ready to drop in.

We ship an official Swift client library that uses modern async/await, is fully Sendable and Codable, and has zero external dependencies — just Foundation and Swift Package Manager.

With UniRate API, you get:

  • Real-time exchange rates for 170+ currencies (fiat + crypto)
  • Historical rates back to 1999 and time-series up to 5 years
  • VAT rates for countries worldwide
  • Free tier with no credit card required

The Swift library is designed to be:

  • Modern: async/await, Sendable, Codable
  • Zero external dependencies — pure Foundation
  • Swift 5.9+ compatible on macOS 12+, iOS 15+, tvOS 15+, watchOS 8+
  • Distributed via Swift Package Manager
  • Open source on GitHub

For full reference on endpoints, rate limits, and advanced options, see our main API documentation.

Below you'll find examples using the official UniRate Swift client library.

Getting Started with Swift

Install the official Swift client via Swift Package Manager. Add the package URL https://github.com/UniRate-API/unirate-api-swift.git in Xcode via File → Add Package Dependencies…, or add it to your Package.swift manually.


// Package.swift
// dependencies: [
//     .package(url: "https://github.com/UniRate-API/unirate-api-swift.git", from: "0.1.0")
// ]

import UniRateAPI

let client = UniRateClient(apiKey: "YOUR_API_KEY")

// Current rate
let rate = try await client.getRate(from: "USD", to: "EUR")
print("USD -> EUR: \(rate)")

// Convert an amount
let euros = try await client.convert(amount: 100, from: "USD", to: "EUR")
print("100 USD = \(euros) EUR")

// All rates for a base currency
let rates = try await client.getAllRates(from: "USD")

// Supported currencies
let currencies = try await client.getSupportedCurrencies()
print("\(currencies.count) currencies supported")

// Historical rate on a specific date
let historical = try await client.getHistoricalRate(
    date: "2024-01-01",
    from: "USD",
    to: "EUR"
)

// Time series (up to 5 years)
let series = try await client.getTimeSeries(
    startDate: "2024-01-01",
    endDate:   "2024-01-07",
    base:      "USD",
    currencies: ["EUR", "GBP"]
)

// VAT rate for a country (ISO-3166 alpha-2)
let germany = try await client.getVATRate(country: "DE")
print("Germany VAT: \(germany.vatData.vatRate)%")

Response Example


// Current rate
USD -> EUR: 0.9245

// Convert
100 USD = 92.45 EUR

// Supported currencies
593 currencies supported

// VAT
Germany VAT: 19.0%

Important Notes

  • Replace 'YOUR_API_KEY' with your actual API key from unirateapi.com
  • Install via SPM: https://github.com/UniRate-API/unirate-api-swift.git (from 0.1.0)
  • Requires Swift 5.9+ and macOS 12+/iOS 15+/tvOS 15+/watchOS 8+
  • All calls are async — run inside a Task or async context
  • Historical endpoints require a Pro API key; free keys get a 401/403
  • All errors throw as UniRateError — handle authentication, invalid currency, and rate-limit cases
  • Store your API key in Keychain or a secure environment variable, not in source

Not a Developer?

We offer paid implementation services to integrate our API into your application without you needing to write any code.

Contact Us for a Quote

Ready to Get Started?

Sign up now to get your API key and start converting currencies in your Swift applications.

Get Your API Key