Fetches a space image from NASA based on a given day and month. Supports both Turkish and English month names. Returns the image in Base64 format.
✅ Fetch NASA space images based on your birthday or a specific date 📆
✅ Supports Turkish & English month names 🌍
✅ Returns Base64-encoded images 🖼️
✅ No API key required 🔑
✅ Works with Node.js & supports Promises ⚡
Install via npm:
npm install space-imageOr using yarn:
yarn add space-imageconst { getSpaceImage } = require("space-image");getSpaceImage(15, "january", "en")
.then(data => console.log(data))
.catch(err => console.error(err));{
"date": "15 January",
"base64Image": "/9j/4AAQSkZJRgABAQAAAQABAAD..."
}You can save the Base64-encoded image to a .jpg file using Node.js fs module:
const { getSpaceImage } = require("space-image");
const fs = require("fs");
async function downloadImage(day, month, lang = "en") {
try {
const data = await getSpaceImage(day, month, lang);
fs.writeFileSync(`space_image_${day}_${month}.jpg`, Buffer.from(data.base64Image, "base64"));
console.log(`✅ Image saved as space_image_${day}_${month}.jpg`);
} catch (error) {
console.error("❌ Failed to download image:", error.message);
}
}
// Example usage
downloadImage(15, "january", "en");Fetches a space image from NASA based on the given day and month.
- Parameters:
day(number) → The day of the month (1-31).month(string) → The name of the month in Turkish or English (e.g., "ocak" or "january").lang(string, optional) → The response language ("tr" or "en"). Defaults to "en".
- Returns:
Promise<object>→ JSON object with date and Base64-encoded image.
Contributions are welcome! Fork the repository, create a branch, make changes, and submit a PR. 🚀
This project is licensed under the MIT License.
- GitHub Issues: Report Bugs or Request Features
- Give a Star: ⭐ If you like this package, consider giving it a star on GitHub!
🚀 Happy Coding! 🎮✨