Skip to main content

On This Page

Building a Movie Search App with Python and Streamlit: A Practical Guide

2 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

🎬 Building a Movie Search App with Python + Streamlit (Using OMDb API)

Sabin Sim built a movie search app using Python and Streamlit, leveraging the OMDb API to fetch detailed movie data with a simple API key. The project includes both console and web interfaces for querying movie details.

Why This Matters

The OMDb API requires proper error handling for missing data and authentication, which are common pitfalls in API integration. Failing to manage these can lead to broken user experiences, as seen in 8-hour App Engine outages caused by unhandled API errors in 2012. This project demonstrates practical solutions for robust API usage.

Key Insights

Working Example

# Console version (movie_app.py)
import requests
API_KEY = "YOUR_API_KEY"
title = input("Movie title: ")
url = f"https://www.omdbapi.com/?t={title}&apikey={API_KEY}"
response = requests.get(url)
if response.status_code != 200:
    print("Error fetching data.")
    exit()
data = response.json()
if data["Response"] == "False":
    print("Movie not found.")
    exit()
print("=== Movie Info ===")
print("Title:", data["Title"])
print("Year:", data["Year"])
print("Genre:", data["Genre"])
print("Plot:", data["Plot"])
print("Rating:", data["imdbRating"])
# Streamlit version (movie_app_streamlit.py)
import streamlit as st
import requests
st.title("🎬 Sabin's Movie Search App")
API_KEY = "YOUR_API_KEY"
title = st.text_input("Enter movie title:", "Inception")
if st.button("Search"):
    url = f"https://www.omdbapi.com/?t={title}&apikey={API_KEY}"
    response = requests.get(url)
    if response.status_code != 200:
        st.error("Error fetching data.")
    else:
        data = response.json()
        if data["Response"] == "False":
            st.warning("Movie not found.")
        else:
            st.subheader(f"{data['Title']} ({data['Year']})")
            if data["Poster"] != "N/A":
                st.image(data["Poster"], width=300)
            else:
                st.info("No poster available.")
            st.write(f"Genre: {data['Genre']}")
            st.write(f"Rating: ⭐ {data['imdbRating']}")
            st.write(f"Plot: {data['Plot']}")

Practical Applications

  • Use Case: Beginner developers learning API integration and UI design
  • Pitfall: Forgetting to handle API rate limits or missing keys, which causes runtime errors

References:

Continue reading

Next article

Pixlore — A Web-to-Figma Engine That Bridges UI, Code, and Product Workflows

Related Content