USD to INR API in Python: Live and RBI Reference Rates
Most Indian apps that deal with dollars need two different USD to INR numbers. A live rate for prices, checkouts and dashboards, and the RBI reference rate for anything an accountant or auditor will look at: export invoices, book closing, reports. This guide gets both in Python, plus a rate for any past date and a daily history in pandas.
Which rate do you need?
| Live mid-market rate | RBI reference rate | |
|---|---|---|
| Updates | Every minute | Once per Mumbai business day, around 13:30 IST |
| Use for | Pricing, checkout, conversion widgets, dashboards | Invoices, accounting, month-end, audit trails |
| API key | Free key | Latest table: no key. Past dates: free key |
| Endpoint | /api/v1/rates | /api/open/central-bank/rbi, /api/v1/central-bank/rbi/… |
1. Today's RBI reference rate (no API key)
The quickest start. No sign-up, standard library only:
import json, urllib.request
url = "https://allratestoday.com/api/open/central-bank/rbi?source=USD&target=INR"
data = json.load(urllib.request.urlopen(url))
print(data["rate_date"], data["rate"]) # e.g. 2026-10-15 95.0691 Every response carries rate_date, the day the RBI published the figure. Store it next to the rate, so you can always show which day's rate a number came from. Since July 2018 the figure is computed by Financial Benchmarks India Ltd (FBIL) and listed in the RBI's Reference Rate Archive, so the RBI and FBIL reference rates are the same number.
2. The live USD to INR rate
For a rate that moves during the day, use /api/v1/rates with a free API key. Keep the key in an environment variable, never in your code:
import os, requests
API = "https://allratestoday.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['ALLRATESTODAY_API_KEY']}"}
r = requests.get(f"{API}/rates", params={"source": "USD", "target": "INR"}, headers=HEADERS, timeout=10)
r.raise_for_status()
print(r.json()[0]["rate"]) # e.g. 94.6739 Need several currencies? Pass them comma-separated, target=INR,EUR,GBP,AED. That is still one request against your quota.
Convert an amount
Add amount and the response becomes a conversion:
r = requests.get(f"{API}/rates", params={"source": "USD", "target": "INR", "amount": 1500}, headers=HEADERS, timeout=10)
print(r.json()["to"]["amount"]) # e.g. 142010.85 For money, keep the result as a Decimal and round once, at the end: Decimal(str(value)).quantize(Decimal("0.01")). Rounding at every step adds up to visible paise differences on long invoices.
3. The RBI rate for a past date
Invoices and books need the rate for a specific day, not today's. Put the date in the path:
r = requests.get(f"{API}/central-bank/rbi/2026-09-30", params={"source": "USD", "target": "INR"}, headers=HEADERS, timeout=10)
d = r.json()
print(d["rate_date"], d["rate"], d["published_on_requested_date"])
# 2026-09-30 95.9832 True Ask for a Sunday and you get Friday's rate with published_on_requested_date: false. The RBI publishes nothing on weekends and Mumbai bank holidays, and the API never makes up a number for those days.
4. A daily history in pandas
For charts, back-testing or re-valuing a ledger, pull a range in one call:
import pandas as pd
r = requests.get(
f"{API}/central-bank/rbi/history",
params={"source": "USD", "target": "INR", "from": "2026-01-01", "to": "2026-09-30"},
headers=HEADERS, timeout=30,
)
df = pd.DataFrame(r.json()["rates"])[["date", "rate"]]
df["date"] = pd.to_datetime(df["date"])
print(df.tail())
print("Month-end:", df.groupby(df["date"].dt.to_period("M"))["rate"].last()) History is billed by volume: one request per currency per month of data. The response tells you the cost in billed_requests. The RBI series goes back to 2003. Add format=csv or format=xlsx to get a file instead of JSON.
5. Production checklist
- Cache. The RBI rate changes once a day, so fetch it once after 13:30 IST and store it. Cache live rates for as long as your use case allows; a minute is plenty for pricing pages.
- Timeouts and a fallback. Always pass
timeout=. If a call fails, keep showing the last stored rate with its date rather than failing the page. - Store the date with the rate. An invoice line should keep the rate, its
rate_dateand the source (live or RBI), so the number can be traced later. - Server side only. Call the keyed endpoints from your backend. Never ship the API key in a mobile app or browser bundle.
FAQ
Which USD to INR rate should my app use?
Use the live mid-market rate for prices, checkout and dashboards, because it moves through the day. Use the RBI reference rate when the number has to match an official source, such as invoices, book closing or reports that an auditor will check. It is published once per Mumbai business day and does not change afterwards.
Do I need an API key?
Not for the latest RBI reference rate: the open endpoint needs no key. The live mid-market rate, past dates and history need a free API key, which includes 300 requests.
Why is the live rate different from the RBI rate?
They measure different things. The live rate is the current mid-market price and changes every minute. The RBI reference rate is a single fixing computed by FBIL around 13:30 IST each business day. A gap of a few paise to a rupee is normal.
What happens if I ask for a weekend date?
There is no RBI rate on Saturdays, Sundays or Mumbai bank holidays. The API returns the last published rate before that date and labels it with its real rate_date, so you can see which day it came from.
Get your free API key
Live rates for 160+ currencies and official rates from 121 central banks. 300 free requests, no credit card.
Get your free API key