Code Examples
Official SDKs
Official CurrencyCore clients for TypeScript, Python, Dart, Kotlin, and Swift, with install commands, error handling, retries, and compatibility notes.
CurrencyCore publishes official typed clients for five ecosystems. They wrap the
same authenticated HTTP API, handle the base URL and API key, and return typed
responses. The API is plain GET, so an SDK is optional; every endpoint page
also shows raw cURL and fetch examples.
| SDK | Package | Platforms | Registry | Current line |
|---|---|---|---|---|
| TypeScript | @currencycore/sdk | Node, browser, React Native | npm | 0.1.x |
| Python | currencycore | CPython 3.x | PyPI | 0.1.x |
| Dart | currencycore | Dart, Flutter | pub.dev | 0.1.x |
| Kotlin / JVM | com.github.CurrencyCore:currencycore-kotlin | Android, JVM (usable from Java) | JitPack | 0.1.x |
| Swift | currencycore-swift | iOS, macOS | Swift Package Manager | 0.1.x |
These are the complete official set. There is no official Go, PHP, Ruby, .NET or separate Java SDK; the Kotlin/JVM client is usable from Java. Framework pages without an official client use raw HTTP, and the sample app patterns use the SDK where one exists.
Check the registry for the latest patch release before pinning a version. The package repositories are linked at the bottom of this page.
Install
npm install @currencycore/sdkpip install currencycore# pubspec.yaml
dependencies:
currencycore: ^0.1.0// build.gradle.kts, distributed via JitPack
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
dependencies {
implementation("com.github.CurrencyCore:currencycore-kotlin:0.1.0")
}// Package.swift, then add "CurrencyCoreSDK" to your target's dependencies
.package(url: "https://github.com/CurrencyCore/currencycore-swift.git", from: "0.1.0")Quick start
Convert 100 USD to EUR. Pass the key explicitly, or set
CURRENCYCORE_API_KEY and omit it.
import { createClient } from "@currencycore/sdk";
const api = createClient({ apiKey: "cc_live_..." });
const res = await api.convert({ from: "USD", to: "EUR", amount: 100 });
console.log(res.results[0]);from currencycore.client import create_client
api = create_client(api_key="cc_live_...")
res = api.convert(var_from="USD", to="EUR", amount=100)
print(res.results[0])The Python from parameter is spelled var_from because from is a reserved
word. The Kotlin client is usable from Java as well as Kotlin.
Public endpoints
/currencies and /countries need no key. Construct the client without one:
const api = createClient();
const currencies = await api.currencies();
Error handling
The API returns a consistent error envelope for every non-2xx response:
{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded...",
"details": {}
}
}
When a client exposes the response or an error object, read both the HTTP status
and the error.code value. Do not branch on the human-readable message; it can
change without notice.
| Status | What to do |
|---|---|
400, 404, 413, 422 | Fix the request. Retrying unchanged will return the same error. |
401 | Check the key and header format. See Authentication. |
402 | Billing is past due. An owner or admin must clear payment. |
403 | The key is valid but the plan, role, organization toggle, or history window blocks the request. Read the message. |
429 | Per-minute limit or monthly quota. Honor Retry-After when present. |
500, 502, 503 | Transient server or provider failure. Retry with exponential backoff and jitter. |
The exact codes are listed in Errors. Error codes are stable enough to branch on; messages are not.
Retries and timeouts
The SDKs make plain HTTP calls. If your client or wrapper retries automatically, keep these rules:
- Retry only on network errors,
429, and5xx. - Do not retry
400,401,402,403,404,413, or422. - Respect
Retry-Afteron429; otherwise use exponential backoff with jitter. - Use a request timeout and cap the total attempts. A short conversion normally returns quickly, while historical analysis can take longer.
- Make retries idempotent. All CurrencyCore data endpoints are
GET, so a retry does not create duplicate records.
If a 429 comes from the monthly quota rather than the per-minute limiter, there
may be no Retry-After; check the message and your dashboard usage. See
Rate Limits and Plan Quotas.
API key and environment
Every client resolves the key in the same order: the explicit argument first,
then CURRENCYCORE_API_KEY. See Authentication for key
types, rotation, and 401 troubleshooting.
Never ship a secret key in a browser bundle, mobile app, or anything you distribute. It is extractable. For browser and mobile clients, proxy through your backend or use a key you control at request time. Test keys are still credentials and should not be published.
API version and compatibility
For the data API, the CORS policy only reflects CurrencyCore-owned origins, plus localhost in development. It does not allow arbitrary customer websites, so a browser call from your own origin is blocked even when the key is valid. Use a backend proxy or server-side runtime. Browser and mobile SDK builds are for trusted first-party surfaces, not for shipping a secret in a distributed app.
The base URL is https://api.currency-core.com/{version}, default v1. The
version is a client option, so a future /v2 will not disturb an existing
integration.
createClient({ version: "v1" });
createClient({ baseUrl: "https://api.currency-core.com/v1" });
The same options exist as create_client(version=...) in Python,
createCurrencyCoreClient(version: ...) in Dart, CurrencyCore.client(version = ...) in Kotlin, and CurrencyCore.configure(version: ...) in Swift.
Each SDK is versioned independently from the API. A client 0.1.x release may
add endpoints or fields without changing the v1 HTTP contract. Read the
package changelog before a major upgrade, and pin a version in production.
Reference
- TypeScript: npm
@currencycore/sdk, GitHub - Python: PyPI
currencycore, GitHub - Dart / Flutter: pub.dev
currencycore, GitHub - Kotlin / Java: JitPack, GitHub
- Swift: Swift Package Manager, GitHub
If a package is unavailable for your runtime, use the raw HTTP examples. Need a language that is not covered? Email support.