EZRate
Sign in

Securing Financial API Keys in Web and Mobile Apps: Proxies, Restrictions and Rotation

Best practices for securing financial API keys: why front-end and mobile apps cannot hide secrets, backend proxies, IP restrictions, rotation and monitoring.

Arian Asadi
· Writer and Market Analyst
Published 5 November 2026, 20:00 · 2 min read
Securing Financial API Keys in Web and Mobile Apps
Key takeaways
  • Anything shipped to a browser or app binary can be extracted; a secret key there is a public key.
  • Call the API from your server and expose only your own, cached endpoint to clients.
  • Add IP or domain restrictions, rotate keys, monitor usage and scan repositories for leaked secrets.

API keys for financial data are valuable: they carry a quota, sometimes a paid plan, and they identify you. Yet the most common integration mistake is pasting the key into JavaScript or a mobile app. This guide covers securing financial API keys properly — not by obfuscation, but by architecture.

i
EZRate API
This guide uses the EZRate currency and gold price API: full documentation, code samples and a free key are on the API page.
★
Short answer
Never ship a secret API key in browser code or a mobile binary — it can be extracted in minutes. Put the key on your server, call the API from there, cache the result and expose your own endpoint to clients. In the EZRate panel, restrict the key to your server IPs (or domains), rotate it if exposed, and watch usage. For public widgets, use EZRate’s embeddable widgets, which need no key.

Part of the Iranian Rial exchange rate API guide.

Why client-side secrets fail

Where you put the keyHow it leaks
JavaScript bundleView source, DevTools → Network, the request header itself
Environment variable in a front-end buildIt is inlined into the bundle at build time
Android APK / iOS IPADecompilers and string extraction; traffic interception
“Obfuscated” stringReversible; the decoded value is visible in the request anyway
Public Git repositoryBots scan new commits for secrets within minutes

The rule is simple: if the client can send the key, an attacker can read it.

The backend proxy pattern

javascript
// Express example
import express from "express";
const app = express();
let cache = { at: 0, body: null };

app.get("/api/rates", async (_req, res) => {
  if (Date.now() - cache.at > 60_000) {
    const r = await fetch("https://api.ezrate.me/v1/rates?symbols=usd,eur,g18",
      { headers: { "X-API-Key": process.env.EZRATE_KEY } });
    if (r.ok) cache = { at: Date.now(), body: await r.json() };
  }
  if (!cache.body) return res.status(503).json({ error: "unavailable" });
  res.set("Cache-Control", "public, max-age=30").json(cache.body);
});

app.listen(3000);

Your proxy is also the right place to add your own rate limiting, so a scraper hitting your endpoint cannot drain your upstream quota.

Mobile apps

  • The app calls your backend, never the provider directly.
  • Authenticate your own users (or use device attestation such as Play Integrity / App Attest) to make abuse of your endpoint harder.
  • Cache on the device and refresh at most once a minute.

See the full mobile build in Flutter & React Native FX tracker.

Restrictions, rotation and monitoring

ControlWhat to do
IP restrictionAllow only your server IPs for the key; requests from elsewhere get 403 forbidden
Domain restrictionFor browser-origin use cases, restrict to your domains
Separate keysOne key per environment and per app; revoke one without breaking others
RotationCreate a new key, deploy it, then delete the old one
MonitoringCheck /usage and the X-RateLimit-Remaining-* headers; alert on unusual spikes
Secret scanningEnable GitHub secret scanning or pre-commit hooks (gitleaks)
bash
# usage does not count against your quota
curl -s -H "X-API-Key: $EZRATE_KEY" https://api.ezrate.me/v1/usage | jq

If a key leaks

  1. Create a new key in the panel and deploy it.
  2. Delete the leaked key.
  3. Remove it from Git history if it was committed (rotation is still required).
  4. Review usage for the leak period.

No key at all: widgets

For a public ticker or table on a website, EZRate’s embeddable widgets load data without any API key, are cached and include attribution. That is the safest option when you do not need raw data.

US Dollar265,200Toman−0.45%

A note on environment variables

Environment variables are the right place for server-side secrets, but in front-end frameworks variables with public prefixes (NEXT_PUBLIC_, VITE_, NUXT_PUBLIC_) are compiled into the browser bundle. Keep financial keys in variables without those prefixes and read them only in server code such as API routes or server middleware.

Related live rates: US dollar rate, 18K gold price, Emami coin price.

Can I hide an API key in front-end JavaScript?
No. Anything the browser sends can be read. Call the API from your server instead.
Is a key in a mobile app safe?
No. App binaries can be decompiled and traffic intercepted; use a backend proxy.
What does a 403 forbidden mean?
The request came from an IP or domain not allowed for that key.
How do I check if my key is being abused?
Watch /usage and the rate-limit headers, and alert on unusual spikes.
Arian Asadi
I studied economics and developed an interest in financial markets, exchange rates, and economic developments during my university years. Throughout my professional career, I have focused particularly on foreign exchange markets, gold, international money transfers, and the impact of economic developments on prices. In the articles I write, I strive to present information about exchange rates and financial markets in a clear and accessible way, based on verifiable data and market trends. My goal is to help readers gain a clearer understanding of market conditions before making decisions about buying, selling, or transferring currencies.
All posts by author →

Comments (0)

Comments are shown after review. Sign-in is needed to send.

Related

API & Developers
Flutter Currency Tracker Tutorial (plus React Native): Build an Iranian Gold and FX App
API & Developers
React Currency Converter for Live Toman Rates, with a Secure Backend Proxy
API & Developers
Laravel Exchange Rate API Tutorial: Live Iranian Rates with Http Client, Redis Cache and a Scheduler