Nickel (NI) - Per Troy Ounce Convert API: developer guide for integration in backend services

Metals-API 10 min read
Nickel (NI) - Per Troy Ounce Convert API: developer guide for integration in backend services

You need to price nickel in USD per troy ounce inside a backend service and reliably convert between ounces, grams, and currencies. By the end of this guide, you’ll fetch live Nickel (NI) rates, derive USD/oz from the API’s oz-per-USD base, execute on-demand conversions, and productionize the workflow with caching and fallbacks.

What we’re building

This guide focuses on two endpoints that cover the majority of backend pricing needs for Nickel (NI):

Illustration: Nickel (NI) - Per Troy Ounce Convert API: developer guide for integration in backend services
  • Latest: fetch the current NI quote with both oz-per-USD and USD-per-oz forms.
  • Convert: convert an arbitrary amount (e.g., USD to NI troy ounces, or NI to USD) on demand.

We’ll keep the scope tight to Nickel (NI) priced per troy ounce for accurate SKU pricing, hedging logic, or research ETL jobs. For other endpoints like intraday, historical, time series, and OHLC, see the Documentation.

Symbols, units, and inversion: Nickel (NI) per troy ounce

Metals-API quotes metals in a base of USD by default. That means:

  • rates.NI = troy ounces of Nickel you get per 1 USD (oz/USD).
  • rates.USDNI = USD per troy ounce of Nickel (USD/oz).

This “inversion” is intentional and powerful. When your base is USD, ounces-per-USD makes certain relative conversions efficient. For backend pricing, you usually want USD per troy ounce, so use rates.USDNI directly—no manual inversion needed.

Units matter:

  • Metals are quoted per troy ounce. 1 troy ounce ≈ 31.1034768 grams. Do not mix with avoirdupois ounces.
  • If your catalog stores grams or kilograms, convert from troy ounces before applying your price logic.

Find symbols and their definitions on the Symbols page. Nickel is NI. If you need to expand beyond NI later, confirm the exact symbol codes first.

Latest: get Nickel now (and why USDNI is your friend)

Use the latest endpoint with both NI and USDNI to keep your service flexible. Below is a ready-to-run curl example. Replace YOUR_API_KEY with your key.

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

Official sample response for Nickel (copy-pasteable for testing and parsing):

{"success":true,"timestamp":1792023000,"date":"2026-10-15","base":"USD","rates":{"NI":2.0808167756132,"USD":1,"USDNI":0.4805805161318483}}

How to read these fields

  • success: Boolean indicating the call worked.
  • timestamp: Unix time (seconds) in UTC for when the rate snapshot was produced. Convert in your service to guard stale data.
  • date: The ISO date tied to the snapshot.
  • base: USD (default). All symbols are expressed relative to this base.
  • rates.NI: troy ounces of nickel per 1 USD (oz/USD).
  • rates.USDNI: USD per troy ounce of nickel (USD/oz). Use this directly for pricing a SKU per ounce or for converting weights to price.

Update cadence: depending on your plan, latest can update on a schedule (for example, every 60 or 10 minutes). Use caching to minimize calls and smooth brief rate jitters. Details are in the Documentation.

Convert: compute NI ounces from USD (and the other way around)

When you need an exact one-off amount conversion—say, how many troy ounces of Nickel you can buy for a given USD budget—call the convert endpoint. This is particularly useful in checkout flows, hedging orders, or alerts that convert thresholds between units.

Example (convert 10,000 USD to troy ounces of NI):

curl "https://metals-api.com/api/convert?access_key=YOUR_API_KEY&from=USD&to=NI&amount=10000"

The convert endpoint returns a structure with the query, a timestamped rate, the result, and unit context. For field-level details, see the API Documentation. Use convert when precision for a specific amount matters (e.g., accounting, fulfillment). For high-throughput quote displays, use latest + local math.

Production-grade Python example: price per ounce, per gram, per kg

This example pulls NI and USDNI, computes price per gram and kilogram, and shows a simple cache strategy. It assumes UTC-aware scheduling and that downstream consumers want USD/oz as the canonical figure.

import os
import time
import math
import requests

API_KEY = os.getenv("METALS_API_KEY", "YOUR_API_KEY")
LATEST_URL = "https://metals-api.com/api/latest"

# Simple in-memory cache (replace with Redis or your config store in prod)
_cache = {"ts": 0, "ttl": 45, "payload": None} # ttl in seconds

def get_latest_ni():
global _cache
now = time.time()
if _cache["payload"] and (now - _cache["ts"] < _cache["ttl"]):
return _cache["payload"]

params = {
"access_key": API_KEY,
"base": "USD",
"symbols": "NI,USDNI,USD"
}
resp = requests.get(LATEST_URL, params=params, timeout=10)
resp.raise_for_status()
data = resp.json()

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

# Cache the successful payload
_cache["payload"] = data
_cache["ts"] = now
return data

def nickel_prices():
data = get_latest_ni()
ts = data["timestamp"] # seconds since epoch (UTC)
usd_per_oz = data["rates"]["USDNI"] # USD per troy ounce
oz_per_usd = data["rates"]["NI"] # troy ounces per 1 USD

TROY_OUNCE_TO_GRAM = 31.1034768
usd_per_gram = usd_per_oz / TROY_OUNCE_TO_GRAM
usd_per_kg = usd_per_gram * 1000.0

return {
"timestamp": ts,
"usd_per_oz": usd_per_oz,
"usd_per_gram": usd_per_gram,
"usd_per_kg": usd_per_kg,
"oz_per_usd": oz_per_usd
}

def convert_usd_to_ni_oz(usd_amount):
# Inline conversion via latest to avoid an extra API request.
# If you require an authoritative conversion for audit, call /api/convert.
px = nickel_prices()
oz = usd_amount / px["usd_per_oz"]
return oz

def convert_grams_to_usd(grams):
px = nickel_prices()
return grams * px["usd_per_gram"]

if __name__ == "__main__":
px = nickel_prices()
print(f"Nickel (NI) price: ${px['usd_per_oz']:.6f}/oz, ${px['usd_per_gram']:.6f}/g, ${px['usd_per_kg']:.2f}/kg; ts={px['timestamp']}")
print("Buy with $1000:", f"{convert_usd_to_ni_oz(1000):.6f}", "troy ounces")
print("Cost of 250 g:", f"${convert_grams_to_usd(250):.2f}")

Key implementation notes

  • Use rates.USDNI for direct USD/oz. Only invert if USDNI is not requested.
  • Cache brief intervals (e.g., 30–60 seconds) to reduce load and smooth temporary network issues. Align with your plan’s update interval.
  • Timestamps are UTC. Store and compare them consistently in your service to detect stale data and to annotate downstream logs/quotes.
  • Choose a deterministic rounding strategy for grams and kilograms. Financial rounding to 2–4 decimals might be too coarse for grams; record the raw floating value in audit logs.

Handling market hours, weekends, and stale data

Metals trading follows market hours and may be thinner or paused on weekends/holidays. Practical implications for your backend:

  • Expect fewer or no updates when markets are closed. The latest endpoint will still return the most recent known snapshot.
  • Display “as of” timestamps near prices in user-facing apps.
  • Implement a fallback chain: latest → cached → last-known-good (persisted in DB). Alert on unusually old snapshots.
  • Batch downstream jobs (e.g., reprice SKUs hourly) rather than pulling on every request.

When to use Latest vs Convert

  • Use Latest when you need the current price and will compute multiple derived values locally (e.g., USD/oz, USD/g, USD/kg, basket pricing).
  • Use Convert for precise one-off amount conversions that you may need to store alongside a timestamp, especially for audit or event-triggered flows (orders, hedges, or notifications).

Both endpoints are documented here: Metals-API Documentation. If you plan to expand symbols or currencies, confirm codes in Metals-API Supported Symbols.

Integrating Nickel into pricing engines and data pipelines

Common backend patterns for NI include:

  • Dynamic catalog pricing: Compute USD/oz and convert to price per gram for fine-featured SKUs. Store a rate snapshot and a unit label to prevent unit confusion later.
  • Hedging calculators: Use latest+convert to size orders in ounces based on budget (USD → NI), then record the timestamped conversion for reconciliation.
  • ETL and research: Snapshot USDNI on a fixed schedule into your warehouse. Add derived columns (USD/g, USD/kg) and an as_of timestamp for time-series analysis.

Consider mapping NI rates into a broader materials-costing service if you work in manufacturing or jewelry where nickel content affects bill-of-materials. Digital transformation here means centralizing unit-safe pricing, applying consistent rounding rules, and making rates auditable and reproducible across services.

Data quality, validation, and alerts

  • Outlier detection: Compare the latest USDNI to your trailing average and set percent thresholds for alerts. Pause automated repricing when thresholds are exceeded.
  • Unit validation: Assert that your code paths never mix troy ounces with grams without explicit conversion. Include unit in function names and variable labels.
  • SLOs: Track success flags and HTTP latencies. If success=false or latency spikes, fail open to cached data and log the incident.

Operational tips that save time

  • Version your pricing schema so you can rotate rules (rounding, fees, spreads) without breaking consumers.
  • Use a small-timebox retry on 5xx network errors; do not hammer with large retry storms. Back off and serve cached prices.
  • Persist the raw API payload alongside your computed fields. It’s invaluable for audit and debugging.
  • Document your unit conventions in your repo’s README and embed assertions around conversions (oz ↔ g ↔ kg).

Nickel and smart technology integration

Nickel sits at the intersection of battery tech, stainless steel, and energy transition supply chains. Clean unit conversions in your backend let product teams experiment with pricing models across ounces, grams, and kilograms without risk. With an API-first approach, you can route NI pricing into ERP, e-commerce, or trading tools, and unlock analytics that test spreads, cost-plus formulas, or budget allocation in real time.

For industry context, check official market resources like the London Metal Exchange’s nickel pages: LME Nickel contract specifications. Verify instrument conventions, but always treat Metals-API symbols and units as the source of truth for your integration.

Security, keys, and environment management

  • Store your Metals-API key in a secure secret manager. Never hardcode it.
  • Separate keys across environments (dev/staging/prod) to avoid quota coupling.
  • Log the request ID and timestamp when persisting rates to enable traceability across services.

You can create and manage API keys via Register and explore managed compute options at MCP. You can also review the homepage for platform overview at metals-api.com.

Testing your integration

  • Snapshot tests: Freeze the official sample response shown above and assert your parser produces the expected USD/oz and g/kg derivatives.
  • Clock skew: Use UTC in your tests. Compare API timestamp to your server’s clock and assert acceptable deltas.
  • Failure injection: Simulate network timeouts, 429s, and response with success=false. Ensure your fallback and alerting paths work.

Keep a runbook with curl commands for on-call engineers. For example, your on-call can verify live NI data via latest and, when necessary, confirm a precise conversion via convert.

Quick reference: core fields you’ll use

  • rates.USDNI → USD per troy ounce (canonical for SKU pricing).
  • rates.NI → troy ounces per USD (convenient for budget-to-ounces sizing).
  • timestamp/date → annotate your prices “as of” these values; treat them as UTC.

If you later expand to historical charts or analytics, add the relevant endpoints from the Documentation. Always confirm symbol availability on Symbols.

FAQ

Q: Which field is USD per troy ounce for Nickel?
A: Use rates.USDNI. With base=USD, rates.NI is oz per USD; rates.USDNI is the direct USD/oz you need for pricing.

Q: How do I show price per gram?
A: Divide USD/oz by 31.1034768 (grams per troy ounce). For kilograms, multiply the gram price by 1000.

Q: How should I handle weekends or holidays?
A: Expect the latest snapshot to remain unchanged when markets are closed. Display “as of” timestamps and serve cached or last-known-good values if updates pause.

Q: Should I call convert for every price display?
A: No. Fetch latest periodically and compute local conversions (USD/oz, USD/g, USD/kg). Use convert for precise, auditable, amount-specific conversions (e.g., USD → NI ounces for a transaction).

Q: Where can I confirm the NI symbol and other supported tickers?
A: Check the Supported Symbols page. Integrations should not assume symbols—always verify first.

Get your API key and wire this into your backend in under an hour. Create an account at Register, read the endpoint specifics in the Documentation, and explore managed compute options via MCP. For a platform overview, visit metals-api.com.