MetalAPI provides real-time and historical data for precious metals, currencies, and commodities. Our RESTful API returns JSON responses and supports HTTPS encryption.
All API requests require authentication using your API key. You can include your API key in three ways:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://metalapi.com/api/v1/latest
curl -H "X-API-Key: YOUR_API_KEY" \
https://metalapi.com/api/v1/latest
curl "https://metalapi.com/api/v1/latest?api_key=YOUR_API_KEY"
Test API Key: For testing purposes, you can use: test-api-key-12345
Important: Keep your API key secure and never expose it in client-side code.
GET /v1/symbols
Get the list of all supported symbols (currencies and metals).
curl "https://metalapi.com/api/v1/symbols?api_key=YOUR_API_KEY"
{
"success": true,
"symbols": {
"XAU": "Gold",
"XAG": "Silver",
"XPT": "Platinum",
"XPD": "Palladium",
"USD": "US Dollar",
"EUR": "Euro",
"GBP": "British Pound"
},
"rate_limit": {
"limit": 10000,
"remaining": 9995,
"reset": 1748736000,
"used": 5,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
GET /v1/latest
Get the latest rates for all supported symbols.
Parameter | Type | Description |
---|---|---|
base | string | Base currency (default: USD) |
currencies | string | Comma-separated list of currencies |
curl "https://metalapi.com/api/v1/latest?api_key=YOUR_API_KEY&base=USD¤cies=XAU,XAG,EUR"
{
"success": true,
"timestamp": 1748189445,
"base": "USD",
"date": "2025-05-27",
"rates": {
"XAU": 0.00053853,
"USDXAU": 1856.906765,
"XAG": 0.032,
"USDXAG": 31.25,
"EUR": 0.8255334,
"USDEUR": 1.211338027
},
"rate_limit": {
"limit": 10000,
"remaining": 9995,
"reset": 1748736000,
"used": 5,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
GET /v1/{date}
Get historical rates for a specific date.
Parameter | Type | Description |
---|---|---|
date | string | Date in YYYY-MM-DD format |
base | string | Base currency (default: USD) |
currencies | string | Comma-separated list of currencies |
curl "https://metalapi.com/api/v1/2024-01-15?api_key=YOUR_API_KEY&base=USD¤cies=XAU,XAG"
{
"success": true,
"timestamp": 1705363200,
"historical": true,
"date": "2024-01-15",
"base": "USD",
"rates": {
"XAU": 0.00053853,
"USDXAU": 1856.906765,
"XAG": 0.032,
"USDXAG": 31.25
},
"rate_limit": {
"limit": 10000,
"remaining": 9995,
"reset": 1748736000,
"used": 5,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
GET /v1/convert
Convert one currency to another.
Parameter | Type | Description |
---|---|---|
from | string | Source currency |
to | string | Target currency |
amount | number | Amount to convert |
curl "https://metalapi.com/api/v1/convert?api_key=YOUR_API_KEY&from=USD&to=XAU&amount=1000"
{
"success": true,
"query": {
"from": "USD",
"to": "XAU",
"amount": 1000
},
"info": {
"timestamp": 1748189445,
"rate": 0.00053853
},
"result": 0.53853,
"rate_limit": {
"limit": 10000,
"remaining": 9995,
"reset": 1748736000,
"used": 5,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
GET /v1/timeframe
Get historical rates for a date range (max 365 days).
Parameter | Type | Description |
---|---|---|
start_date | string | Start date (YYYY-MM-DD) |
end_date | string | End date (YYYY-MM-DD) |
base | string | Base currency (default: USD) |
currencies | string | Comma-separated list of currencies |
curl "https://metalapi.com/api/v1/timeframe?api_key=YOUR_API_KEY&start_date=2024-01-01&end_date=2024-01-07¤cies=XAU"
{
"success": true,
"timeframe": true,
"start_date": "2024-01-01",
"end_date": "2024-01-07",
"base": "USD",
"rates": {
"2024-01-01": {
"XAU": 0.00053853,
"USDXAU": 1856.906765,
"XAG": 0.032,
"USDXAG": 31.25
},
"2024-01-02": {
"XAU": 0.00053853,
"USDXAU": 1856.906765,
"XAG": 0.032,
"USDXAG": 31.25
}
},
"rate_limit": {
"limit": 10000,
"remaining": 9995,
"reset": 1748736000,
"used": 5,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
GET /v1/change
Calculate rate changes between two dates.
Parameter | Type | Description |
---|---|---|
start_date | string | Start date (YYYY-MM-DD) |
end_date | string | End date (YYYY-MM-DD) |
base | string | Base currency (default: USD) |
currencies | string | Comma-separated list of currencies |
curl "https://metalapi.com/api/v1/change?api_key=YOUR_API_KEY&start_date=2024-01-01&end_date=2024-01-02¤cies=XAU"
{
"success": true,
"change": true,
"start_date": "2024-01-01",
"end_date": "2024-01-02",
"base": "USD",
"rates": {
"XAU": {
"start_rate": 0.00053853,
"end_rate": 0.00053853,
"change": 0,
"change_pct": 0
}
},
"rate_limit": {
"limit": 10000,
"remaining": 9995,
"reset": 1748736000,
"used": 5,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
GET /v1/ohlc
Get Open, High, Low, Close prices for a specific date.
Parameter | Type | Description |
---|---|---|
date | string | Date (YYYY-MM-DD) |
base | string | Base currency (default: USD) |
currencies | string | Comma-separated list of currencies |
curl "https://metalapi.com/api/v1/ohlc?api_key=YOUR_API_KEY&date=2024-01-01¤cies=XAU"
{
"success": true,
"ohlc": true,
"date": "2024-01-01",
"base": "USD",
"rates": {
"XAU": {
"open": 0.0005277594,
"high": 0.0005654565,
"low": 0.0005116035,
"close": 0.00053853
}
},
"rate_limit": {
"limit": 10000,
"remaining": 9995,
"reset": 1748736000,
"used": 5,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
GET /v1/carat
Get gold prices by carat (available for paid plans).
Parameter | Type | Description |
---|---|---|
carat | string | Gold carat (8, 10, 14, 18, 22, 24) |
base | string | Base currency (default: USD) |
curl "https://metalapi.com/api/v1/carat?api_key=YOUR_API_KEY&carat=24"
{
"success": true,
"carat": "24",
"date": "2025-05-27",
"base": "USD",
"timestamp": 1748336188,
"rates": {
"XAU24K": {
"price": 1856.9,
"unit": "troy_oz",
"carat": "24"
}
},
"rate_limit": {
"limit": 10000,
"remaining": 9995,
"reset": 1748736000,
"used": 5,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
GET /v1/usage
Get API usage statistics for your account.
curl "https://metalapi.com/api/v1/usage?api_key=YOUR_API_KEY"
{
"success": true,
"usage": {
"requests_made": 15,
"requests_quota": 1000,
"requests_remaining": 985,
"plan": "lite"
},
"rate_limit": {
"limit": 10000,
"remaining": 9995,
"reset": 1748736000,
"used": 5,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
API rate limits are based on your subscription plan. Requests are counted monthly and reset on the first day of each month.
Plan | Monthly Requests | Update Interval | Features |
---|---|---|---|
Free | 100 | Daily | Basic endpoints, Email support |
Lite | 1,000 | 30 minutes | All endpoints, Basic analytics |
Standard | 10,000 | 10 minutes | Priority support, Advanced analytics |
Advanced | 50,000 | 60 seconds | Webhook support, Custom domains |
Pro | 100,000 | 60 seconds | Premium support, White-label options |
Ultra | 500,000 | 15 seconds | Dedicated support, White-label |
Business | 500,000 | 15 seconds | SLA guarantee, Dedicated support |
Enterprise | 1,500,000 | 5 seconds | Custom integrations, Enterprise support |
Every API response includes comprehensive rate limit information in the headers:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 985
X-RateLimit-Reset: 1748189445
X-RateLimit-Used: 15
X-RateLimit-Plan: Standard
X-RateLimit-Reset-Date: 2025-06-01T00:00:00.000000Z
Header Descriptions
X-RateLimit-Limit
Your monthly request limit based on subscription plan
X-RateLimit-Remaining
Number of requests remaining in current period
X-RateLimit-Reset
Unix timestamp when rate limits reset (start of next month)
X-RateLimit-Used
Number of requests used in current period
X-RateLimit-Plan
Your current subscription plan name
X-RateLimit-Reset-Date
ISO 8601 formatted date when limits reset
Pro Tip: Monitor these headers in your application to implement client-side rate limiting and avoid hitting your limits.
In addition to headers, rate limit information is also included in the JSON response body:
{
"success": true,
"base": "USD",
"timestamp": 1748715946,
"rates": {
"EUR": 0.8255334,
"XAG": 0.03602543,
"XAU": 0.00053853
},
"rate_limit": {
"limit": 10000,
"remaining": 9992,
"reset": 1748736000,
"used": 8,
"plan": "Standard",
"reset_date": "2025-06-01T00:00:00.000000Z"
}
}
Dual Format: Rate limiting information is provided in both HTTP headers and JSON response body for maximum compatibility and ease of use.
When an error occurs, the API returns a JSON response with error details:
{
"success": false,
"error": {
"code": 101,
"type": "no_api_key",
"info": "You have not supplied an API Access Key."
}
}
Code | Type | Description |
---|---|---|
101 | no_api_key | No API key provided |
102 | invalid_api_key | Invalid API key |
103 | quota_exceeded | Monthly quota exceeded |
104 | invalid_base | Invalid base currency |
105 | invalid_symbols | Invalid currency symbols |
106 | invalid_date | Invalid date format |
300 | function_access_restricted | Feature not available for your plan |
404 | endpoint_not_found | Endpoint not found |
const axios = require('axios');
const apiKey = 'YOUR_API_KEY';
const baseUrl = 'https://metalapi.com/api/v1';
// Get latest rates
async function getLatestRates() {
try {
const response = await axios.get(`${baseUrl}/latest`, {
params: {
api_key: apiKey,
base: 'USD',
currencies: 'XAU,XAG,EUR'
}
});
console.log('Response:', response.data);
console.log('Rate Limit Info:', response.data.rate_limit);
// You can also access rate limit info from headers
console.log('Remaining requests:', response.headers['x-ratelimit-remaining']);
} catch (error) {
console.error('Error:', error.response.data);
if (error.response.data.rate_limit) {
console.log('Rate Limit Info:', error.response.data.rate_limit);
}
}
}
// Convert currency
async function convertCurrency() {
try {
const response = await axios.get(`${baseUrl}/convert`, {
params: {
api_key: apiKey,
from: 'USD',
to: 'XAU',
amount: 1000
}
});
console.log(`1000 USD = ${response.data.result} XAU`);
console.log('Rate Limit Info:', response.data.rate_limit);
} catch (error) {
console.error('Error:', error.response.data);
}
}
// Get symbols
async function getSymbols() {
try {
const response = await axios.get(`${baseUrl}/symbols`, {
params: {
api_key: apiKey
}
});
console.log('Available symbols:', response.data.symbols);
console.log('Rate Limit Info:', response.data.rate_limit);
} catch (error) {
console.error('Error:', error.response.data);
}
}
getLatestRates();
convertCurrency();
getSymbols();
import requests
import json
API_KEY = 'YOUR_API_KEY'
BASE_URL = 'https://metalapi.com/api/v1'
def get_latest_rates():
"""Get latest exchange rates"""
params = {
'api_key': API_KEY,
'base': 'USD',
'currencies': 'XAU,XAG,EUR'
}
response = requests.get(f'{BASE_URL}/latest', params=params)
if response.status_code == 200:
data = response.json()
print('Response:', json.dumps(data, indent=2))
print(f'Remaining requests: {data["rate_limit"]["remaining"]}')
# You can also access rate limit info from headers
print(f'Rate limit from headers: {response.headers.get("X-RateLimit-Remaining")}')
else:
print(f'Error: {response.status_code}')
error_data = response.json()
print(json.dumps(error_data, indent=2))
if 'rate_limit' in error_data:
print('Rate Limit Info:', error_data['rate_limit'])
def convert_currency(from_currency, to_currency, amount):
"""Convert one currency to another"""
params = {
'api_key': API_KEY,
'from': from_currency,
'to': to_currency,
'amount': amount
}
response = requests.get(f'{BASE_URL}/convert', params=params)
if response.status_code == 200:
data = response.json()
print(f'{amount} {from_currency} = {data["result"]} {to_currency}')
print('Rate Limit Info:', data['rate_limit'])
else:
print(f'Error: {response.status_code}')
print(response.json())
def get_symbols():
"""Get available symbols"""
params = {
'api_key': API_KEY
}
response = requests.get(f'{BASE_URL}/symbols', params=params)
if response.status_code == 200:
data = response.json()
print('Available symbols:')
if 'metals' in data['symbols']:
print('Metals:', data['symbols']['metals'])
if 'currencies' in data['symbols']:
print('Currencies:', data['symbols']['currencies'])
print('Rate Limit Info:', data['rate_limit'])
else:
print(f'Error: {response.status_code}')
print(response.json())
# Example usage
get_latest_rates()
convert_currency('USD', 'XAU', 1000)
get_symbols()
<?php
// Simple PHP example - Get latest gold price
$api_key = 'YOUR_API_KEY';
$url = 'https://metalapi.com/api/v1/latest?api_key=' . urlencode($api_key) . '&base=USD¤cies=XAU';
$response = file_get_contents($url);
$data = json_decode($response, true);
if ($data['success']) {
echo "Gold Price: $" . $data['rates']['XAU'] . " per troy ounce\n";
echo "Rate Limit: " . $data['rate_limit']['remaining'] . " requests remaining\n";
} else {
echo "Error: " . $data['message'] . "\n";
}
?>
# Get latest rates
curl "https://metalapi.com/api/v1/latest?api_key=YOUR_API_KEY&base=USD¤cies=XAU,XAG,EUR"
# Get symbols
curl "https://metalapi.com/api/v1/symbols?api_key=YOUR_API_KEY"
# Convert currency
curl "https://metalapi.com/api/v1/convert?api_key=YOUR_API_KEY&from=USD&to=XAU&amount=1000"
Create beautiful, customizable widgets to display real-time metal and currency rates on your website. Our widget system provides easy integration with full customization control.
Use our interactive widget generator to create custom widgets without any coding. Choose from multiple themes, sizes, and data types.
Clean grid layout with card-based design
Compact single symbol display
Scrolling ticker for multiple symbols
Comprehensive table with all details
Simple vertical list layout
Full screen display for TV/monitors
Get Started: Visit our widget generator to create your first widget
Open Widget GeneratorLearn how to integrate MetalAPI widgets into your website with these simple steps.
Use the widget generator to configure your widget settings, select symbols, and customize the appearance.
After creating your widget, copy the generated embed code. Choose between HTML embed or JavaScript integration.
<!-- HTML Embed -->
<iframe src="https://metalapi.com/widget/YOUR_WIDGET_ID"
width="400" height="300" frameborder="0"></iframe>
<!-- JavaScript Integration -->
<div id="metalapi-widget"></div>
<script src="https://metalapi.com/js/widget.js"></script>
<script>
MetalAPIWidget.init({
container: '#metalapi-widget',
widgetId: 'YOUR_WIDGET_ID',
apiUrl: 'https://metalapi.com/api/widgets/data'
});
</script>
Paste the embed code into your HTML where you want the widget to appear. The widget will automatically load and display real-time data.
Tip: Make sure your domain is added to the widget's allowed domains list for security.
Customize your widgets with these configuration options to match your website's design and requirements.
See our widgets in action with these live examples. Click on any widget to view it in full screen.
Ready to create your own widget?
Need help integrating MetalAPI? Our support team is here to assist you.