A simple FastAPI application to serve data on upcoming lunar and solar eclipses.
- Hosted on Render: https://eclipses-api.onrender.com
- API Docs: https://eclipses-api.onrender.com/docs
- Install Python 3.10+.
- Create a virtual environment:
python -m venv venv
- Activate it:
venv\Scripts\activate
(Windows) - Install dependencies:
pip install -r requirements.txt
- Place
eclipse_data.csv
in the project root. - Run the app:
uvicorn main:app --reload
- Access at
http://localhost:8000
and docs athttp://localhost:8000/docs
.
GET /
: Welcome message with link to docs.GET /eclipses
: List all eclipses fromeclipse_data.csv
.GET /eclipses/next
: Get the next upcoming eclipse.GET /eclipses/{type}
: Filter by type (solar or lunar).
curl https://eclipses-api.onrender.com/eclipses/next
Response:
{
"date": "2025-03-14",
"type": "lunar",
"visibility": "Pacific, Americas, Western Europe, Western Africa",
"duration": 218
}
Eclipse data sourced from NASA's catalog (2021–2040), stored in eclipse_data.csv
.