How to Get the Uruguayan Peso (UYU) - N/A Price using a REST API endpoint

Metals-API 8 min read
How to Get the Uruguayan Peso (UYU) - N/A Price using a REST API endpoint

You need a reliable Uruguayan Peso (UYU) rate for pricing, reporting, or settlement, and you want to fetch it programmatically. By the end of this guide, you will pull the latest UYU quotes with a REST call, interpret UYU vs USDUYU correctly, and convert amounts between USD and UYU using Metals-API.

What “UYU price” means in Metals-API terms

Metals-API returns exchange rates relative to a base currency (by default USD). For currencies, you’ll typically use these two symbols together:

Illustration: How to Get the Uruguayan Peso (UYU) - N/A Price using a REST API endpoint
  • UYU — number of Uruguayan pesos per 1 USD.
  • USDUYU — number of US dollars per 1 UYU.

This mirrors how metals are often quoted both ways (e.g., XAG vs USDXAG). Using both symbols together helps you avoid manual inversion and rounding error.

Symbol Meaning when base=USD Use it for
UYU UYU per 1 USD Converting USD amounts into pesos
USDUYU USD per 1 UYU Converting pesos into USD without inverting yourself

Confirm the exact code(s) you need on the Metals-API Supported Symbols page.

Fetch the latest UYU and USDUYU in one call

The Latest Rates endpoint returns current quotes (update frequency depends on plan). Request UYU and USDUYU together so you have both directions ready for calculations.

curl "https://metals-api.com/api/latest?access_key=YOUR_API_KEY&symbols=UYU,USDUYU,USD"

Example response you can expect to parse (official sample):

{"success":true,"timestamp":1792195740,"date":"2026-10-17","base":"USD","rates":{"UYU":40.1862695,"USD":1,"USDUYU":0.024884121179747722}}

What the fields mean and how you’ll use them

  • success: Boolean indicating the call worked.
  • timestamp: Unix time (seconds). Useful for cache control, charting, and audit logs.
  • date: UTC calendar date for the snapshot.
  • base: Quote base (USD by default). Keep this in your downstream metadata.
  • rates.UYU: UYU per 1 USD — multiply USD amounts by this to get pesos.
  • rates.USDUYU: USD per 1 UYU — multiply UYU amounts by this to get dollars.
  • rates.USD: Always 1 when base is USD, handy as a sanity check.

Reference the Metals-API Documentation for optional parameters and plan-based capabilities like update intervals.

Convert endpoint: compute exact amounts in UYU

If you prefer the API to perform the math (and rounding) for you, use the Convert endpoint. This is useful for checkout totals, settlements, or fee calculations where you want server-side conversion on a specific amount.

curl "https://metals-api.com/api/convert?access_key=YOUR_API_KEY&from=USD&to=UYU&amount=1500"
  • from: The source currency code (e.g., USD).
  • to: The target currency code (e.g., UYU).
  • amount: The numeric value to convert.

Tip: You can also reverse it for refunds or settlements coming in UYU:

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

When you need to trace live mechanics or check supported parameters, see the Convert section of the Documentation.

Python example: pull UYU rates and convert both ways

This snippet calls the Latest Rates endpoint, extracts UYU and USDUYU, and performs conversions. It also demonstrates basic caching strategy based on timestamp.

import os
import time
import requests

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

params = {
"access_key": API_KEY,
"symbols": "UYU,USDUYU,USD"
}

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}")

timestamp = data["timestamp"] # seconds since epoch (UTC)
as_of_date = data["date"]
base = data["base"]

uyu_per_usd = data["rates"]["UYU"] # e.g., 40.18... UYU per 1 USD
usd_per_uyu = data["rates"]["USDUYU"] # e.g., 0.02488... USD per 1 UYU

# Example conversions
usd_amount = 1250.00
uyu_amount = usd_amount * uyu_per_usd

incoming_uyu = 350000.0
settlement_usd = incoming_uyu * usd_per_uyu

print(f"As of {as_of_date} (timestamp {timestamp}) base={base}")
print(f"USD -> UYU: {usd_amount} USD = {uyu_amount:.2f} UYU")
print(f"UYU -> USD: {incoming_uyu:.0f} UYU = {settlement_usd:.2f} USD")

# Naive cache: if data is less than 10 minutes old, skip refreshing
CACHE_TTL = 600
if time.time() - timestamp < CACHE_TTL:
print("Using cached rates (fresh < 10 minutes).")
else:
print("Consider refreshing rates now.")

For production, externalize the cache (Redis/memcached), validate all required symbols are present before computing, and log the timestamp plus the exact symbols used so downstream analytics can reconcile values quickly.

Practical details that save time

  • Base currency: When base=USD (default), rates.UYU is UYU per USD. If you change the base, reinterpret the rates accordingly. Keep the base value with each stored quote.
  • Inversion: Prefer requesting USDUYU rather than inverting UYU yourself. Inversion introduces rounding drift across workflows (pricing, fees, refunds).
  • Timestamps and timezone: date is a UTC date; timestamp is Unix epoch seconds (UTC). Use timestamp for cache-control and reconciliation; don’t assume local time.
  • Caching: Align cache TTL with your plan’s update frequency. Many use 60s–10m TTLs depending on volatility tolerance and quota. Cache both the raw response and the derived calculations you reuse (e.g., checkout totals).
  • Weekends/market closures: Currency markets can be quieter on weekends/holidays; if you see unchanged timestamps across requests, rely on your cache to avoid redundant calls and explicitly surface “as of” to end users.
  • Units: Metals responses include “unit” like “per troy ounce.” Currency responses won’t include that field; interpret rates as “per 1 base unit.” For metals plus UYU cross-quoting, normalize units before combining data.
  • Precision: Use Decimal for monetary calculations to avoid float rounding issues when converting between USD and UYU at scale.
  • Symbol validation: Always verify codes on the Symbols page to prevent symbol typos from causing empty rate maps.

Common integration patterns for UYU

E-commerce pricing and checkout

  • Fetch UYU and USDUYU during cart build and cache for the user session.
  • Use Convert endpoint for the final amount to lock rounding to the API’s quote at submission time.
  • Persist the timestamp, rate, and base for audit-ready receipts.

Risk dashboards and monitoring

  • Sample latest UYU/USDUYU on a schedule aligned with your plan interval; avoid over-polling.
  • Trigger alerts when USDUYU crosses operational thresholds that meaningfully impact margins or settlement values.

Reconciling settlements

  • Store both directions (UYU and USDUYU) with timestamp so you can explain any rounding deltas during dispute resolution.
  • When comparing with banking statements, align your timestamp to the booking time and consider adding tolerance bands.

For additional capabilities (historical snapshots, time series, OHLC, bid/ask, etc.), see the relevant sections in the Documentation. Keep this post focused on UYU via Latest and Convert, then add features as your product matures.

Testing, validation and troubleshooting

  • Check your symbols parameter includes exactly what you need: symbols=UYU,USDUYU,USD.
  • If a field is missing in rates, fail fast with a clear error; don’t silently invert or substitute a default.
  • Monitor timestamp drift; if it doesn’t change over multiple polls, your cache may be serving stale data or your plan interval hasn’t rolled over yet.
  • Document your rate provenance: endpoint, symbol list, base, timestamp, and the amount used in any Convert calls.

Security, quotas, and operational hygiene

  • Keep the access_key server-side. For browser-based apps, proxy requests through your backend.
  • Centralize Metals-API calling in one service module to enforce symbol whitelists and caching consistently.
  • Alert on API errors and timeouts; retry with backoff and serve last-known-good values with an “as of” note if needed.

Where to go next

  • Sign up to obtain your API key: Register.
  • Review endpoint specifics, parameters, and plan-based behaviors in the Documentation.
  • Explore your control panel and managed connectivity options at MCP.

Notes on metals context (if you later quote metals in UYU)

Many teams combine currency rates with metals to quote, for example, a metal price in UYU. When doing so:

  • Mind units: metals are returned “per troy ounce.” If your catalog is in grams or kilograms, convert units first, then apply the currency rate.
  • Use synchronized timestamps: fetch currency and metal quotes in the same call window and store both timestamps to reduce temporal basis risk.
  • When quoting or hedging, prefer using both-direction symbols (e.g., USDUYU and a USD-per-ounce metal symbol) to avoid chained inversions.

As you expand, consult the Metals-API site for broader capabilities and integration options.

Additional references

FAQ

Q: Why do I see both UYU and USDUYU?
A: UYU is pesos per USD; USDUYU is dollars per peso. Request both to avoid manually inverting and to keep precision consistent across pricing and refunds.

Q: Which timestamp should I store?
A: Persist the Unix timestamp and the UTC date returned by the API with every computed figure (prices, invoices, settlements). This enables audit trails and reconciliations.

Q: How often should I refresh UYU?
A: Match your polling and cache TTL to your plan’s update interval and business tolerance for FX drift. Many teams cache 1–10 minutes and refresh on material user actions (checkout, quote confirm).

Q: Do I need to change the base from USD?
A: Not usually. Keeping base=USD is straightforward and well-supported. If you change the base, ensure your downstream math and data model reflect the new base consistently.

Q: Can I convert specific amounts without doing the math client-side?
A: Yes. Use the Convert endpoint with from=, to=, and amount=. It returns the computed amount along with the rate used, which is helpful for receipts.

Ready to integrate UYU into your product? Get your API key and start with the Latest and Convert endpoints today: Register. If you need account configuration or managed connectivity, visit MCP.