Get Swiss Franc (CHF) - N/A prices using this API for real-time forex quoting
The fastest way to get Swiss Franc (CHF) prices for real-time forex quoting in trading front-ends, risk dashboards, or checkout flows is to wire a dependable market data API directly into your stack. This article shows how to use the Metals-API to retrieve CHF quotes and history programmatically, then apply them to pricing, hedging, and analytics. We’ll integrate CHF with a tight subset of endpoints that matter for foreign exchange workflows, walk through request/response patterns, and explain the gotchas around base currency, timestamps, and caching. You’ll also see how to combine CHF with metal symbols when you need to express a metal price or hedge exposure in Swiss Francs—without adding latency or complexity.
Why CHF real-time prices matter in fintech and trading
CHF is a reserve currency used broadly across private banking, wealth management, and commodities trade finance. Whether you’re quoting a precious metal in Swiss Francs on a jewelry e-commerce site, building a trading blotter that needs live P&L in CHF, or producing an ERP cost roll-up for a Swiss manufacturing unit, consistent and reliable CHF rates are essential. The Metals-API delivers both metals and currency rates through the same interface, so your application can track metals and express them in CHF using a single integration.
Use cases addressed in this guide
- Real-time forex quoting: fetch the latest CHF rate to translate a USD-denominated price into Swiss Francs on the fly.
- Historical backfill: source CHF time series for backtesting, charting, or P&L explain across specific ranges.
- Conversion pipelines: standardize pricing calculations into CHF with auditable conversion inputs and reproducible outcomes.
We will focus on three core endpoints:
- Latest Rates: to pull the current CHF quote.
- Time-Series: to backfill CHF rates across a date window.
- Convert: to convert monetary amounts to/from CHF on demand.
For broader features, see the detailed Metals-API Documentation and complete Metals-API Supported Symbols. If you don’t have credentials yet, start with the free tier at the Metals-API Website.
How the Metals-API models CHF and metals
The Metals-API returns rates using a base currency (by default, USD). You can request CHF explicitly, or request all rates and read CHF from the payload. For metals, the service also expresses prices per troy ounce. When you combine CHF with a metal (for example, computing the price of gold or tin in CHF), you’ll often:
- Fetch the latest metal rate relative to the base (commonly USD) and get CHF relative to the same base.
- Compute the cross to express the metal in CHF.
- Apply unit conversions (troy ounce to grams or kilograms) if needed for operational pricing.
Because CHF rates and metals rates come from one API, you reduce the operational risk of mismatched timestamps or vendor methodologies across your pipelines.
Endpoint 1: Latest Rates for CHF
Use the Latest endpoint to retrieve the current CHF quote. This is the right choice for e-commerce real-time pricing, “mark-to-now” P&L snapshots, and on-screen quote refreshes. Depending on your plan, updates may be intraday; always check your account tier for expected frequency and integrate caching accordingly.
Purpose and functionality
- Returns the most recent available rates for requested symbols.
- Base currency defaults to USD if not specified.
- Suitable for UI refreshes, price tickers, and quick conversions.
Parameters and guidance
- access_key: Your API key. Get one at the Metals-API Website.
- base (optional): The base currency to which all rates are relative. If omitted, USD is used.
- symbols (optional): A comma-separated list of symbols; include CHF to focus on Swiss Francs.
cURL example: request CHF
curl -s "https://metals-api.com/api/latest?access_key=YOUR_API_KEY&symbols=CHF"
Example response
The following JSON mirrors the documented structure and includes CHF. The base currency is USD by default; the timestamp is a Unix epoch.
{
"success": true,
"timestamp": 1789690187,
"base": "USD",
"date": "2026-09-18",
"rates": {
"CHF": 0.9152
}
}
Field-by-field breakdown and usage
- success: Boolean indicating a successful request. Check this first to guard downstream logic.
- timestamp: Unix epoch seconds for the rate snapshot. Use this to align candles, compute drift, and cache expiration.
- base: The currency all returned rates are measured against; default is USD.
- date: ISO day corresponding to the timestamp; use for reporting and chart labels.
- rates.CHF: The rate for CHF relative to base. With base=USD, rates.CHF = CHF per 1 USD. To express 1 CHF in USD, invert the value.
Real-world implementation tips
- Caching: If your UI refreshes every few seconds but your plan updates every X minutes, cache by timestamp to avoid exceeding quotas and to present consistent numbers.
- Weekend handling: Forex markets can show limited updates over weekends; treat unchanged timestamps as expected. For charts, carry forward the last value if no new tick is available.
- Base alignment: If your downstream system expects base=CHF, either invert USD-based quotes or request base=CHF directly, then maintain consistency across endpoints.
- Latency: Batch symbols in one call when you also need metals alongside CHF to reduce HTTP overhead.
Common pitfalls and troubleshooting
- Assuming 1/rate symmetry without base awareness: Always confirm what the base is before inverting.
- Stale cache: Tie cache invalidation to timestamp, not wall time, to avoid displaying mismatched series when the vendor refreshes asynchronously.
- Precision: Store rates as decimal types in your database to avoid floating-point rounding issues, especially in P&L reconciliation.
Endpoint 2: Time-Series for CHF
When backtesting strategies, generating historical charts, or reconciling period P&L into CHF, use the Time-Series endpoint. It aggregates daily data between two dates under a single request so your ETL process is stable and auditable.
Purpose and functionality
- Returns a dictionary of daily rates keyed by date over a specified range.
- Uses a base currency (default USD); the CHF series is consistent with that base.
- Ideal for historical analytics, OHLC alignment, and backtesting.
Parameters and guidance
- access_key: Your API key.
- start_date, end_date: Inclusive ISO dates in YYYY-MM-DD format.
- base (optional): Defaults to USD. Keep it consistent with your other data feeds.
- symbols (optional): Use CHF to constrain payload size and improve performance.
Example request
curl -s "https://metals-api.com/api/timeseries?access_key=YOUR_API_KEY&start_date=2026-09-11&end_date=2026-09-18&symbols=CHF"
Example response
{
"success": true,
"timeseries": true,
"start_date": "2026-09-11",
"end_date": "2026-09-18",
"base": "USD",
"rates": {
"2026-09-11": {
"CHF": 0.9185
},
"2026-09-13": {
"CHF": 0.9170
},
"2026-09-18": {
"CHF": 0.9152
}
}
}
How to interpret and use the series
- timeseries: Confirms the payload contains a date-indexed series.
- rates[date].CHF: CHF per 1 USD for that date. Use this to build daily charts or compute returns and vol.
- Gaps and holidays: If a date is not present, don’t assume zero. Most systems carry forward the last observation or exclude non-trading days in analytics windows.
- Alignment: If you consume metals data on the same dates, the base alignment simplifies expressing any metal in CHF by cross-multiplying or inverting as needed.
Performance considerations
- Window size: For long ranges, partition requests by month or quarter to control payload size and avoid timeouts in constrained environments.
- Cold vs warm cache: Store the series in your DB or object store and only refresh recent dates on a rolling basis.
Troubleshooting
- Empty days: Weekends and holidays may be absent; design your charting layer to handle sparse series.
- Clock skew: Use the API’s timestamp rather than your server clock to define daily cutoffs if you must match vendor day boundaries.
Endpoint 3: Convert amounts to/from CHF
The Convert endpoint standardizes amount conversions into CHF (or out of CHF) using the underlying rate at the time of the query. It’s the recommended approach for transactional pricing, invoicing, and checkout flows where the exact converted amount must be recorded.
Purpose and functionality
- Converts any amount from one symbol to another—commonly between currencies, or between USD and a metal in advanced pricing flows.
- Returns the rate used and the computed result. Store both for auditability.
Parameters and guidance
- access_key: Your API key.
- from: The input currency code, e.g., USD or CHF.
- to: The target currency code, e.g., CHF or USD.
- amount: The numeric amount to convert.
cURL example: convert 1,250 USD to CHF
curl -s "https://metals-api.com/api/convert?access_key=YOUR_API_KEY&from=USD&to=CHF&amount=1250"
Example response
{
"success": true,
"query": {
"from": "USD",
"to": "CHF",
"amount": 1250
},
"info": {
"timestamp": 1789690187,
"rate": 0.9152
},
"result": 1143.9999999999998
}
Interpreting the conversion payload
- query: Echoes your request parameters—log this for traceability.
- info.timestamp: The rate’s Unix timestamp. Use this to lock in the conversion moment for compliance and reconciliation.
- info.rate: The applied rate, CHF per 1 USD in this example.
- result: The computed CHF amount. Retain result and rate together in your ledger or order record.
Practical tips for production conversions
- Rounding: Define deterministic rounding rules (banker’s, round-half-up) and precision (e.g., 2 decimals for CHF in retail, more for institutional).
- Idempotency: Attach an idempotency key to conversion-triggering requests in your app to avoid duplicate charges or ledger entries on retries.
- Spread/markups: If your business applies a markup over spot, store both the spot rate and the applied rate for transparency.
Quick-start: programmatic usage
Below is a minimal Python example to fetch the latest CHF rate and convert a USD amount. Adapt error handling, retries, and logging to your standards.
import os
import json
import time
import urllib.request
import urllib.parse
API_KEY = os.environ.get("METALS_API_KEY", "YOUR_API_KEY")
def get_latest_chf():
params = urllib.parse.urlencode({
"access_key": API_KEY,
"symbols": "CHF"
})
url = f"https://metals-api.com/api/latest?{params}"
with urllib.request.urlopen(url, timeout=15) as resp:
data = json.loads(resp.read().decode("utf-8"))
if not data.get("success"):
raise RuntimeError(f"API error: {data}")
return data
def convert_usd_to_chf(amount_usd):
params = urllib.parse.urlencode({
"access_key": API_KEY,
"from": "USD",
"to": "CHF",
"amount": amount_usd
})
url = f"https://metals-api.com/api/convert?{params}"
with urllib.request.urlopen(url, timeout=15) as resp:
data = json.loads(resp.read().decode("utf-8"))
if not data.get("success"):
raise RuntimeError(f"API error: {data}")
return data
if __name__ == "__main__":
latest = get_latest_chf()
print("Latest CHF payload:")
print(json.dumps(latest, indent=2))
quote_ts = latest.get("timestamp")
rate = latest.get("rates", {}).get("CHF")
print(f"Timestamp: {quote_ts} Rate (CHF per 1 USD): {rate}")
converted = convert_usd_to_chf(1250)
print("\nConversion result:")
print(json.dumps(converted, indent=2))
For complete parameter options, error shapes, and advanced endpoints, visit the Metals-API Documentation. To validate that CHF is supported in your plan, consult the Metals-API Supported Symbols.
CHF in multi-asset workflows: combining metals and currencies
One of the most powerful patterns is quoting a metal in CHF directly in your UI. Because Metals-API returns metals and currency rates consistently, you can compute a CHF metal price by combining the latest values. For example, to price tin (symbol XSN) in CHF per kilogram, you would:
- Fetch Latest for XSN (per troy ounce) and CHF (per 1 USD if using USD base).
- Compute price per troy ounce in USD, then convert to CHF using the CHF rate.
- Convert troy ounce to grams (1 troy ounce = 31.1034768 grams) and scale to kilograms.
This workflow is useful for digital transformation of procurement (e.g., contracts in CHF, supplier quotes in USD), smart technology integration in ERP pricing engines, and data analytics that compare cost indices across currencies. Technological innovation in this space often hinges on standardizing these conversions so analytics pipelines can compare apples to apples across business units.
Future trends and possibilities with CHF and tin (XSN)
- Intelligent hedging: Automate hedging for tin purchase orders triggered by CHF strength/weakness thresholds.
- Event-driven analytics: Fire alerts when CHF volatility breaches a threshold that materially impacts tin margins.
- Scenario modeling: Stress-test CHF scenarios against tin input costs to evaluate pricing power and contract renegotiations.
For symbol validation, see the Metals-API Supported Symbols. When you implement this cross-asset logic, keep units straight and document your conversion chain for auditability.
Architectural patterns for CHF-first applications
Pattern A: Base=USD everywhere, convert at the edge
- Store all canonical prices and historical series in USD.
- Fetch CHF on page load or tick update; convert in the presentation layer.
- Pros: Simpler canonical storage. Cons: Recompute on each view; accept rounding differences across sessions.
Pattern B: Base=CHF in your data layer
- Set base=CHF in API calls or invert USD-based quotes on ingestion.
- Normalize all metals and FX into CHF before persisting.
- Pros: Consistent CHF-native analytics and P&L. Cons: Need robust base-inversion logic during ETL.
Pattern C: Dual base storage
- Persist core series in USD and CHF to reduce on-demand conversions.
- Use time-series endpoint for batch backfills; use latest for intraday deltas.
- Pros: Faster reads for high-traffic apps. Cons: More storage and synchronization logic.
Data hygiene: units, time zones, and weekends
- Units: CHF is a currency; there’s no “per troy ounce” concept. When combining with metals, the metal leg will be per troy ounce. Convert units before user display to avoid confusion.
- Time zones: The API timestamp is epoch seconds; standardize conversions to UTC in your systems.
- Weekends and holidays: Expect fewer or no updates. For valuation, carry forward the last tick or apply your governance policy for stale rates.
Caching and rate management
- Immutable by timestamp: If timestamp is unchanged across polls, serve from cache to save requests.
- Layered cache: Use in-memory cache for hot paths and a TTL-aligned distributed cache for scale.
- Batch symbols: If you also need other currencies with CHF for cross calculations, request them together to minimize overhead.
Error handling and recovery
- Upfront validation: Check success before reading fields.
- Backoff and jitter: On transient HTTP errors or vendor maintenance windows, exponentially back off and introduce jitter.
- Partial degradation: If Latest is briefly unavailable, fall back to the most recent Time-Series day plus a clear “as of” label in UI.
Security and operational best practices
- API key storage: Keep your key in a secure secret manager. Never hard-code keys in clients shipped to end users.
- TLS enforcement: Always use HTTPS endpoints.
- Audit logging: Log request IDs, timestamps, and payload digests for reconciliation and incident response.
- Least privilege: Limit where the key is deployed; avoid embedding it in public front-end code.
Testing and monitoring
- Contract tests: Validate the presence and type of fields (success, timestamp, rates.CHF) in CI.
- Canary checks: Monitor response times and success rates from multiple regions.
- Data quality alarms: Alert on large jumps in CHF day-over-day if outside your expected volatility bands.
Frequently used symbol references
Always verify symbol support and naming in the official list: Metals-API Supported Symbols. For this article, our focus is CHF. When integrating metals in CHF scenarios (for example, tin in CHF), confirm each symbol before going to production.
Get started now
To start quoting in Swiss Francs today, create a free key and hit the Latest, Time-Series, and Convert endpoints. You’ll be able to price in CHF in minutes and expand to metals-in-CHF workflows as needed. Visit the Metals-API Website and the step-by-step Metals-API Documentation to integrate now.
Appendix: Additional practical guidance
Precision and rounding in CHF
- Store raw rates at high precision (e.g., 8–10 decimal places) and round at the display layer.
- Be explicit about rounding mode to avoid reconciliation drift.
Handling spreads and execution prices
- If you must approximate executable prices, consider modeling a business-defined spread over the spot rate. Record both the spot and the applied rate.
Change detection (fluctuation-based alerts)
While not covered deeply here, you can design alerts based on day-over-day or week-over-week changes in CHF by comparing adjacent entries in the Time-Series payload. For a list of all endpoints that may help with movement analysis, see the documentation.
References and related links
- Metals-API Website — create a free API key and check plan features.
- Metals-API Documentation — in-depth endpoint specifications and parameters.
- Metals-API Supported Symbols — confirm that CHF and any target symbols are supported.
- Swiss National Bank — context on CHF policy, rates, and market background.
Conclusion
For real-time forex quoting in Swiss Francs, a clean integration with Metals-API gives you current CHF rates, historical backfills, and precise conversions—using a single, consistent interface that also supports metals when you need to price commodities in CHF. We focused on the three endpoints that matter most to CHF workflows: Latest (for live quoting), Time-Series (for backtesting and charts), and Convert (for transactional accuracy). With careful attention to base currency, timestamp alignment, unit conversions when mixing metals, and robust caching, you can ship production-ready CHF pricing quickly. Get your free key from the Metals-API Website and consult the Metals-API Documentation to implement today.
FAQ
What symbol should I use for Swiss Franc?
Use CHF. Confirm support on the Metals-API Supported Symbols page.
What is the base currency in responses?
By default, USD. You can specify a different base in requests or invert as needed. Always check the base field before interpreting rates.
How often are CHF rates updated?
Update frequency depends on your plan. Cache by timestamp to avoid unnecessary calls between updates.
How do I convert amounts to CHF?
Use the Convert endpoint with from=USD (or other) and to=CHF, passing the amount. Store the returned rate and timestamp for audit.
Can I price metals in CHF?
Yes. Fetch the metal rate and CHF rate with a consistent base, then compute the cross and apply unit conversions (e.g., troy ounce to grams) before display.
What about weekends and holidays?
Expect fewer updates. Carry forward the last known rate for charting or valuation, with clear “as of” labeling.
Is there an SDK?
You can call the REST API with your preferred HTTP client. Refer to the documentation for full details.