Skip to main content
info@drupalodyssey.com
Wednesday, July 30, 2025
Contact

Main navigation

  • Home
  • Blog
    • all
    • Development
    • Community
    • Management
    • DevOps
    Photo by  Anastasia  Shuraeva: https://www.pexels.com/photo/a-bearded-man-reading-a-burning-newspaper-7539726
    Bulletproof Your Drupal Data With Automated Nightly Backups
    Jul 30, 2025
    Contractor happy with blueprints.
    Streamlining Drupal Deployments Using Drush and GitHub Actions CI/CD
    Jul 22, 2025
    Reduce, Reuse, Recycle
    Streamlined Content: Effortless PDF Display & Management in Drupal
    Jul 21, 2025
    Aluminum Cans Passing Through the Assembly Line by cottonbro studio on Pexels
    Automate and Simplify Your Drupal Workflow with Bash Scripts for Shared Hosting
    Jul 19, 2024
    Binoculars resting on newspapers.
    Evaluating Search and Replace Scanner: The Ultimate Tool for Drupal Bulk Content Edits?
    Jun 29, 2024
    People looking at a computer screen
    S3 File System Module Not Working with Media Entity Download Module? Here's the Fix
    Jun 18, 2024
    Mechanic hands working on an engine.
    Setting Up the Etsy OAuth2 Client For Use With The Etsy Shop Integration Module
    May 10, 2024
    Fashion designer sketching new garments.
    Crafting Your Online Store: Drupal's Role in Your Etsy Success
    May 09, 2024
    Socket toolbox
    Beginner's Guide: Getting Started With Drush for Efficient Drupal Development
    May 08, 2024
    Stargazing over mountians.
    Drupal-Powered Stargazing: A Module for NASA's Astronomy Picture of the Day
    Sep 15, 2023
    Computer screen with code.
    Learn How To Script Drupal Installations Using Drush
    Dec 08, 2014
    Scuba diver with Drupal mask.
    Scuba: Drupal Style
    Oct 16, 2014
    Woman frustrated with laptop.
    5 Reasons Your CMS Sucks
    Jul 24, 2013
    Two young men having a discussion in front of a computer.
    Deployment Module XSRF Patch Committed
    Jul 05, 2013
    Two young men having a discussion in front of a computer.
    Deployment Module XSRF Patch Committed
    Jul 05, 2013
    Application settings.
    Using PHP To Disable Internet Explorer Compatibility Mode
    Jun 04, 2013
  • Resources
  • About
  • SPACER
  • SPACER
  • SPACER
  • SPACER
  • SPACER
Search
Community

Drupal-Powered Stargazing: A Module for NASA's Astronomy Picture of the Day

September 15, 2023
Effective Sept. 18, 2023, my Github repository will no longer be updated for this module. All functionality has been incorporated into the NASA Astronomy Picture of the Day module on Drupal.org.

Drupal Odyssey is supported by it's readers. When you purchase products or services using the links on this site, we may earn a small commission at no additional cost to you. Learn more

With this module, you can effortlessly enhance your Drupal website with stunning astronomical imagery and engaging content. Whether you're building a space-related blog, an educational platform, or simply want to share the wonders of the universe, the APoD module is your gateway to a vast collection of celestial visuals.

The National Aeronautics and Space Administration (NASA) maintains serveral API enpoints to make data available to developers. One of these endpoints is a spinoff of the NASA's popular website Astronomy Picture of the Day (APoD for short) which I visit regularly myself.

I first found this API several years ago when I worked for the Space Foundation and incorporated the NASA data into their website at the time using ColdFusion. As the years went by, whenever I'd start learning a new CMS or programming language, I would use the APoD API to implement the functionality to display the daily image. My first Drupal iteration was written for Drupal 5 then I rebuilt it for Drupal 7 and started updating it for Drupal 8 but never finished it. Now I'm proud to say that I've updated it again and have fully functional module for Drupal 9 and Drupal 10.

Module Features

Drupal Service Class

The core of this module revolves around a Drupal service class with one method to retrieve the images. The method allows various parameters such as specific date, date range, random image(s), and whether images are high-def or not. The service class also caches the API results in the cache system to help prevent hitting the rate limites for the API. This is especially helpful when using the demo api key.

Routes

There are two routes provided by the module; '/astronomy-picture-of-the-day' and '/astronomy-picture-of-the-day/{date}' which is responsible for displaying the image, copyright, and description of the image. The former is a simple redirect to the later for the current date. There is also previous/next functionality to allow users to bing view previous images and videos all the way back to June 16, 1995.

Block

The module provides a simple Block plugin that allows you to specify whether to display the image for a specific date, today's date, or a random image. Just place the Astronomy Picture of the Day Block on any page and you are done.

Conclusion

The NASA's Astronomy Picture of the Day Drupal module offers a remarkable opportunity to infuse your website with the wonders of the cosmos. This module empowers web developers and astronomy enthusiasts to effortlessly integrate NASA's daily astronomy images and insightful descriptions into their Drupal-powered websites. 

Author

Ron Ferguson

Previous Blog

Next Blog

0 Comments

Login or Register to post comments.

Categories

Categories

  • Development
    (6)
  • Community
    (9)
  • Management
    (6)
  • DevOps
    (5)

Trending Blog

Trending Blog

Contractor happy with blueprints.
Streamlining Drupal Deployments Using Drush and GitHub Actions CI/CD
22 Jul, 2025
Reduce, Reuse, Recycle
Streamlined Content: Effortless PDF Display & Management in Drupal
21 Jul, 2025
Photo by  Anastasia  Shuraeva: https://www.pexels.com/photo/a-bearded-man-reading-a-burning-newspaper-7539726
Bulletproof Your Drupal Data With Automated Nightly Backups
30 Jul, 2025
Woman frustrated with laptop.
5 Reasons Your CMS Sucks
24 Jul, 2013
Mechanic hands working on an engine.
Setting Up the Etsy OAuth2 Client For Use With The Etsy Shop Integration Module
10 May, 2024

Tags

Tags

  • Drupal 10
  • Drupal 9
  • Drupal 8
  • Drupal 11
  • Drupal 7
  • Drush
  • Drupal
  • MySQL

Ad - Sidebar (300 x 250 AD)

Ad - Sidebar (300 x 600 AD)

Newsletter

Subscribe my Newsletter for new blog & tips Let’s stay updated!

Categories

  • Development
  • Community
  • Management

Useful Links

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Disclaimer
  • Cookies

Must Read

Aluminum Cans Passing Through the Assembly Line by cottonbro studio on Pexels
Automate and Simplify Your Drupal Workflow with Bash Scripts for Shared Hosting
19 Jul, 2024
Binoculars resting on newspapers.
Evaluating Search and Replace Scanner: The Ultimate Tool for Drupal Bulk Content Edits?
29 Jun, 2024
Mechanic hands working on an engine.
Setting Up the Etsy OAuth2 Client For Use With The Etsy Shop Integration Module
10 May, 2024
Socket toolbox
Beginner's Guide: Getting Started With Drush for Efficient Drupal Development
08 May, 2024

© 2024 All Rights Reserved.

Proud supporter of active military, veterans and first responders.