Skip to content

A future challenge for myself to consume 9 APIs with Python in 9 Days

Notifications You must be signed in to change notification settings

steaksauce-/9DaysOfAPIs

Repository files navigation

9DaysOfAPIs

About

As a SysAdmin who uses Python for automating/simplifying certain tasks, I've always wanted to do more. I by no means claim to be a developer, but enjoy it as a hobby and a way to advance my career. This little project is a way for me to get used making API calls with Python. All of the topics of the APIs are things that I think are interesting or funny.

This project started out at 30 days of APIs, and then 21. However, it was easier to find 9 interesting APIs than 30.

While all of the projects will use argparse for certain variables, keep in mind that it is probably safer to set an environment variable with your API keys.

Activities

Day 1 - NASA Astronomy Photos

nasa-apod.py

Simple CLI app that takes a NASA API key and grabs the APOD for today, or the specified date, and downloads it to the current directory.

Arguments:

[optional] --api-key The api.nasa.gov API key to use. Defaults to DEMO_KEY.

[optional] --date The date to grab the photo from. Defaults to today.

Day 2 - NASA Near Earth Asteroids (NEO)

nasa-asteroids.py

Returns a list of Near Earth Objects on a given date range and notes if they are considered potentially hazardous.

Arguments:

api_key The API key to use.

start_date The start date that the asteroid will be near Earth. example: 2019-07-23

end_date The end date that the asteriod will be near Earth. example: 2019-07-30

Day 3 - Open Weather Maps (OMW)

omw-weather.py

Obtains weather forecast for a given city using a given API key from openweathermap.org

Arguments:

api_key Your OWM API key.

zip_code The zipcode you wish to query about.

Day 4 - Taco Fancy

taco-recipe.py

Gives you a random taco recipe!

Arguments:

NONE!

Day 5 - REST Countries

countries-basicinfo.py

Gives the capital and language(s) of a given country.

country The full name of the country.

Day 6 - FOAAS

foaas-foff.py

Returns a random message from FOAAS that only requires input in the from field.

Arguments:

[OPTIONAL] --signed Who are you?

Day 7 - IP Stack

ipstack-geolocation.py

Returns the geolocation for your current IP address, or a given IP address.

Arguments:

api_key Your IP Stack API key.

[OPTIONAL] --ip The IP address you wish to query. Defaults to your IP address.

Day 8 - DnD5e

dnd5e-spells.py

Grabs information about a given Dungeons and Dragons 5e Spell

Arguments:

spell_name The name of the spell to get information for.

Day 9 - Twilio (Using DnD5e)

twilio-dndspells.py

Grabs information about a given Dungeons and Dragons 5e Spell and texts it to a given number.

Arguments:

spell_name The name of the spell to get information for.") api_key The Twilio API key.") auth_token The Twilio acccount Auth Token.") sender The Twilio phone number to send the SMS message from.") recipient The phone number to send the spell information from.")

Lessons Learned

  • MVP (minimum viable product) is easy and provides a way for quick feedback.
  • If you have to look up documentation or Google something, it's best to know the 'lingo' to know what to look for.
  • I should be writing tests (possibly do 9 days of tests as a companion to this project?).
  • Don't always rely on a demo key.
  • f strings are useful, but ugly.
  • Not all JSON output is meant to be printed as plain text.
  • There's more than one way to skin a cat.
  • I should probably script the API endpoint to scrape possibilities instead of hardcoding them.
  • A lot of software vendors are probably using other APIs -- it's genius really.
  • "free" APIs tend to be slow.
  • It's ALOT easier to use a vendor supported package to make your API calls than it is to form your own requests.
  • I wish I knew about list comprehension before doing this.

About

A future challenge for myself to consume 9 APIs with Python in 9 Days

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages