How to Build a Currency Converter App in Streamlit

Learn how to build a simple currency converter app using Streamlit and the Fixer.io API. A hands-on guide to combining Python, APIs, and UI for real-world use!

๐Ÿ’ก Why Build a Currency Converter?

Weโ€™ve all been there โ€” scrolling through flight deals or ordering something online and wondering: โ€œHow much is that in my currency?โ€ Instead of Googling it every time, letโ€™s build a lightweight currency converter app using Streamlit and Fixer.io API.

It’s quick, it’s useful, and itโ€™s a fantastic intro project to:

  • Calling external APIs
  • Building a real-time UI with Streamlit
  • Handling user input and API data

Ready? Letโ€™s go. ๐Ÿš€


๐Ÿ› ๏ธ What Youโ€™ll Need

Before we dive in, make sure youโ€™ve got the following:

๐Ÿ”ง Prerequisites:

  • Python 3.x installed
  • Streamlit installed (pip install streamlit)
  • A free API key from Fixer.io

๐Ÿ“ฆ Step 1: Install Required Packages

Open your terminal and run:

pip install streamlit requests

These are the only two packages we need โ€” Streamlit for UI, and requests to fetch data from the API.


๐Ÿ”‘ Step 2: Get Your API Key from Fixer.io

  1. Go to https://fixer.io
  2. Sign up for a free account
  3. Copy your API key from the dashboard

Replace the API key in the code below with your own. (Free plan works just fine for basic currency rates.)


๐Ÿง  Step 3: Set Up Your Script

Create a new file, e.g., currency_converter.py, and start by importing the essentials:

import streamlit as st
import requests

Then define your API endpoint:

API_KEY = "your_api_key_here"
URL = f"http://data.fixer.io/api/latest?access_key={API_KEY}"

๐Ÿ”„ Step 4: Fetch Exchange Rates

Weโ€™ll write a function to make a GET request to Fixer and return exchange rates:

def get_exchange_rates():
response = requests.get(URL)
if response.status_code == 200:
data = response.json()
if data.get("success"):
return data["rates"]
else:
st.error("Error fetching exchange rates. Please check your API key.")
else:
st.error("Failed to fetch exchange rates.")
return {}

If all goes well, youโ€™ll get a dictionary of rates like {"USD": 1.12, "INR": 89.2, ...}.


๐ŸŒ Step 5: Create a Currency Name Map

Fixer only returns currency codes (e.g., USD, INR). For a better user experience, map them to readable names:

currency_names = {
"USD": "US Dollar",
"EUR": "Euro",
"SAR": "Saudi Riyal",
"INR": "Indian Rupee",
"GBP": "British Pound",
# ... include as many as needed
}

To keep things clean, only show codes that actually exist in the API response.


๐Ÿงพ Step 6: Build the Streamlit UI

This is where the magic happens โœจ

st.title("Currency Converter")

# User input
amount = st.number_input("Enter amount:", min_value=0.01, value=1.00, format="%.2f")

# Dynamic dropdowns
from_currency = st.selectbox("From Currency:", options=[f"{code} ({name})" for code, name in currency_names.items() if code in fx])
to_currency = st.selectbox("To Currency:", options=[f"{code} ({name})" for code, name in currency_names.items() if code in fx])

๐Ÿ” Step 7: Handle Conversion Logic

When the user hits the Convert button:

if st.button("Convert"):
from_code = from_currency.split(" ")[0]
to_code = to_currency.split(" ")[0]

if from_code in fx and to_code in fx:
converted_amount = round(amount * fx[to_code] / fx[from_code], 2)
st.success(f"{amount} {from_code} = {converted_amount} {to_code}")
else:
st.error("Invalid currency selection. Please try again.")

This takes the input amount, fetches the correct conversion rate, and shows the result.


๐Ÿ“ท (Optional) Step 8: Visual Polish

You can enhance the app further with:

  • Icons or flags using images
  • Charts showing historical trends (Fixer has historical data APIs too)
  • Themes or dark mode (Streamlit has built-in theming)

๐Ÿš€ Run the App

Open a terminal and run:

streamlit run currency_converter.py

๐ŸŽ‰ And voilร  โ€” a fully working currency converter in your browser!


๐Ÿง  Wrap-Up

In this tutorial, we learned how to:

  • Use Fixer.io API to fetch real-time exchange rates
  • Build an interactive Streamlit UI
  • Handle user input and show dynamic results

This is a great beginner project to learn APIs and Streamlit. Want to take it further? Try adding:

  • Currency trend graphs
  • Historical conversions
  • Local caching to improve performance

๐Ÿ™‹ FAQ

โ“ Is Fixer.io free?

Yes! There’s a free tier with hourly updates for EUR base currency.

โ“ Can I change the base currency?

Only with a paid plan โ€” by default, Fixer.io returns rates based on EUR.

โ“ Can I convert to/from cryptocurrencies?

Yes, Fixer supports some crypto like BTC, though updates may be less frequent.


๐Ÿ’ฌ Your Turn!

Did you build this app? Got stuck somewhere or added cool features?

Drop a comment below, or reach out to us at Ossels AI if you want help building real-world AI or data apps like this one.

๐Ÿ”— Also check out our other Python + AI tutorials here

Posted by Ananya Rajeev

Ananya Rajeev is a Kerala-born data scientist and AI enthusiast who simplifies generative and agentic AI for curious minds. B.Tech grad, code lover, and storyteller at heart.