Public
Edited
Mar 1, 2023
Insert cell
Insert cell
API_KEY = 'XXX'
Insert cell
series_id = 'RIFSPPNAAD30NB'
Insert cell
observation_start = '2019-01-01' // add widget
Insert cell
observation_end = '2021-04-05' // add widget
Insert cell
frequency = 'm' // One of the following values: 'd', 'w', 'bw', 'm', 'q', 'sa', 'a', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem'
Insert cell
units = 'lin' // One of the following values: 'lin', 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log'
Insert cell
aggregation_method = 'eop'// One of the following values: 'avg', 'sum', 'eop'
Insert cell
apiEndpoint = 'https://api.stlouisfed.org/fred/series/observations?'
Insert cell
apiUrl = encodeURI(`${apiEndpoint}series_id=${series_id}&api_key=${API_KEY}&file_type=json&observation_start=${observation_start}&observation_end=${observation_end}&frequency=${frequency}&units=${units}&aggregation_method=${aggregation_method}`)
Insert cell
Insert cell
//url = `${corsApp}${apiUrl}`
Insert cell
//res = fetch(encodeURI(url)) // not sure URI encoding is needed
Insert cell
//data = res.clone().json()
Insert cell
//data.observations
Insert cell
Insert cell
Insert cell
import {fetchp} with {DOMAINS as ALLOW_DOMAINS} from '@tomlarkworthy/fetchp'
Insert cell
DOMAINS = ['fred.stlouisfed.org']
Insert cell
justinsdata = fetchp(apiUrl)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more