Text Yourself the NASA Picture of the Day with Standard Library and Node.js
Tags: node, javascript, showdev, webdev
Published: 2018-10-18 07:00:56

---
title: Text Yourself the NASA Picture of the Day with Standard Library and Node.js
published: true
description: The sky is not the limit
tags: node, javascript, showdev, webdev
---

![The APoD for 10/16/2018: Jupiter in Ultraviolet from HubbleMe](https://res.cloudinary.com/eileenstdlib/image/upload/v1539839937/APoD/0_aUCLxxSlMh5V_aGH.jpg)

```
Me: The sky is not the limit ☁️
Stranger: Pics or I don't believe you 🙄
```

[Based on the above conversation, I'm going to show you how to get NASA's](https://medium.com/@eileenzhong/text-yourself-the-nasa-picture-of-the-day-with-standard-library-and-node-js-226f6ca48adc) highly coveted **Astronomy Picture of the Day** (APoD) with [Standard Library](https://www.stdlib.com) 🌑 ⭐️ 

If you're not familiar with [Standard Library](https://www.stdlib.com), we're a serverless platform that enables everyone (yes, everyone! Calling all PMs, designers, marketing teams, sales people, oh and engineers… 🙋) to build, ship, and integrate scalable APIs in a matter of seconds. With the help of our online text editor, [Code.xyz](https://code.xyz), you can do all of this right from your browser.

## **Requirements**
[Standard Library](https://www.stdlib.com) account (free)
[NASA](https://api.nasa.gov/) API key (free)

[Standard Library](https://www.stdlib.com) provides a plethora of API templates that are readily usable. In order to retrieve the APoD API template, go to [Code.xyz](https://code.xyz) and search for astronomy-picture-of-the-day by @eileenzhong 💁

![APoD template](https://res.cloudinary.com/eileenstdlib/image/upload/v1539839876/APoD/Screen_Shot_2018-10-16_at_1.47.39_PM.png)

Name your API:
![Name your API](https://res.cloudinary.com/eileenstdlib/image/upload/v1539839876/APoD/Screen_Shot_2018-10-16_at_2.50.53_PM.png)

One last step before sending the APoD to your phone!

You'll need to properly configure the `env.json` file. You'll notice that there are two sets of variables; however, we will be deploying our code to the dev environment, so we will only need to provide the dev variables.
First, insert your Standard Library library token (`STDLIB_LIBRARY_TOKEN`):

![Right click to access this context menu](https://res.cloudinary.com/eileenstdlib/image/upload/v1539839876/APoD/Screen_Shot_2018-10-16_at_2.53.21_PM.png)

Then, insert your [NASA API key](https://api.nasa.gov/). When finished, your `env.json` file should look like this:

![Completed env.json](https://res.cloudinary.com/eileenstdlib/image/upload/v1539839876/APoD/Screen_Shot_2018-10-16_at_2.52.33_PM.png)

That's all the setup you have to do! 

To run the program, click "Debug" to bring the parameter input area into view. Enter your phone number, including the country code:

![Don't forget the country code!](https://res.cloudinary.com/eileenstdlib/image/upload/v1539839876/APoD/Screen_Shot_2018-10-16_at_3.01.34_PM.png)

When you click "Run", you'll receive NASA's astronomy picture of the day! 🚀

That's not even the coolest part. 

We don't want to click "Run" every single day to get this text delivered to our phone. Thankfully, [Standard Library](https://www.stdlib.com) has a task scheduler where you can customize a schedule to automagically invoke your newly created API. 
In [Code.xyz](https://code.xyz), click the "Tasks" tab. You can then enter a phone number and customize a schedule to your liking:

![Create a scheduled task for your API](https://res.cloudinary.com/eileenstdlib/image/upload/v1539839877/APoD/Screen_Shot_2018-10-16_at_3.19.34_PM.png)

*Suggestion: schedule the task to execute once a day since APoD is an acronym for astronomy picture of the day, and hence, the picture won't change throughout the day.*

When you're happy with the settings, click the blue "Schedule Task" button to schedule your API.
That's it! If you know one ☝️, two ✌️, or five 🖐 other people who would appreciate a daily astronomy picture, you can schedule a different task (one for each phone number) for all of them. 


---

## **Bonus section**
If you've made it this far, you deserve a reward 🌈 Now, don't get too excited (actually - do get excited 🙃). With just 2 more lines of code, you can send your friend a random quote along with the APoD!

![APoD and a random Paul Jacques Grillo quote](https://res.cloudinary.com/eileenstdlib/image/upload/v1539839918/APoD/Image_from_iOS.png)

We'll be using WordPress's API to pull a randomized quote: `http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1`. 

{% gist https://gist.github.com/eileenzhong/d2b2b79a854abb617f6850b0f5a900ab %}

Don't worry about all the RegEx (regular expressions) sitting on line 12. The WordPress API just returns some HTML tags that won't play nicely in an MMS 📱

Alternatively, you can just replace the value of the quote variable with any chunk of text you'd like to send your friend: `const quote = "Hi friend."`

Questions, comments, ideas? Feel free to email me at eileen@stdlib.com! I'd love to hear about your next project with [Standard Library](https://www.stdlib.com) and [Code.xyz](https://code.xyz).


---

*Eileen is a software engineer at [Standard Library](https://www.stdlib.com).*