Central African Cfa Franc (XAF) - N/A Spot Price: Live API Integration Guide

Metals-API 8 min read
Central African Cfa Franc (XAF) - N/A Spot Price: Live API Integration Guide

You need to display or convert live Central African CFA franc (XAF) prices in your app—quoting a jewelry item to a customer in Yaoundé, converting a USD-denominated procurement budget to XAF, or normalizing a metals research dashboard for a Central Africa audience. By the end of this guide, you will fetch the current XAF spot from the API, understand the USD⇄XAF inversion, and wire it into your code with caching and reliability basics.

What we’re building: real-time XAF for pricing and P&L

This walkthrough focuses on a single job: integrate the XAF spot in real time and use it to convert USD values to XAF (and back). Typical use cases include:

  • Localizing USD-denominated metal quotes into XAF on product detail pages and checkouts.
  • Converting a USD procurement line item to XAF for internal approvals and vendor payments.
  • Saving the daily XAF rate to support end-of-day P&L and financial reporting in Central Africa.

We’ll use at most two endpoints to keep it focused: Latest Rates for live XAF, and brief notes on Time-Series if you want daily closes for backfilling. For other features, see the Documentation and confirm symbol availability on the Symbols page. If you don’t yet have credentials, get an API key here: Register.

Get the live Central African CFA franc (XAF) spot

The Latest Rates endpoint returns live exchange rates with USD as the base currency by default. For XAF, request the XAF symbol. You can also request USDXAF, which is the inverted quote (USD per 1 XAF):

curl -s "https://metals-api.com/api/latest?access_key=YOUR_API_KEY&symbols=XAF,USDXAF"

Below is the real JSON response format to expect when querying XAF (fields and values shown exactly as received in a sample call):

{"success":true,"timestamp":1792973340,"date":"2026-10-26","base":"USD","rates":{"XAF":584.812154,"USD":1,"USDXAF":0.0017099507819052613}}

What these fields mean for your code

  • base: "USD" — all rates are quoted relative to 1 USD by default.
  • rates.XAF: 584.812154 — XAF per 1 USD (i.e., how many francs you get for one US dollar).
  • rates.USDXAF: 0.0017099507819052613 — USD per 1 XAF (the inverse of XAF per USD).
  • timestamp: 1792973340 and date: "2026-10-26" — the server’s pricing time (epoch seconds) and the human-readable date. Treat timestamp as UTC.

You will typically use:

  • rates.XAF to convert any USD amount into XAF (multiply USD by XAF-per-USD).
  • rates.USDXAF to convert any XAF amount into USD (multiply XAF by USD-per-XAF).

Python example: convert USD amounts to XAF and back

This script fetches the latest XAF spot, converts a USD amount to XAF for local pricing, and converts an XAF amount back to USD for P&L.

import requests
from datetime import datetime, timezone

API_KEY = "YOUR_API_KEY"
URL = "https://metals-api.com/api/latest"

params = {
    "access_key": API_KEY,
    "symbols": "XAF,USDXAF"
}

resp = requests.get(URL, params=params, timeout=10)
resp.raise_for_status()
data = resp.json()

if not data.get("success"):
    raise RuntimeError(f"API error: {data}")

ts = data["timestamp"]  # epoch seconds (UTC)
as_of = datetime.fromtimestamp(ts, tz=timezone.utc)
base = data["base"]
xaf_per_usd = data["rates"]["XAF"]           # XAF per 1 USD
usd_per_xaf = data["rates"]["USDXAF"]        # USD per 1 XAF

# Example conversions
usd_amount = 1500.00
xaf_price = usd_amount * xaf_per_usd

xaf_amount = 250000.00
usd_price = xaf_amount * usd_per_xaf

print(f"As of {as_of.isoformat()} base={base}")
print(f"1 USD = {xaf_per_usd} XAF")
print(f"1 XAF = {usd_per_xaf} USD")
print(f"{usd_amount} USD = {xaf_price} XAF")
print(f"{xaf_amount} XAF = {usd_price} USD")

Swap out the example amounts with your own cart totals, procurement line items, or valuation numbers. Keep the base currency logic in mind: because base=USD, multiplying USD by rates.XAF gives XAF; multiplying XAF by rates.USDXAF gives USD.

Understanding inversion and when to use XAF vs USDXAF

Metals-API standardizes on base=USD in responses. That means:

  • rates.XAF is directly usable for USD→XAF conversions (localizing USD prices for Central Africa).
  • rates.USDXAF is directly usable for XAF→USD conversions (normalizing XAF costs into USD reporting).

If you store only one side, compute the other via inversion to reduce payload size: USDXAF = 1 / XAF. Always guard against division by zero and prefer server-provided USDXAF if you requested it; it reflects the API’s precise calculation at source time.

How this plugs into metals workflows

If your app consumes metal quotes that are USD-based (for example, per-troy-ounce prices in USD), you can localize totals to XAF by multiplying your USD-denominated metal price or invoice total by rates.XAF. Remember:

  • Metals pricing on this API is quoted per troy ounce by default when you request a metal symbol. When combining with metals, keep your unit math explicit (troy ounces vs grams) elsewhere in your stack.
  • This guide focuses on the XAF currency side only. For the complete catalog of metal and currency symbols, check the Symbols page.

Reliability, caching, and operational notes

  • Timestamps and timezone: Treat timestamp as epoch seconds in UTC. Persist the timestamp with your stored rate to make downstream decisions deterministic.
  • Update frequency: Depending on plan, the Latest Rates endpoint updates roughly every 60 minutes or 10 minutes. Cache the response for at least the update interval to reduce request volume and jitter in your UI.
  • Weekend/market closures: If you query during weekends or holidays, currency updates can be less frequent. Use the last known good rate and surface the as-of timestamp in your UI.
  • HTTP resiliency: Add short timeouts, retries with exponential backoff on transient errors, and a circuit-breaker to fall back to your cached rate.
  • Precision: Use decimal types in your language of choice when multiplying totals to avoid floating-point drift, especially for larger baskets or multi-line invoices.
  • Idempotent storage: When archiving daily XAF closes, key your records by the API date field and verify monotonic timestamps to prevent duplicates.

Historical runs and daily reporting with Time-Series

For dashboards and backfills, request a date range of daily XAF fixes using the Time-Series endpoint. You’ll receive one rate per day keyed by date. Once you’ve validated your live workflow with Latest Rates, extend your batch pipeline with Time-Series to compute:

  • Daily averages of localized (XAF) procurement spend.
  • Day-over-day FX impact on margin for XAF-region orders.

Design your batch job to run once per day shortly after the time your business defines as “close.” Always use the response’s date keys and timestamps for deterministic joins with your transactional ledger. For request parameters and field specifics, see the Documentation.

Testing and monitoring

  • Sanity checks: Verify that rates.XAF × rates.USDXAF ≈ 1.0 within tolerance; alert if divergence exceeds a threshold.
  • Alerting: Trigger on stale timestamp (older than your SLA), missing symbols, or HTTP errors.
  • Observability: Log the API timestamp, rate values, and cache hit/miss metrics. Include request IDs where available.

Security and deployment

  • Secrets: Store YOUR_API_KEY in your secret manager or environment variables; never commit it to source control.
  • Client vs server calls: Prefer server-side calls where feasible; if you must call from the browser, proxy through your backend to protect the key.
  • Version control: Wrap your integration in a thin service, pin dependencies, and unit-test inversion and rounding logic.

Cross-checks and references

  • Confirm symbol availability and naming on the Symbols page.
  • Read endpoint parameter options and response schemas in the Documentation.
  • Regulatory and macro context: Central African CFA franc monetary policy is managed by BEAC. For background, see the Bank of Central African States website: beac.int.

Advanced: tying XAF FX into metals pricing engines

If you maintain your own metals pricing model (e.g., fair value in USD per troy ounce), wire the XAF rate directly into your engine:

  • Localize spot quotes: localized_spot_xaf = spot_usd × rates.XAF.
  • Localize cart totals: sum the USD line items, multiply once by rates.XAF, and round at the end to minimize rounding error.
  • Normalize vendor quotes received in XAF: total_usd = total_xaf × rates.USDXAF to compare suppliers apples-to-apples in USD.

This keeps your app consistent even when you later integrate per-metal endpoints. When you expand, pay attention to units (troy ounces for metals vs weight or piece counts in your catalog) and keep conversions explicit and tested.

Operational checklists

  • Cache policy: Default to at least the documented update interval. If your traffic is bursty, apply a soft TTL and refresh in the background.
  • Fallbacks: Persist the last successful rate; if the API is temporarily unavailable, use the cached value and present an “as-of” label in the UI.
  • Data lineage: Stamp every ledger entry you create with the FX timestamp and the FX rate you used.
  • Audits: Store raw JSON responses for a short retention window to debug discrepancies with finance teams.

Notes for Tellurium (TE) watchers in XAF regions

Teams exploring Tellurium-related markets and supply chains can treat XAF integration as a foundational step in digital transformation. Once live XAF is in place, you can:

  • Feed TE-related procurement in USD into analytics, then render dashboards in XAF for on-the-ground operations.
  • Combine XAF FX with sensor-driven or ERP-derived TE throughput for smart, near-real-time margin tracking.
  • Prototype TE price stress tests by replaying historical XAF series to quantify FX sensitivity in Central African operations.

As you extend to more metals and analytics, lean on consistent timestamping and unit discipline to keep your insights trustworthy.

FAQ

Q: What’s the base currency in the response?
A: USD. rates.XAF is XAF per 1 USD, and rates.USDXAF is USD per 1 XAF. Use the one that directly matches your conversion direction.

Q: How should I show “as-of” times?
A: Convert timestamp (epoch seconds) to UTC and display it. If you localize to Africa/Douala or another regional timezone, keep UTC in logs for auditing.

Q: How often does the XAF rate update?
A: The Latest Rates endpoint updates periodically (for example, roughly every 60 or 10 minutes depending on plan). Cache accordingly and avoid polling faster than the update cadence.

Q: Can I backfill historical XAF rates?
A: Yes, use the Time-Series endpoint to request daily historical rates. Join those dates with your transaction ledger to compute historical XAF totals. See the Documentation for parameters.

Q: Any tips for precision and rounding?
A: Use decimal types and round only at display or posting time. For multi-line carts, sum in high precision and round the final total to your accounting standard.

Ready to ship XAF pricing? Get your API key and start integrating today: Register. If you need help aligning architecture, SLAs, or onboarding across teams, explore our program here: MCP.