CatAPI is a Streamlit-based web application that fetches and displays random cat images from the Cataas REST API, providing a playful and interactive way to enjoy feline photos right in your browser (Cataas, Streamlit Docs). It leverages Python’s Requests library for HTTP calls, implements rate limiting and retry logic for robust API interaction, and uses Streamlit’s session state to let you save and revisit your favorite cats (Requests, Streamlit Docs).
- Random Cat Images: Retrieve a random cat image on each click using the Cataas
/cat
endpoint and Python’srequests.get
method (PublicAPI, Requests). - Image Customization: Overlay custom text on cats via the Cataas
/cat/says/{text}
endpoint for personalized captions (Cataas). - Rate Limiting & Retries: Enforce a 2-second pause between API calls and retry up to 3 times on failures using Python’s
time.sleep
and loop logic (Requests). - Favorites Management: Save and view your favorite cat images across the session with Streamlit’s
st.session_state
mechanism (Streamlit Docs). - URL Validation: Ensure that any custom image URLs or tags are valid with the
validators
library before making API calls (PyPI). - Responsive UI: Wide-layout and custom page title/icon configuration via
st.set_page_config
for an optimal viewing experience (Streamlit Docs).
Try it live on Streamlit Cloud: https://catimagesapi.streamlit.app/
Clone the repository and install dependencies with pip:
git clone https://github.com/KyleSanchezGit/CatAPI.git
cd CatAPI
pip install -r requirements.txt
(pip)
Run the app locally with Streamlit:
streamlit run streamlit_app.py
Then open the provided localhost
URL in your browser. (Streamlit Docs)
This project is licensed under the Apache-2.0 License. (GitHub)
For questions or feedback, open an issue on the GitHub repository or reach out to Kyle Sanchez via GitHub.