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 inYYMMDD
format.
- 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
These query parameters are available in all endpoints:
w
(int, optional): Width ratio (e.g.,16
for a16:9
ratio).h
(int, optional): Height ratio (e.g.,9
for a16:9
ratio).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.
pip
to install dependencies.
-
Clone the repository.
-
Install the required dependencies:
pip install -r requirements.txt
-
Add a
default.jpg
image 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.