A Python web API to fetch and resize the Astronomy Picture of the Day from NASA's APOD (Astronomy Picture of the Day), with customizable resizing options.
The API is available at: https://nasa.gatienh.fr/.
- Basic health check for the API.
- Fetches the daily NASA image (updated every day around midnight UTC-5).
- Example:
GET http://127.0.0.1:3400/daily/
- Fetches and resizes the NASA image for a specific date.
- Path Parameters:
date(str, required): The date inYYMMDDformat.
- Parameters:
- Example:
GET http://127.0.0.1:3400/date/241115/?w=9&h=19
- Description: Fetches and resizes a random NASA image.
- Query Parameters:
minW(int, optional): Minimum width pixel.minH(int, optional): Minimum height pixel.
- Example:
GET http://127.0.0.1:3400/random/?minW=500&minH=2000
- Fetches the metadata (title, credit, explanation) for today's NASA APOD.
- Example:
GET http://127.0.0.1:3400/metadata/daily/
- Fetches the metadata (title, credit, explanation) for a specific date.
- Path Parameters:
date(str, required): The date inYYMMDDformat.
- Example:
GET http://127.0.0.1:3400/metadata/date/260109/
These query parameters are available in all endpoints:
w(int, optional): Width ratio (e.g.,16for a16:9ratio).h(int, optional): Height ratio (e.g.,9for a16:9ratio).crop(bool, optional, default:true):- If
true, the image is cropped to fit the specified aspect ratio. - If
false, the image is resized while maintaining proportions.
- If
download(bool, optional): Iftrue, the image will be downloaded automatically.- Example:
GET http://127.0.0.1:3400/random/?minW=2400&minH=800&w=16&h=9&crop=false&download=true
- Python 3.8 or higher.
pipto install dependencies.
-
Clone the repository.
-
Install the required dependencies:
pip install -r requirements.txt
-
Add a
default.jpgimage at the root of the project. This image will be used when the API does not have an image to return. -
Run the API:
python app.py
-
The API will be available at: http://127.0.0.1:3400.