currency_sdk library

Currency SDK - Offline-first currency conversion with 160+ currencies

A production-ready Flutter/Dart SDK for real-time currency conversion powered by Cloudflare Workers edge computing.

Features

  • 🌍 160+ currencies updated every 2 hours
  • 📱 Offline-first with Hive caching
  • ⚡ Edge-powered by Cloudflare Workers
  • 🔒 Secure API key authentication
  • 💰 Free tier with 10,000 requests/month

Quick Start

import 'package:currency_sdk/currency_sdk.dart';

void main() async {
  // Free tier - no API key needed
  final client = CurrencyClient();
  await client.initialize();

  // Get exchange rates
  final rates = await client.getRates('USD');
  print(rates.convert(100, 'EUR')); // Convert 100 USD to EUR

  // Convert directly
  final amount = await client.convert(
    amount: 100,
    from: 'USD',
    to: 'EUR',
  );
  print('100 USD = $amount EUR');
}

Offline Support

The SDK automatically caches exchange rates locally. When offline:

  • Returns cached data immediately
  • No network calls = instant response
  • Data stays fresh for 2 hours

For higher limits and priority support:

final client = CurrencyClient(apiKey: 'your_api_key');

Get your API key at: https://dashboard.currency-sdk.com

Enterprise

Custom Cloudflare Workers for large teams:

final client = CurrencyClient.enterprise(
  apiKey: 'ent_abc123',
  workerUrl: 'https://your-company.workers.dev',
);

Classes

CurrencyClient
Main client for accessing currency conversion rates
CurrencyData

Exceptions / Errors

CurrencySDKException
Base exception class for all SDK errors
InvalidApiKeyException
Thrown when API key is invalid or missing
NetworkException
Thrown when network request fails
NoCachedDataException
Thrown when no cached data is available and device is offline
RateLimitExceededException
Thrown when rate limit is exceeded
SDKNotInitializedException
Thrown when SDK is used before initialization
UnsupportedCurrencyException
Thrown when requested currency is not supported