Skip to content

Instantly share code, notes, and snippets.

View rruntsch's full-sized avatar

Randy Runtsch rruntsch

View GitHub Profile
@rruntsch
rruntsch / gist:374d7be0758724fe1c7b010195fc55f3
Last active May 23, 2023 21:35
Example Python code to get real time stock quotes and end of day (EOD) historical stock price data from StockData.org APIs.
# Author: Randy Runtsch
# Date: May 23, 2023
# Title: get_stock_data.py
# Description: Create and instance of class c_stock and call its
# get_eod_stock_date function to obtain daily closing prices
# and get_real_time_stock_quotes to obtain the latest price quote.
from c_stock import c_stock
from api_secrets import api_token
@rruntsch
rruntsch / c_who_mortality_data.py
Created November 21, 2022 15:32
Example of calling WHO GHO OData API with Python
#
# Name: c_who_mortality.py
# Date: April 17, 2022
# Author: Randy Runtsch
#
# Description:
#
# Obtain WHO Global Observatory (GO) records in JSON format with the GHO Odata API for IndicatorCode: NCDMORT3070,
# IndicatorName: Probability (%) of dying between age 30 and exact age 70 from any of
# cardiovascular disease, cancer, diabetes, or chronic respiratory disease.
@rruntsch
rruntsch / c_country_pop.py
Created November 17, 2022 12:56
Python Program to Retrieve International Database Population Estimates from the Census Data API International Database
#
# Name: c_country_pop.py
# Date: November 15, 2022
# Author: Randy Runtsch
#
# Description:
#
# Get the mid-year population estimates for a country for the specified year.
# Write the data to a CSV file.
@rruntsch
rruntsch / get_us_debt.py
Created April 23, 2022 11:41
Call the constructor of the c_us_debt_api Python class with the specified folder and file name, start date, and end date.
#
# Name: get_us_debt.py
# Date: April 22, 2022
# Author: Randy Runtsch
#
# Description:
#
# Use the c_us_debt class to obtain the total debt
# owed by the US federal government, by day, for a range
# of dates.
@rruntsch
rruntsch / c_us_debt_api.py
Created April 23, 2022 11:38
Python class to retrieve US federal government debt data, by date, for th specified date range. The class writes the retrieved JSON data structur to the specified file.
#
# Name: c_us_debt.py
# Date: April 22, 2022
# Author: Randy Runtsch
#
# Description:
#
# Obtain all US debt records, for the specified date range,
# as JSON structures, from the Treasury Direct Debt Informatin API.
# Write each record to the specified output folder and file.
@rruntsch
rruntsch / c_nasa_fireball_data.py
Created April 16, 2022 18:58
This Python program calls the NASA Fireball Data API to retrieve fireball records in JSON format. It then writes the records to a CSV file.
#
# Name: c_nasa_fireball_data.py
# Date: April 15, 2022
# Author: Randy Runtsch
#
# Description:
#
# Obtain all fireball records, as JSON structures, from the NASA Jet Propulsion Lab Fireball API.
# Write each record to the specified output folder and file.
#
@rruntsch
rruntsch / c_bls_data.py
Last active April 14, 2022 16:29
Python program to call the U.S. Bureau of Labor Statistics (BLS) Public Data API to retrieve economic data and write it to a CSV file.
#
# Name: c_bls_data.py
# Date: April 14, 2022
# Author: Randy Runtsch
#
# Description:
#
# The c_bls_data class uses Version 2 of the US Bureau of Labor Statistics (BLS) API
# to obtain one of more series of BLS data. It retrieves the data in
# JavaScript Object Notation (JSON) format, converts the data to CSV records,
@rruntsch
rruntsch / customer_location_json.sql
Created March 31, 2022 21:02
Query data from SQL Server and write its results in the JSON format.
-- File: customer_location_json.sql
-- Date: March 31, 2022
-- Author: Randy Runtsch
-- Description: Get the names and location (city, state or province,
-- postal code, and country or region name
-- for all customers in the AdventureWorks2019 database.
-- Return the data in JSON format.
USE AdventureWorks2019;
@rruntsch
rruntsch / customer_location_csv.sql
Last active March 31, 2022 21:04
Select customer data from the SQL Server Adventure Works database to demonstrate saving returned data to a CSV file.
-- File: customer_location_csv.sql
-- Date: March 31, 2022
-- Author: Randy Runtsch
-- Description: Get the names and location (city, state or province,
-- postal code, and country or region name
-- for all customers in the AdventureWorks2019 database.
-- Return the data in plain text format.
USE AdventureWorks2019;
@rruntsch
rruntsch / c_usda_quick_stats.py
Created March 31, 2022 09:49
Demonstration Python program to request agricultural data with the USDA's Quick Stats API.
# Name: c_usda_quick_stats.py
# Author: Randy Runtsch
# Date: March 29, 2022
# Project: Query USDA QuickStats API
# Author: Randall P. Runtsch
#
# Description: Query the USDA QuickStats api_GET API with a specified set of
# parameters. Write the retrieved data, in CSV format, to a file.
#
# See Quick Stats (NASS) API user guide: https://quickstats.nass.usda.gov/api