Pune Gold 24k (PUNE-24k) - Per Gram Convert API

Metals-API 9 min read
Pune Gold 24k (PUNE-24k) - Per Gram Convert API

You need a reliable way to display Pune 24k gold per-gram prices in your app or pricing engine. By the end of this guide, you will fetch live XAU data, convert it from USD per troy ounce into per-gram pricing, and (optionally) translate it into your local currency for Pune storefronts, trading tools, or ERP integrations.

What “Pune Gold 24k per gram” means in API terms

The global benchmark for gold is XAU (fine gold, troy ounce). Pune jewelers typically quote 24k (99.9% purity) per gram. To bridge that gap, your app should:

Illustration: Pune Gold 24k (PUNE-24k) - Per Gram Convert API
  • Fetch XAU pricing with base USD.
  • Use USDXAU (USD per troy ounce) when available for direct unit pricing.
  • Convert troy ounces to grams: 1 troy ounce = 31.1034768 grams.
  • Optionally convert USD to your local currency via the Convert endpoint.
  • Apply local fees, GST, making charges, and a city premium as separate, explicit add-ons.

This approach gives a transparent, auditable “commodity base” for Pune 24k per-gram prices, while keeping retail adjustments modular and trackable.

Endpoints you will use

To keep it focused and production-ready, we will use two endpoints:

  • Latest Rates: to get current XAU quotes and USDXAU (USD per ounce).
  • Convert: to convert XAU or USD amounts into your chosen currency for Pune display.

If you later need historical backfilling or analytics, see the Historical and Time-series sections of the Documentation. For the universe of metals and currency symbols, refer to the Symbols list.

Step 1: Get live XAU pricing

Request the Latest Rates endpoint for XAU and USDXAU. USDXAU is the direct USD-per-ounce quote; XAU is the inverse (ounces per USD). Both are useful depending on the math you prefer.

curl "https://metals-api.com/api/latest?access_key=YOUR_API_KEY&symbols=XAU,USDXAU&base=USD"

Example response (use these exact values to validate your parser):

{"success":true,"timestamp":1792454820,"date":"2026-10-20","base":"USD","rates":{"XAU":0.00024179703556834,"USD":1,"USDXAU":4135.700000000067}}

What these fields mean for per-gram pricing

  • base: USD. All rates are quoted relative to USD unless you change base.
  • rates.XAU: ounces per 1 USD. You will usually invert if you need USD per ounce.
  • rates.USDXAU: USD per 1 ounce. Directly usable for USD/oz to gram conversion.
  • timestamp/date: when the quote was last updated. Treat this as UTC unless your UI converts it.

To compute Pune 24k per gram in USD:

  • USD per ounce = rates.USDXAU
  • USD per gram = rates.USDXAU / 31.1034768

If you display in a local currency, convert that USD per gram using the Convert endpoint as shown below.

Step 2: Convert to per gram and your currency

Metals-API provides a conversion endpoint to translate amounts across metals and currencies. A typical workflow for Pune:

  1. Get USDXAU from Latest.
  2. Compute USD per gram.
  3. Convert USD per gram to your target currency code via Convert.
  4. Add local taxes and making charges in your app.

The Convert endpoint is documented here: Metals-API Documentation. Use it to convert from USD to your local currency for “Pune 24k per gram”. If you’re unsure about symbol codes for currencies, consult the Symbols page.

End-to-end code: compute Pune 24k gold per gram

The snippet below pulls live XAU pricing, converts to per gram, then converts USD to a target currency code. Replace TARGET_CCY with your local currency code, set your taxes/fees in code, and wire it to your pricing UI or order flow.

import requests
from decimal import Decimal, ROUND_HALF_UP

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://metals-api.com/api"
TARGET_CCY = "TARGET_CCY" # e.g., your local currency code from the Symbols page

TROY_OUNCE_TO_G = Decimal("31.1034768")

def get_latest_usdxau():
# Request both XAU and USDXAU so you have inverse and direct quotes
url = f"{BASE_URL}/latest"
params = {
"access_key": API_KEY,
"base": "USD",
"symbols": "XAU,USDXAU"
}
r = requests.get(url, params=params, timeout=10)
r.raise_for_status()
data = r.json()
# Validate required fields
if not data.get("success") or "rates" not in data or "USDXAU" not in data["rates"]:
raise RuntimeError(f"Unexpected latest payload: {data}")
return Decimal(str(data["rates"]["USDXAU"])), data["timestamp"], data.get("date")

def usd_to_target(amount_usd):
# Convert a USD amount to TARGET_CCY via Convert endpoint
url = f"{BASE_URL}/convert"
params = {
"access_key": API_KEY,
"from": "USD",
"to": TARGET_CCY,
"amount": str(amount_usd)
}
r = requests.get(url, params=params, timeout=10)
r.raise_for_status()
data = r.json()
if not data.get("success") or "result" not in data:
raise RuntimeError(f"Unexpected convert payload: {data}")
return Decimal(str(data["result"])), data["info"]["timestamp"]

def price_per_gram_in_usd():
usdxau, ts, date = get_latest_usdxau()
usd_per_gram = (usdxau / TROY_OUNCE_TO_G).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
return usd_per_gram, ts, date

def price_per_gram_in_target_with_fees(tax_pct=3.0, making_charge_per_g=0.0, city_premium_pct=0.0):
usd_per_g, ts, date = price_per_gram_in_usd()
# Convert USD per gram to local currency
target_amount, fx_ts = usd_to_target(usd_per_g)
base_per_g = target_amount

# Apply local adjustments
tax_multiplier = Decimal(1) + Decimal(tax_pct) / Decimal(100)
city_premium_multiplier = Decimal(1) + Decimal(city_premium_pct) / Decimal(100)
final_per_g = (base_per_g * tax_multiplier * city_premium_multiplier + Decimal(making_charge_per_g)) \
.quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)

return {
"base_per_g_target_ccy": str(base_per_g),
"final_per_g_target_ccy": str(final_per_g),
"currency": TARGET_CCY,
"gold_purity": "24k (999)",
"latest_date": date,
"latest_timestamp": ts,
"fx_timestamp": fx_ts
}

if __name__ == "__main__":
quote = price_per_gram_in_target_with_fees(
tax_pct=3.0, # example GST or VAT percentage
making_charge_per_g=0, # add your numeric making charge per gram
city_premium_pct=0.0 # add a city premium if applicable
)
print(quote)

Notes:

  • We deliberately use USDXAU to minimize rounding from inversion.
  • All timestamps should be treated as UTC. Convert them to local time in your UI layer.
  • Apply local add-ons outside of the raw commodity price so you can audit markup components.

One more way: Convert endpoint for commodity sizing

If your workflow is “how much gold does this amount buy,” you can call Convert with from=USD, to=XAU and an amount. This returns troy ounces for the amount, which you can then convert to grams if you wish to present weight-based purchase capacity for Pune users.

For Convert parameters and field names, use the endpoint docs. When in doubt about symbol availability or naming, confirm on Supported Symbols.

Units, purity, and practical gotchas

  • Troy ounces vs grams: All XAU prices are per troy ounce by default. Multiply or divide by 31.1034768 to convert between ounces and grams.
  • 24k purity: 24k is 99.9% pure gold. If you later list 22k/18k, apply purity factors or use the Carat endpoint (see docs) to retrieve carat-specific rates directly.
  • Base currency: Latest responses are by default base=USD. rates.XAU means ounces per 1 USD; rates.USDXAU means USD per ounce.
  • Timestamps/timezone: Treat timestamps as UTC. Show last-updated in your UI and cache accordingly.
  • Caching: Many retail updates don’t need tick-by-tick refresh. Cache responses for a few minutes to reduce calls and page load latency. Also cache the Convert result for the same TTL so your per-gram price and FX stay in sync.
  • Weekends/holidays: Markets can be less liquid or closed. Latest still serves the most recent available price. Consider graying the UI when the timestamp is stale beyond your SLA.
  • Outages/fallbacks: Keep the previous successful price cached with a visible “as of” time. Alert if no fresh price after a threshold.
  • Rounding: For per-gram retail display, round to 2 decimal places in the display currency. Keep internal calculations at higher precision to avoid cumulative errors.

Production design for Pune storefronts and apps

To ship a reliable Pune 24k per-gram feed, structure your pipeline as:

  1. Fetch Latest (XAU, USDXAU) and compute USD/gram.
  2. Convert USD/gram to your display currency via Convert.
  3. Apply local taxes and charges in an auditable layer.
  4. Serve to frontends via your own cached API with ETag/If-Modified-Since to minimize re-computation.

Enhancements you may consider:

  • Use the Carat endpoint (see docs) to support 24k, 22k, 18k directly in your catalog if you sell multiple purities.
  • Wire an internal monitor to validate that USDXAU × XAU ≈ 1 within a tolerance to catch data drift.
  • Log the Metals-API timestamp with each price you store so charts and order audit trails match the exact feed moment.

Why XAU is the digital backbone for local 24k price discovery

Modern retail gold pricing in cities like Pune benefits from a digital-first stack. By anchoring on XAU, you tap into an objective, machine-readable benchmark. From there, you compute per-gram prices, overlay fintech-grade FX conversion, and add localized components in a transparent manner. This unlocks data analytics (e.g., markup tracking), automated repricing, and consistent user experiences across mobile and POS terminals.

For teams building digital asset features or gold-linked wallets, the same inputs can drive NAV calculations, hedging dashboards, or smart order routing. Use Latest for intraday updates and Convert for cross-currency operations while persisting audit-critical fields (timestamp, base, and unit).

Validation tips and references

  • Cross-check units by verifying that 1 / rates.XAU approximates rates.USDXAU.
  • Sanity-check your per-gram math using the ounce-to-gram constant and a calculator routine.
  • If you display market context, consult recognized references such as the LBMA and the CME Group metals overview.

Security, deployment, and operations

  • Store your API key securely (server-side only). Do not expose it to browsers.
  • Rate control: batch your symbol requests where possible (request XAU and USDXAU together), and use caching to throttle frequency.
  • Retries: implement exponential backoff and circuit-breaking. Fall back to the last known good price with a visible “as of” timestamp.
  • Versioning: track response schema changes by validating required fields (“success”, “base”, “rates”, “USDXAU”).

Where to find symbols and keys

Not sure which currency codes to convert into? Check the authoritative list on Metals-API Supported Symbols.

If you need an API key or want to explore managed options, use these official entry points:

  • Register to obtain your API key and start integrating.
  • Explore deployment options in MCP if you prefer managed connectivity.

For endpoint semantics, parameters, and examples beyond the scope of this article, see the Documentation.

FAQ

How do I get “per gram” if the API gives ounces?
Use USDXAU (USD per ounce) from Latest, then divide by 31.1034768 to get USD per gram. Convert that USD/gram to your local currency via the Convert endpoint.

Which field is “USD per ounce” — XAU or USDXAU?
USDXAU is USD per ounce. XAU is the inverse (ounces per USD). Prefer USDXAU for direct per-gram math to avoid rounding during inversion.

How do I support 22k or 18k gold?
Either multiply the 24k per-gram by a purity factor in your app or use the Carat endpoint referenced in the docs to retrieve carat-specific rates. Keep retail charges separate for transparency.

Why does the price not change on weekends?
When markets are closed or liquidity is thin, the latest snapshot may remain unchanged. Use the timestamp to show “as of” and consider caching plus UI hints when the price is older than your SLA.

What’s the best way to reduce API calls?
Batch symbols (XAU and USDXAU together), apply short-lived caching (e.g., a few minutes), and reuse the same TTL for FX Convert so the commodity and FX legs stay aligned.

If you’re ready to ship Pune 24k per-gram pricing backed by live XAU data, get your key at Register and review parameters in the Documentation. For symbol lookups and deployment options, check Symbols and MCP.