### Quick start: initialize client, get latest rates, convert
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/python/README.md
Initialize the AllRatesToday client with your API key, fetch latest rates, and convert an amount.
```python
from allratestoday import AllRatesToday
# Set your API key
client = AllRatesToday(api_key="YOUR_API_KEY")
# Get latest exchange rates
data = client.latest(base="USD", symbols=["EUR", "GBP", "JPY"])
print(data["rates"]) # {"EUR": 0.9234, "GBP": 0.7891, "JPY": 151.42}
# Convert an amount
result = client.convert("USD", "EUR", 1000)
print(f"$1,000 = €{result['result']}")
```
--------------------------------
### ECB npm SDK Installation and Quick Start
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Install and use the ecb-exchange-rate npm package for the European Central Bank. Fetches a single currency pair or the full published rate table.
```javascript
npm install ecb-exchange-rate
import { getRate, getLatestRates } from 'ecb-exchange-rate';
// One pair at the official ECB rate
const pair = await getRate('USD', 'EUR', { apiKey: 'art_live_...' });
console.log(pair.rate, pair.rate_date);
// The bank's full published table
const table = await getLatestRates({ apiKey: 'art_live_...' });
console.log(table.rate_date, table.rates.length);
```
--------------------------------
### Install PHP SDK
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/README.md
Install the official PHP SDK for AllRatesToday.
```bash
composer require allratestoday/sdk
```
--------------------------------
### Install Python SDK
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/README.md
Install the official Python SDK for AllRatesToday.
```bash
pip install allratestoday
```
--------------------------------
### Quick Start: Initialize client and get latest rates
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Import the SDK, create a client with your API key, and fetch the latest exchange rates for USD to EUR, GBP, and JPY. The response is logged to the console.
```typescript
import AllRatesToday from '@allratestoday/sdk';
// Set your API key
const client = new AllRatesToday({ apiKey: 'YOUR_API_KEY' });
// Get latest exchange rates
const { rates } = await client.latest({ base: 'USD', symbols: ['EUR', 'GBP', 'JPY'] });
console.log(rates);
```
--------------------------------
### Quick Start: Get rate, convert, and historical rates
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/php/README.md
Initialize the client with your API key and demonstrate getRate, convert, and getHistoricalRates methods. Requires a free API key from allratestoday.com/register.
```php
use AllRatesToday\AllRatesToday;
$client = new AllRatesToday('art_live_your_key_here');
// Get exchange rate
$rate = $client->getRate('USD', 'EUR');
echo "1 USD = {$rate[0]['rate']} EUR\n";
// Convert amount
$result = $client->convert('USD', 'EUR', 100);
echo "\$100 = €{$result['result']}\n";
// Get historical rates
$history = $client->getHistoricalRates('USD', 'EUR', '30d');
foreach ($history['rates'] as $point) {
echo "{$point['time']}: {$point['rate']}\n";
}
```
--------------------------------
### Fetch exchange rates with curl
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/README.md
Quick start example for fetching exchange rates without an SDK. Requires a free API key from allratestoday.com/register, which is passed in the Authorization header.
```bash
curl "https://allratestoday.com/api/v1/rates?source=USD&target=EUR" \
-H "Authorization: Bearer YOUR_API_KEY"
```
--------------------------------
### Install @allratestoday/sdk with yarn
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Install the SDK using Yarn, an alternative package manager.
```bash
yarn add @allratestoday/sdk
```
--------------------------------
### Install @allratestoday/sdk with pnpm
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Install the SDK using pnpm, a fast and disk-space-efficient package manager.
```bash
pnpm add @allratestoday/sdk
```
--------------------------------
### PHP SDK Quick Start
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Quick start for the allratestoday PHP SDK. Create a client with your API key, fetch latest rates, and convert an amount between currencies.
```php
latest(['base' => 'USD']);
echo $rates->EUR; // 0.9234
// Convert currency
$result = $client->convert([
'from' => 'USD',
'to' => 'EUR',
'amount' => 1000
]);
echo $result->converted; // 923.40
```
--------------------------------
### Get Available Currencies - cURL Example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example request to retrieve the list of available currencies. The endpoint is cached for 24 hours and does not require authentication.
```bash
curl "https://allratestoday.com/api/v1/symbols"
```
--------------------------------
### Install @allratestoday/central-bank via npm
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript-central-bank/README.md
Install the package using npm. This is the standard installation command for the central-bank SDK.
```bash
npm install @allratestoday/central-bank
```
--------------------------------
### Install @allratestoday/sdk with npm
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Install the SDK using npm. This is the standard package manager for Node.js projects.
```bash
npm install @allratestoday/sdk
```
--------------------------------
### Install React Currency Localizer
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/README.md
Install the React package for localized pricing and currency conversion.
```bash
npm install react-currency-localizer-realtime
```
--------------------------------
### Python SDK Quick Start
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Quick start for the allratestoday Python SDK. Create a client with your API key, then fetch latest rates, historical rates for a specific date, and list available currencies.
```python
from allratestoday import AllRatesToday
client = AllRatesToday('art_live_your_api_key')
# Get latest rates
rates = client.latest(base='USD')
print(rates['EUR']) # 0.9234
# Get historical rates
history = client.historical(base='USD', date='2025-01-15')
print(history['EUR']) # 0.9180
# List available currencies
currencies = client.currencies()
print(len(currencies)) # 160+
```
--------------------------------
### Rust SDK Quick Start
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Quick start for the allratestoday Rust SDK. Create a client with your API key, fetch latest rates for specific currencies, and convert an amount.
```rust
use allratestoday::AllRatesToday;
fn main() {
let client = AllRatesToday::new("art_live_your_api_key");
// Get latest rates
let rates = client.latest("USD", Some(&["EUR", "GBP"])).unwrap();
println!("{:?}", rates);
// Convert currency
let result = client.convert("USD", "EUR", 100.0).unwrap();
println!("100 USD = {:?} EUR", result.result);
}
```
--------------------------------
### Get Available Currencies - Response Example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example response for the GET /api/v1/symbols endpoint. Shows the JSON structure with a currencies array and a count field. The response is cached for 24 hours (Cache-Control: public, max-age=86400).
```http
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: public, max-age=86400
{
"currencies": [
{ "code": "AED", "name": "UAE Dirham", "symbol": "AED" },
{ "code": "AUD", "name": "Australian Dollar", "symbol": "A$" },
{ "code": "BDT", "name": "Bangladeshi Taka", "symbol": "Tk" },
{ "code": "BRL", "name": "Brazilian Real", "symbol": "R$" },
{ "code": "CAD", "name": "Canadian Dollar", "symbol": "CA$" },
{ "code": "EUR", "name": "Euro", "symbol": "€" },
{ "code": "GBP", "name": "British Pound", "symbol": "£" },
{ "code": "INR", "name": "Indian Rupee", "symbol": "n" },
{ "code": "JPY", "name": "Japanese Yen", "symbol": "¥" },
{ "code": "USD", "name": "US Dollar", "symbol": "$" },
...
],
"count": 160
}
```
--------------------------------
### Available Currencies: response example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Example JSON response from the symbols() method, showing a subset of the 160+ supported currencies.
```javascript
{
symbols: {
AED: 'United Arab Emirates Dirham',
AFN: 'Afghan Afghani',
ALL: 'Albanian Lek',
AMD: 'Armenian Dram',
AUD: 'Australian Dollar',
BDT: 'Bangladeshi Taka',
BRL: 'Brazilian Real',
CAD: 'Canadian Dollar',
CHF: 'Swiss Franc',
CNY: 'Chinese Yuan',
EUR: 'Euro',
GBP: 'British Pound Sterling',
INR: 'Indian Rupee',
JPY: 'Japanese Yen',
KRW: 'South Korean Won',
USD: 'United States Dollar',
// ...160+ currencies
}
}
```
--------------------------------
### JavaScript/TypeScript SDK Quick Start
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Shows how to import the SDK, create a client, and use methods for latest rates, currency conversion, and historical rates.
```javascript
import { AllRatesToday } from '@allratestoday/sdk';
const client = new AllRatesToday('art_live_your_api_key');
// Get latest rate
const rates = await client.latest({ base: 'USD', symbols: ['EUR', 'GBP'] });
console.log(rates.EUR); // 0.9234
// Convert currency
const result = await client.convert({
from: 'USD',
to: 'EUR',
amount: 1000
});
console.log(result.converted); // 923.40
// Get historical rates
const history = await client.historical({
base: 'USD',
date: '2025-01-15'
});
console.log(history.EUR); // 0.9180
```
--------------------------------
### timeSeries(start, end, options?)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Get rates across a custom date range.
```APIDOC
## timeSeries(start, end, options?)
### Description
Get rates across a custom date range.
### Method
timeSeries
### Parameters
- **start** (string) - Required - The start date.
- **end** (string) - Required - The end date.
- **options** (object) - Optional - Options for the request.
### Response
Returns the exchange rates for the date range.
```
--------------------------------
### Get Publication Calendar - curl example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example curl request to get the publication calendar for the Central Bank of Sri Lanka (cbsl) for the year 2026.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/v1/central-bank/cbsl/availability?year=2026"
```
--------------------------------
### Get Central Bank Rate Time Series - curl example (USD/CAD)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example curl request for a USD/CAD series from the Bank of Canada (boc) over a date range.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/v1/central-bank/boc/history?source=USD&target=CAD&from=2026-01-01&to=2026-06-30"
```
--------------------------------
### Latest Exchange Rates: response example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Example JSON response from the latest() method, showing base currency, date, and rates for CHF, GBP, and JPY.
```javascript
{
base: 'USD',
date: '2026-04-09T14:30:00Z',
rates: {
CHF: 0.8821,
GBP: 0.7891,
JPY: 151.42
}
}
```
--------------------------------
### Get Official Rates for a Date - curl example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example curl request to retrieve official rates for the ECB on 2026-06-30 with source and target parameters.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/v1/central-bank/ecb/2026-06-30?source=USD&target=EUR"
```
--------------------------------
### Provide API key to useCurrencyConverter to fix 'API key is missing' error
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/react/README.md
Pass a non-empty API key via the apiKey option. Get a free key at allratestoday.com/register. The example uses import.meta.env.VITE_ALLRATESTODAY_KEY to supply the key.
```tsx
// Provide your API key (get one free at allratestoday.com/register)
useCurrencyConverter({
basePrice: 99.99,
baseCurrency: 'USD',
apiKey: import.meta.env.VITE_ALLRATESTODAY_KEY, // Not empty string
})
```
--------------------------------
### Install allratestoday-central-bank via pip
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/python-central-bank/README.md
Installs the allratestoday-central-bank package from PyPI. The package has zero dependencies and supports Python versions indicated by the PyPI version badges.
```bash
pip install allratestoday-central-bank
```
--------------------------------
### Time Series Data: response example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Example JSON response from the timeSeries() method, showing rates for EUR and GBP on multiple dates.
```javascript
{
base: 'USD',
startDate: '2026-01-01',
endDate: '2026-03-31',
rates: {
'2026-01-01': {
EUR: 0.9187,
GBP: 0.7834
},
'2026-01-02': {
EUR: 0.9195,
GBP: 0.7841
},
'2026-01-03': {
EUR: 0.9201,
GBP: 0.7856
},
// ...
}
}
```
--------------------------------
### Install react-currency-localizer-realtime
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/react/README.md
Install the package using npm, yarn, or pnpm. React 17+ is a peer dependency; no other dependencies are required.
```bash
# npm
npm install react-currency-localizer-realtime
# yarn
yarn add react-currency-localizer-realtime
# pnpm
pnpm add react-currency-localizer-realtime
```
--------------------------------
### Single Rate: response example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Example JSON response from the getRate() method, showing the rate and source.
```javascript
{
from: { currency: 'USD', amount: 1 },
to: { currency: 'EUR', amount: 0.9234 },
rate: 0.9234,
source: 'wise'
}
```
--------------------------------
### React SDK Quick Start
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Quick start for the React SDK using the useCurrencyLocalizer hook. Automatically detects user currency via IP, caches rates, and is SSR compatible with Next.js and Remix.
```jsx
import { useCurrencyLocalizer } from
'react-currency-localizer-realtime';
function PricingCard({ priceUSD }) {
const { convert, userCurrency, loading }
= useCurrencyLocalizer({
apiKey: 'art_live_your_api_key',
baseCurrency: 'USD'
});
if (loading) return ;
return (
{convert(priceUSD)} {userCurrency}
);
}
```
--------------------------------
### Historical Exchange Rates: response example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Example JSON response from the forDate() method, showing base, date, and rates for EUR.
```javascript
{
base: 'USD',
date: '2026-01-15',
rates: {
EUR: 0.9187
}
}
```
--------------------------------
### Fetch latest published rate from ECB
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript-central-bank/README.md
Import CentralBankRates, create an instance, and call latest() to get the published rate for a currency pair. No API key is required. The example logs the rate and its publication date.
```typescript
import { CentralBankRates } from '@allratestoday/central-bank';
const cb = new CentralBankRates(); // no API key needed
const pair = await cb.latest('ecb', { source: 'USD', target: 'EUR' });
console.log(pair.rate, 'published', pair.rate_date);
// 0.8588851671 published 2026-08-28
```
--------------------------------
### Get Single Pair from Central Bank of Sri Lanka - cURL Example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Gets a single pair from the Central Bank of Sri Lanka (cbsl). Pass source and target together for a single-pair lookup. When the pair is not directly published by the bank, the rate is cross-computed via the bank's home currency and flagged with derived: true. Available on all plans.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/v1/central-bank/cbsl/latest?source=USD&target=LKR"
```
--------------------------------
### curl Example - 30-day History
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example curl request for 30-day historical rates. Uses the Authorization header with a live API key.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/historical-rates?source=EUR&target=LKR&period=30d"
```
--------------------------------
### Run tests with pytest
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/python/README.md
Install pytest and pytest-cov, then run the test suite verbosely.
```bash
pip install pytest pytest-cov
pytest tests/ -v
```
--------------------------------
### CommonJS require and latest rates example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Shows how to use the SDK in CommonJS environments. Creates a client with an API key and fetches the latest exchange rates.
```javascript
const AllRatesToday = require('@allratestoday/sdk').default;
const client = new AllRatesToday({ apiKey: 'YOUR_API_KEY' });
client.latest().then(data => console.log(data.rates));
```
--------------------------------
### Official Central-Bank Rates (TypeScript)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Use officialRates() to get official rates published by central banks and tax authorities. No API key is needed for the latest table. The example shows fetching the full ECB reference table, a single cross-computed pair, and listing available sources with staleness status. Always cite the returned rate_date as it is the institution's publication date.
```typescript
const client = new AllRatesToday(); // no key
// Full ECB reference table
const table = await client.officialRates('ecb');
console.log(table.rate_date, table.rates); // [{ base: 'EUR', quote: 'USD', type: 'reference', value: 1.17 }, …]
// One pair (cross-computed inside the bank's own table if not published directly → `derived: true`)
const usd = await client.officialRates('ecb', { source: 'EUR', target: 'USD' });
console.log(`ECB ${usd.rate_date}: 1 EUR = ${usd.rate} USD`);
// Which sources exist, and which are behind their publication schedule
const { sources } = await client.officialSources();
console.log(sources.map((s) => `${s.code} ${s.latest}${s.stale ? ' (stale)' : ''}`));
```
--------------------------------
### GET /api/v1/symbols
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/README.md
Lists all supported currencies.
```APIDOC
## GET /api/v1/symbols
### Description
Lists all supported currencies.
### Method
GET
### Endpoint
/api/v1/symbols
### Parameters
None
### Response
#### Success Response (200)
- List of supported currency codes
#### Error Responses
- **400** - Bad request — missing or invalid parameters
- **500** - Internal server error
- **503** - Service temporarily unavailable
```
--------------------------------
### latest(options?)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Get latest rates for one or more currencies.
```APIDOC
## latest(options?)
### Description
Get latest rates for one or more currencies.
### Method
latest
### Parameters
- **options** (object) - Optional - Options for the request.
### Response
Returns the latest exchange rates.
```
--------------------------------
### useCurrencyLocalizer(options)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/react/README.md
Documentation for the useCurrencyLocalizer hook, including parameters, return values, and an example.
```APIDOC
## useCurrencyLocalizer(options)
### Description
Batch-friendly hook for converting multiple prices efficiently. Ideal for e-commerce product listings where you need to convert many prices with one exchange rate lookup.
### Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `baseCurrency` | `string` | Yes | ISO 4217 currency code |
| `apiKey` | `string` | Yes | Your AllRatesToday API key |
| `manualCurrency` | `string` | No | Override detected currency |
| `geoEndpoint` | `string` | No | Custom geolocation endpoint URL |
| `onReady` | `function` | No | Callback when converter is ready |
| `onError` | `function` | No | Callback on error |
### Returns
| Property | Type | Description |
|----------|------|-------------|
| `convert` | `(price: number) => number \| null` | Convert a price |
| `format` | `(price: number) => string` | Format a price with currency symbol |
| `convertAndFormat` | `(price: number) => string` | Convert and format in one call |
| `localCurrency` | `string \| null` | Detected currency code |
| `baseCurrency` | `string` | Original currency code |
| `exchangeRate` | `number \| null` | Exchange rate used |
| `isLoading` | `boolean` | Loading state |
| `isReady` | `boolean` | True when ready to convert |
| `error` | `Error \| null` | Error object if any |
### Example
```tsx
import { useCurrencyLocalizer } from 'react-currency-localizer-realtime'
function ProductList({ products }) {
const { convertAndFormat, isReady } = useCurrencyLocalizer({
baseCurrency: 'USD',
apiKey: process.env.REACT_APP_ALLRATESTODAY_KEY,
})
return (
{products.map(p => (
-
{p.name}: {isReady ? convertAndFormat(p.price) : '...'}
))}
)
}
```
```
--------------------------------
### Use AllRatesToday Python SDK
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/README.md
Use the Python SDK to get a rate, convert an amount, and fetch historical rates. The API key enables higher limits and historical data.
```python
from allratestoday import AllRatesToday
client = AllRatesToday()
rate = client.get_rate("USD", "EUR")
print(f"1 USD = {rate['rate']} EUR")
# Convert amount
result = client.convert("USD", "EUR", 100)
print(f"$100 = €{result['result']}")
# With API key for higher limits & historical data
auth = AllRatesToday(api_key="art_live_...")
history = auth.get_historical_rates("USD", "EUR", "30d")
```
--------------------------------
### useCurrencyLocalizer example: ProductList component
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/react/README.md
Example usage of the useCurrencyLocalizer hook to convert and format prices in a product list. Uses the convertAndFormat function and isReady flag to handle loading state.
```tsx
import { useCurrencyLocalizer } from 'react-currency-localizer-realtime'
function ProductList({ products }) {
const { convertAndFormat, isReady } = useCurrencyLocalizer({
baseCurrency: 'USD',
apiKey: process.env.REACT_APP_ALLRATESTODAY_KEY,
})
return (
{products.map(p => (
-
{p.name}: {isReady ? convertAndFormat(p.price) : '...'}
))}
)
}
```
--------------------------------
### Use AllRatesToday PHP SDK
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/README.md
Use the PHP SDK to get a rate, convert an amount, and fetch historical rates. The API key enables higher limits and historical data.
```php
use AllRatesToday\AllRatesToday;
$client = new AllRatesToday();
$rate = $client->getRate('USD', 'EUR');
echo "1 USD = {$rate['rate']} EUR";
// Convert amount
$result = $client->convert('USD', 'EUR', 100);
echo "$100 = €{$result['result']}";
// With API key for higher limits & historical data
$auth = new AllRatesToday('art_live_...');
$history = $auth->getHistoricalRates('USD', 'EUR', '30d');
```
--------------------------------
### Currency Conversion: current conversion response
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Example JSON response from the convert() method for a current conversion.
```javascript
{
from: 'USD',
to: 'EUR',
amount: 1000,
result: 923.4,
rate: 0.9234
}
```
--------------------------------
### Use AllRatesToday JavaScript/TypeScript SDK
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/README.md
Use the JavaScript/TypeScript SDK to get a rate, convert an amount, and fetch historical rates. The API key enables higher limits and historical data.
```typescript
import AllRatesToday from '@allratestoday/sdk';
const client = new AllRatesToday();
const rate = await client.getRate('USD', 'EUR');
console.log(`1 USD = ${rate.rate} EUR`);
// Convert amount
const result = await client.convert('USD', 'EUR', 100);
console.log(`$100 = €${result.result}`);
// With API key for higher limits & historical data
const auth = new AllRatesToday({ apiKey: 'art_live_...' });
const history = await auth.getHistoricalRates('USD', 'EUR', '30d');
```
--------------------------------
### forDate(date, options?)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Get rates for a specific historical date.
```APIDOC
## forDate(date, options?)
### Description
Get rates for a specific historical date.
### Method
forDate
### Parameters
- **date** (string) - Required - The historical date.
- **options** (object) - Optional - Options for the request.
### Response
Returns the exchange rates for the specified date.
```
--------------------------------
### latest(base, symbols, api_key)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/python/README.md
Get latest rates for one or more currencies.
```APIDOC
## latest(base, symbols, api_key)
### Description
Get latest rates for one or more currencies.
### Method
latest
### Parameters
- **base** (string) - Required - The base currency code.
- **symbols** (string or list) - Optional - Comma-separated list of currency codes to return rates for.
- **api_key** (string) - Required - Your API key.
### Returns
Latest exchange rates for the specified currencies.
```
--------------------------------
### Subscription Pricing Table with formatPrice
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/react/README.md
Displays a subscription pricing table with a custom formatPrice function that appends '/month' to the localized price. Uses the same apiKey environment variable as the product grid example.
```tsx
function PricingTable() {
const plans = [
{ name: 'Basic', price: 9.99 },
{ name: 'Pro', price: 19.99 },
{ name: 'Enterprise', price: 49.99 },
]
return (
{plans.map(plan => (
{plan.name}
`${currency} ${price.toFixed(2)}/month`
}
/>
))}
)
}
```
--------------------------------
### getRates(source, target, options?)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Get rates with full metadata.
```APIDOC
## getRates(source, target, options?)
### Description
Get rates with full metadata.
### Method
getRates
### Parameters
- **source** (string) - Required - The source currency code.
- **target** (string) - Required - The target currency code.
- **options** (object) - Optional - Options for the request.
### Response
Returns rates with full metadata.
```
--------------------------------
### getRate(from, to, amount?, options?)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Get a single exchange rate.
```APIDOC
## getRate(from, to, amount?, options?)
### Description
Get a single exchange rate.
### Method
getRate
### Parameters
- **from** (string) - Required - The source currency code.
- **to** (string) - Required - The target currency code.
- **amount** (number) - Optional - The amount to convert.
- **options** (object) - Optional - Options for the request.
### Response
Returns a single exchange rate.
```
--------------------------------
### Historical Rates by Period (TypeScript)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Fetch historical exchange rates using preset periods like '30d' without manual date calculations. The example retrieves USD to EUR rates for the last 30 days.
```typescript
const history = await client.getHistoricalRates('USD', 'EUR', '30d');
console.log(history);
```
--------------------------------
### get_rate(from, to, amount, api_key)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/python/README.md
Get a single exchange rate.
```APIDOC
## get_rate(from, to, amount, api_key)
### Description
Get a single exchange rate.
### Method
get_rate
### Parameters
- **from** (string) - Required - The source currency code.
- **to** (string) - Required - The target currency code.
- **amount** (number) - Optional - The amount to convert (defaults to 1).
- **api_key** (string) - Required - Your API key.
### Returns
Exchange rate for the specified currency pair.
```
--------------------------------
### getRates($source, $target)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/php/README.md
Get rate data with metadata for a currency pair.
```APIDOC
## getRates($source, $target)
### Description
Get rate data with metadata.
### Parameters
- **$source** (string) - Required - Source currency code.
- **$target** (string) - Required - Target currency code.
### Response
Returns rate data with metadata.
```
--------------------------------
### Handle AllRatesTodayError with status
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/python/README.md
Demonstrates error handling with AllRatesTodayError. The exception includes an optional status attribute; for example, a 404 status indicates a currency code not found.
```python
from allratestoday import AllRatesToday, AllRatesTodayError
client = AllRatesToday(api_key="YOUR_API_KEY")
try:
rate = client.get_rate("USD", "INVALID")
except AllRatesTodayError as e:
print(e) # "Currency not found"
print(e.status) # 404
```
--------------------------------
### List Covered Central Banks - cURL Example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Lists all covered central banks. Requires Bearer token authentication. Returns metadata for every covered central bank: bank code, name, country, home currency, latest rate date, and endpoint URLs.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/v1/central-banks"
```
--------------------------------
### time_series(start, end, base, symbols, api_key)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/python/README.md
Get rates across a custom date range.
```APIDOC
## time_series(start, end, base, symbols, api_key)
### Description
Get rates across a custom date range.
### Method
time_series
### Parameters
- **start** (string) - Required - Start date (YYYY-MM-DD).
- **end** (string) - Required - End date (YYYY-MM-DD).
- **base** (string) - Required - The base currency code.
- **symbols** (string or list) - Optional - Comma-separated list of currency codes to return rates for.
- **api_key** (string) - Required - Your API key.
### Returns
Exchange rates for each day in the date range.
```
--------------------------------
### Currency Conversion: historical conversion response
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Example JSON response from the convert() method for a historical conversion, including the date.
```javascript
{
from: 'USD',
to: 'EUR',
amount: 1000,
result: 918.7,
rate: 0.9187,
date: '2026-01-15'
}
```
--------------------------------
### Historical Rates Response (JavaScript)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Example response object from getHistoricalRates, showing the structure with source, target, period, current rate, and an array of historical rates.
```javascript
{
source: 'USD',
target: 'EUR',
period: '30d',
current: { rate: 0.9234, time: '2026-04-09T14:30:00Z' },
rates: [
{ rate: 0.9198, time: '2026-03-10T00:00:00Z' },
{ rate: 0.9210, time: '2026-03-11T00:00:00Z' },
// ...
]
}
```
--------------------------------
### TypeScript import with all exported types
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Imports the AllRatesToday SDK and all its exported interfaces and types. Use this to get full type definitions in TypeScript projects.
```typescript
import AllRatesToday, {
AllRatesTodayError,
AllRatesTodayOptions,
RequestOptions,
RateResponse,
AuthRateResponse,
LatestOptions,
LatestResponse,
ForDateOptions,
ForDateResponse,
ConvertOptions,
ConvertResponse,
TimeSeriesOptions,
TimeSeriesResponse,
HistoricalRateResponse,
SymbolsResponse,
} from '@allratestoday/sdk';
```
--------------------------------
### Get Latest Official Central Bank Rates - cURL Example
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Gets the latest official central bank rates for the European Central Bank (ECB). Requires Bearer token authentication. Returns the most recent full rate table as published by the central bank.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/v1/central-bank/ecb/latest"
```
--------------------------------
### Response - 30-day History
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example JSON response for the 30-day historical rates endpoint. Shows the structure with source, target, data array, source_api, and period.
```http
HTTP/1.1 200 OK
Content-Type: application/json
{
"source": "EUR",
"target": "LKR",
"data": [
{
"date": "2026-03-13T00:00:00.000Z",
"rate": 358.4521,
"timestamp": 1710288000000
},
{
"date": "2026-03-14T00:00:00.000Z",
"rate": 360.1214,
"timestamp": 1710374400000
},
...
],
"source_api": "wise",
"period": "30d"
}
```
--------------------------------
### Single Rate: with amount
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Get a single rate with a specified amount, then log the converted amount using template literals.
```typescript
// With amount
const rate = await client.getRate('USD', 'EUR', 500);
console.log(`$500 = €${rate.to.amount}`);
```
--------------------------------
### Set environment variables for Vite, Create React App, and Next.js
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/react/README.md
Define the API key for each framework. Use VITE_ALLRATESTODAY_KEY for Vite, REACT_APP_ALLRATESTODAY_KEY for Create React App, and NEXT_PUBLIC_ALLRATESTODAY_KEY for Next.js.
```bash
# Vite
VITE_ALLRATESTODAY_KEY=your_api_key_here
# Create React App
REACT_APP_ALLRATESTODAY_KEY=your_api_key_here
# Next.js
NEXT_PUBLIC_ALLRATESTODAY_KEY=your_api_key_here
```
--------------------------------
### Response - Custom Date Range
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example JSON response for the custom date range endpoint. Shows an array of rate objects.
```http
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"rate": 1.3421,
"source": "USD",
"target": "CAD",
"time": "2026-01-01T00:00:00Z"
},
{
"rate": 1.3456,
"source": "USD",
"target": "CAD",
"time": "2026-01-02T00:00:00Z"
},
...
]
```
--------------------------------
### Available Currencies: list all symbols
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Call client.symbols() to get a list of all supported currency symbols and names. The response includes a symbols object with currency codes as keys.
```typescript
const data = await client.symbols();
console.log(data);
```
--------------------------------
### Run tests in watch mode
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Starts the test runner in watch mode for development, automatically re-running tests on file changes.
```bash
npm run test:watch
```
--------------------------------
### GET /table
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Retrieves a table of exchange rates for multiple currencies. The response can be in JSON, CSV, XML, or XLSX format. Each currency pair counts as one request toward the monthly limit.
```APIDOC
## GET /table
### Description
Retrieves a table of exchange rates for multiple currencies. The response can be in JSON, CSV, XML, or XLSX format. Each currency pair counts as one request toward the monthly limit.
### Method
GET
### Endpoint
/table
### Parameters
#### Query Parameters
- **source** (string) - Required - The base currency code (e.g., USD).
- **targets** (string) - Required - Comma-separated list of target currency codes (e.g., EUR,GBP,JPY).
- **format** (string) - Optional - Response format: json, csv, xml, xlsx. Default is json.
### Request Example
GET /table?source=USD&targets=EUR,GBP,JPY
### Response
#### Success Response (200)
- **rates** (object) - An object mapping each target currency to its rate.
- **source** (string) - The base currency code.
- **time** (string) - ISO 8601 timestamp of the rates.
#### Response Example
{
"rates": {
"EUR": 0.9234,
"GBP": 0.7891,
"JPY": 151.23
},
"source": "USD",
"time": "2026-04-12T14:30:00Z"
}
```
--------------------------------
### Multiple Target Currencies Request - curl
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example request for multiple target currencies (EUR, GBP, JPY, CAD) using the authenticated /api/v1/rates endpoint. Requesting 4 target currencies counts as 4 API requests toward your monthly limit.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/v1/rates?source=USD&target=EUR,GBP,JPY,CAD"
```
--------------------------------
### Single Target Currency Request - curl
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example request for a single target currency (EUR) using the authenticated /api/v1/rates endpoint. Requires an API key in the Authorization header.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/v1/rates?source=USD&target=EUR"
```
--------------------------------
### GET /latest
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Retrieves the latest exchange rate for a currency pair. The response includes the rate, source currency, target currency, and timestamp in ISO 8601 format.
```APIDOC
## GET /latest
### Description
Returns the latest exchange rate for a currency pair. The response includes the rate, source currency, target currency, and timestamp in ISO 8601 format.
### Method
GET
### Endpoint
/latest
### Parameters
#### Query Parameters
- **source** (string) - Required - The source currency code (e.g., USD).
- **target** (string) - Required - The target currency code (e.g., EUR).
- **format** (string) - Optional - Response format: json, csv, xml, xlsx. Default is json.
### Request Example
GET /latest?source=USD&target=EUR
### Response
#### Success Response (200)
- **rate** (number) - The exchange rate.
- **source** (string) - The source currency code.
- **target** (string) - The target currency code.
- **time** (string) - ISO 8601 timestamp of the rate.
#### Response Example
{
"rate": 0.9234,
"source": "USD",
"target": "EUR",
"time": "2026-04-12T14:30:00Z"
}
```
--------------------------------
### Historical Exchange Rates: using string date and Date object
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Fetch rates for a specific date using either a string or a Date object. The example shows both approaches with different base and symbols.
```typescript
// Using a string date
const data = await client.forDate('2026-01-15', { base: 'USD', symbols: ['EUR'] });
console.log(data);
// Using a Date object
const data = await client.forDate(new Date('2026-01-15'), { base: 'EUR', symbols: ['USD', 'GBP'] });
console.log(data);
```
--------------------------------
### Configure AllRatesToday client
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/python/README.md
Creates an AllRatesToday client with required api_key and optional base_url and timeout parameters. The default base_url is https://allratestoday.com and the default timeout is 10 seconds.
```python
client = AllRatesToday(
api_key="YOUR_API_KEY", # Required
base_url="https://allratestoday.com", # Optional
timeout=10, # Optional (seconds)
)
```
--------------------------------
### new AllRatesToday($apiKey, $baseUrl, $timeout)
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/php/README.md
Constructor for the AllRatesToday client. Initializes the SDK with your API key, optional base URL, and timeout.
```APIDOC
## new AllRatesToday($apiKey, $baseUrl, $timeout)
### Description
Creates a new AllRatesToday client instance.
### Parameters
- **$apiKey** (string) - Required - Your API key.
- **$baseUrl** (string) - Optional - API base URL, defaults to `https://allratestoday.com`.
- **$timeout** (int) - Optional - Request timeout in seconds, defaults to `10`.
### Example
```php
$client = new AllRatesToday('art_live_your_key_here');
```
```
--------------------------------
### Initialize client with API key
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript-central-bank/README.md
Initializes the client with a free API key from the environment variable `ALLRATES_API_KEY`. Methods that require a key throw `NeedsApiKeyError` (a subclass of `CentralBankError`) with sign-up instructions before making any request.
```ts
const cb = new CentralBankRates({ apiKey: process.env.ALLRATES_API_KEY });
```
--------------------------------
### curl Example - Custom Date Range
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Example curl request for a custom date range from 2026-01-01 to 2026-03-31.
```bash
curl -H "Authorization: Bearer art_live_your_api_key" \
"https://allratestoday.com/api/v1/rates?source=USD&target=CAD&from=2026-01-01&to=2026-03-31"
```
--------------------------------
### AllRatesToday Client Configuration
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Creates a new AllRatesToday client instance with required API key and optional base URL and timeout settings.
```APIDOC
## AllRatesToday Client Configuration
### Description
Creates a new AllRatesToday client instance with required API key and optional base URL and timeout settings.
### Constructor
`new AllRatesToday(options)`
### Parameters
- **apiKey** (string) - Required - Your API key
- **baseUrl** (string) - Optional - API base URL (default: `https://allratestoday.com`)
- **timeout** (number) - Optional - Request timeout in milliseconds (default: `10000`)
### Example
typescript
const client = new AllRatesToday({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://allratestoday.com',
timeout: 10000,
});
```
--------------------------------
### Create client with API key
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/python-central-bank/README.md
Instantiate the client with a free API key to unlock historical dates, time series, publication calendars, and cross-source comparison. Methods that require a key raise NeedsApiKeyError before making any request.
```python
cb = CentralBankRates(api_key="art_live_...")
```
--------------------------------
### Single Rate: get rate between two currencies
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Get a single exchange rate between USD and EUR using the getRate() method. The response includes from, to, rate, and source.
```typescript
const rate = await client.getRate('USD', 'EUR');
console.log(rate);
```
--------------------------------
### Configure AllRatesToday client
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Creates a new AllRatesToday client with required apiKey and optional baseUrl and timeout settings.
```typescript
const client = new AllRatesToday({
apiKey: 'YOUR_API_KEY', // Required — get one free at allratestoday.com/register
baseUrl: 'https://allratestoday.com', // Optional — API base URL
timeout: 10000, // Optional — request timeout in ms
});
```
--------------------------------
### Run tests with coverage report
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/sdks/javascript/README.md
Runs the test suite and generates a coverage report.
```bash
npm run test:coverage
```
--------------------------------
### Add allratestoday Rust crate
Source: https://github.com/allrates-today/exchange-rates-api/blob/main/docs/AllRatesToday-API-Specifications.pdf
Add the allratestoday Rust crate from crates.io.
```bash
cargo add allratestoday
```