A simple script that shows you info about NASA's astronomy image of the day.

Open in ScriptKit

Example: nasa-astronomy-pic-of-the-day-500

The Code:

// Menu: NASA's Astronomy Picture of the Day
// Description: Get NASA's APOTD
// Suggested Schedule cron, run it everyday at 10AM local time: 0 10 * * *
// Author: Asep Norzai
// Twitter: @asepnorzai
import "@johnlindquist/kit"
let {data: {copyright, date, explanation, title, hdurl}} = await get(`https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY`)
show(`
<div style="padding: 1em">
<h1 style="text-align: center">Astronomy Picture of the Day</h1>
<p><strong>Title:</strong> <a href="https://apod.nasa.gov/apod/astropix.html">${title}</a></p>
<p><strong>Explanation:</strong> ${explanation}</p>
<p><strong>Date:</strong> ${date}</p>
<p><strong>Copyright:</strong> ${copyright}</p>
<image src="${hdurl}" style="margin-top: 0.5em" title="${title}"/>
</div>`,
{
title,
width: 800,
height: 1000
})

Extra Findings:

I initially wanted to use // Schedule: 0 10 * * * to automatically show the image everyday, 10am local time, but somehow when opening the script through https://scriptkit.com/api/new?name=, the schedule value gets stripped off, leaving only // Schedule:? Not sure if it's a bug or by design?