{"id":25686912,"url":"https://github.com/markushhh/fredapi.jl","last_synced_at":"2025-08-01T10:05:55.270Z","repository":{"id":46008227,"uuid":"231814301","full_name":"markushhh/FredApi.jl","owner":"markushhh","description":"Download FRED data in Julia.","archived":false,"fork":false,"pushed_at":"2024-11-16T06:47:19.000Z","size":702,"stargazers_count":6,"open_issues_count":3,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T04:41:29.764Z","etag":null,"topics":["dataset","fred-api","fredapi","julia"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markushhh.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-04T19:06:04.000Z","updated_at":"2024-11-16T14:15:17.000Z","dependencies_parsed_at":"2022-08-28T11:40:38.642Z","dependency_job_id":null,"html_url":"https://github.com/markushhh/FredApi.jl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markushhh%2FFredApi.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markushhh%2FFredApi.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markushhh%2FFredApi.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markushhh%2FFredApi.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markushhh","download_url":"https://codeload.github.com/markushhh/FredApi.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535057,"owners_count":21446503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dataset","fred-api","fredapi","julia"],"created_at":"2025-02-24T20:07:43.308Z","updated_at":"2025-04-23T23:43:59.597Z","avatar_url":"https://github.com/markushhh.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FredApi.jl\r\n\r\n![\"logo\"](docs/src/assets/logo.png)\r\n\r\n`FredApi.jl` offers the possibility to access the [FRED Developer API](https://research.stlouisfed.org/docs/api/) in Julia.\r\nThis package is available in R as [FredApi](https://github.com/markushhh/FredApi).\r\n\r\n## Installation\r\n\r\n```@julia\r\nadd FredApi\r\n```\r\n\r\nor\r\n\r\n```@julia\r\nadd https://github.com/markushhh/FredApi.jl/\r\n```\r\n\r\n## Index\r\n\r\nThe package contains following functions: \r\n\r\n- `set_api_key`\r\n- `get_symbols`\r\n- `search_symbol`\r\n- `get_release`\r\n- `get_metadata`\r\n- `get_category`\r\n- `get_sources`\r\n- `get_source`\r\n- `save_api_key`\r\n- `load_api_key`\r\n\r\n## Set up an Envionment Variable for the FRED API key\r\n\r\nYou can either set up an environment variable for the FRED API key called \"API_FRED\" or use a local environment variable when entering a new julia session with \r\n\r\n```@julia\r\nset_api_key(\"YOUR_KEY\")\r\n```\r\n\r\nwhere you manually replace `YOUR_KEY` with your private API key. \r\nTo set an environment variable under windows, open command prompt and type in `setx API_FRED \"YOUR_KEY\"` where `YOUR_KEY` must be replaced with your API key.\r\nTo open the command prompt press `Windows+R`, then type in `cmd` and press Enter.\r\nTo set an environment variable on an other OS follow [this](https://lmgtfy.com/?qtype=search\u0026t=w\u0026segment=lmgtfy2\u0026is_ad=0\u0026gclid=\u0026q=how+to+set+environment+variable+\u0026as=0\u0026engine=\u0026media_type=) link and add your OS. \r\nYou can request a FRED API key at [https://research.stlouisfed.org/useraccount/login/secure/](https://research.stlouisfed.org/useraccount/login/secure/).\r\n\r\nAnother option is to write the API key to your home directory with `save_api_key(\"YOUR_KEY\")`. It saves a `.fred_api_key` file into `homedir()` which can later be loaded into the current julia process with `load_api_key()`. This method requires you to load the key always if you start a new session.\r\n\r\n## Tutorial and Workflow\r\n\r\n```@julia\r\nusing FredApi\r\nset_api_key(\"API_FRED\")\r\n```\r\n\r\nFollowing is an applied tutorial about how to use the package. Simply replace the symbol with your prefered symbol and run the function.\r\n\r\nDownload a full dataset with\r\n\r\n```@julia\r\nget_symbols(\"GDPC1\")\r\n```\r\n\r\noutput\r\n\r\n```@julia\r\n291×1 TimeArray{Float64,1,Date,Array{Float64,1}} 1947-01-01 to 2019-07-01\r\n│            │ Value     │\r\n├────────────┼───────────┤\r\n│ 1947-01-01 │ 2033.061  │\r\n│ 1947-04-01 │ 2027.639  │\r\n│ 1947-07-01 │ 2023.452  │\r\n│ 1947-10-01 │ 2055.103  │\r\n│ 1948-01-01 │ 2086.017  │\r\n│ 1948-04-01 │ 2120.45   │\r\n│ 1948-07-01 │ 2132.598  │\r\n│ 1948-10-01 │ 2134.981  │\r\n│ 1949-01-01 │ 2105.562  │\r\n   ⋮\r\n│ 2017-10-01 │ 18322.464 │\r\n│ 2018-01-01 │ 18438.254 │\r\n│ 2018-04-01 │ 18598.135 │\r\n│ 2018-07-01 │ 18732.72  │\r\n│ 2018-10-01 │ 18783.548 │\r\n│ 2019-01-01 │ 18927.281 │\r\n│ 2019-04-01 │ 19021.86  │\r\n│ 2019-07-01 │ 19121.112 │\r\n```\r\n\r\nDownload a subsample\r\n\r\n```@julia\r\nget_symbols(\"GDPC1\", \"2010-01-01\", \"2019-01-01\")\r\n```\r\n\r\noutput\r\n\r\n```@julia\r\n37×1 TimeArray{Float64,1,Date,Array{Float64,1}} 2010-01-01 to 2019-01-01\r\n│            │ Value     │\r\n├────────────┼───────────┤\r\n│ 2010-01-01 │ 15415.145 │\r\n│ 2010-04-01 │ 15557.277 │\r\n│ 2010-07-01 │ 15671.967 │\r\n│ 2010-10-01 │ 15750.625 │\r\n│ 2011-01-01 │ 15712.754 │\r\n│ 2011-04-01 │ 15825.096 │\r\n│ 2011-07-01 │ 15820.7   │\r\n│ 2011-10-01 │ 16004.107 │\r\n│ 2012-01-01 │ 16129.418 │\r\n   ⋮\r\n│ 2017-04-01 │ 18021.048 │\r\n│ 2017-07-01 │ 18163.558 │\r\n│ 2017-10-01 │ 18322.464 │\r\n│ 2018-01-01 │ 18438.254 │\r\n│ 2018-04-01 │ 18598.135 │\r\n│ 2018-07-01 │ 18732.72  │\r\n│ 2018-10-01 │ 18783.548 │\r\n│ 2019-01-01 │ 18927.281 │\r\n```\r\n\r\nTo change the time frame of the dataset, the `collapse()` function in `TimeSeries.jl` comes in really handy.\r\n\r\n```@julia\r\nusing TimeSeries\r\n\r\nx = get_symbols(\"FEDFUNDS\", \"2000-01-01\", \"2019-01-01\")\r\n\r\ncollapse(x, year, first)\r\n```\r\n\r\noutput\r\n\r\n```@julia\r\n20×1 TimeArray{Float64,1,Date,Array{Float64,1}} 2000-01-01 to 2019-01-01\r\n│            │ Value │\r\n├────────────┼───────┤\r\n│ 2000-01-01 │ 5.45  │\r\n│ 2001-01-01 │ 5.98  │\r\n│ 2002-01-01 │ 1.73  │\r\n│ 2003-01-01 │ 1.24  │\r\n│ 2004-01-01 │ 1.0   │\r\n│ 2005-01-01 │ 2.28  │\r\n│ 2006-01-01 │ 4.29  │\r\n│ 2007-01-01 │ 5.25  │\r\n│ 2008-01-01 │ 3.94  │\r\n   ⋮\r\n│ 2012-01-01 │ 0.08  │\r\n│ 2013-01-01 │ 0.14  │\r\n│ 2014-01-01 │ 0.07  │\r\n│ 2015-01-01 │ 0.11  │\r\n│ 2016-01-01 │ 0.34  │\r\n│ 2017-01-01 │ 0.65  │\r\n│ 2018-01-01 │ 1.41  │\r\n│ 2019-01-01 │ 2.4   │\r\n```\r\n\r\nTo explore more options, go to [TimeSeries.jl](https://github.com/JuliaStats/TimeSeries.jl/blob/master/docs/src/combine.md)\r\n\r\n```@julia\r\nusing Plots\r\n\r\nplot(x, legend = false)\r\n```\r\n\r\n![\"plot\"](docs/src/assets/plot.png)\r\n\r\nIn case you do not know which ID a time series is associated with, you can search for it using the API. Let's have a look over an example. We would like to download the French Gross Domestic Product. We would use `search_symbol` and explore the results.\r\n\r\n```@julia\r\nx = search_symbol(\"GDP\", \"France\")\r\nprintln(x)\r\n```\r\n\r\nThe resulting DataFrame is sorted by popularity, you can always sort by any column you'd like by applying `sort!(x, j)` to sort by the `j`-th column.\r\n\r\n```\r\n13×3 DataFrame\r\n│ Row │ popularity │ title            │ id                                                                                                │\r\n│     │ Int64      │ String           │ String                                                                                            │\r\n├─────┼────────────┼──────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────┤\r\n│ 1   │ 47         │ CLVMNACSCAB1GQFR │ Real Gross Domestic Product for France                                                            │\r\n│ 2   │ 24         │ CPMNACSCAB1GQFR  │ Gross Domestic Product for France                                                                 │\r\n│ 3   │ 20         │ NYGDPPCAPKDFRA   │ Constant GDP per capita for France                                                                │\r\n│ 4   │ 16         │ RGDPNAFRA666NRUG │ Real GDP at Constant National Prices for France                                                   │\r\n│ 5   │ 12         │ CLVMNACNSAB1GQFR │ Real Gross Domestic Product for France                                                            │\r\n│ 6   │ 11         │ MKTGDPFRA646NWDB │ Gross Domestic Product for France                                                                 │\r\n│ 7   │ 7          │ NAEXKP01FRQ661S  │ Gross Domestic Product by Expenditure in Constant Prices: Total Gross Domestic Product for France │\r\n│ 8   │ 7          │ CPMNACNSAB1GQFR  │ Gross Domestic Product for France                                                                 │\r\n│ 9   │ 5          │ NAEXKP01FRQ657S  │ Gross Domestic Product by Expenditure in Constant Prices: Total Gross Domestic Product for France │\r\n│ 10  │ 5          │ NAEXKP01FRQ189S  │ Gross Domestic Product by Expenditure in Constant Prices: Total Gross Domestic Product for France │\r\n│ 11  │ 3          │ NAEXKP01FRA189S  │ Gross Domestic Product by Expenditure in Constant Prices: Total Gross Domestic Product for France │\r\n│ 12  │ 2          │ NAEXKP01FRA657S  │ Gross Domestic Product by Expenditure in Constant Prices: Total Gross Domestic Product for France │\r\n│ 13  │ 1          │ NAEXKP01FRA661S  │ Gross Domestic Product by Expenditure in Constant Prices: Total Gross Domestic Product for France │\r\n```\r\n\r\nLet's take the most popular series `Real Gross Domestic Product for France` and get more information about it.\r\n\r\n```@julia\r\nget_metadata(\"CLVMNACSCAB1GQFR\")\r\n```\r\n\r\noutput\r\n\r\n```\r\nMetadata for: CLVMNACSCAB1GQFR\r\nTitle: Real Gross Domestic Product for France\r\nUnits: Millions of Chained 2010 Euros\r\nAdjustment: Seasonally Adjusted\r\nFrequency: Quarterly\r\nNotes: Eurostat unit ID: CLV10_MNAC\r\nEurostat item ID = B1GQ\r\nEurostat country ID: FR\r\n\r\nSeasonally and calendar adjusted data.\r\n\r\nFor euro area member states, the national currency series are converted into euros using the irrevocably fixed exchange rate. This preserves the same growth rates than for the previous national currency series. Both series coincide for years after accession to the euro area but differ for earlier years due to market exchange rate movements.\r\n\r\nCopyright, European Union, http://ec.europa.eu, 1995-2016.Complete terms of use are available at http://ec.europa.eu/geninfo/legal_notices_en.htm#copyright\r\n```\r\n\r\n, to get release information about the series, run `get_release(\"CLVMNACSCAB1GQFR\")`\r\n\r\noutput:\r\n\r\n```\r\nDict{String,Any} with 6 entries:\r\n  \"realtime_start\" =\u003e \"2020-01-07\"\r\n  \"name\"           =\u003e \"National Accounts - GDP (Eurostat)\"\r\n  \"id\"             =\u003e 267\r\n  \"realtime_end\"   =\u003e \"2020-01-07\"\r\n  \"link\"           =\u003e \"http://appsso.eurostat.ec.europa.eu/nui/show.do?dataset=…\r\n  \"press_release\"  =\u003e true\r\n```\r\n\r\n, to get the category run: `get_category(\"CLVMNACSCAB1GQFR\")`. In this example we get `GDP`.\r\n\r\nTo get all sources from FRED, run `get_sources()` which results in\r\n\r\n```\r\n89×3 DataFrame. Omitted printing of 1 columns\r\n│ Row │ id    │ name                                                    │\r\n│     │ Int64 │ String                                                  │\r\n├─────┼───────┼─────────────────────────────────────────────────────────┤\r\n│ 1   │ 1     │ Board of Governors of the Federal Reserve System (US)   │\r\n│ 2   │ 3     │ Federal Reserve Bank of Philadelphia                    │\r\n│ 3   │ 4     │ Federal Reserve Bank of St. Louis                       │\r\n│ 4   │ 6     │ Federal Financial Institutions Examination Council (US) │\r\n│ 5   │ 11    │ Dow Jones \u0026 Company                                     │\r\n│ 6   │ 14    │ University of Michigan                                  │\r\n│ 7   │ 15    │ Council of Economic Advisers (US)                       │\r\n⋮\r\n│ 82  │ 129   │ Moody’s                                                 │\r\n│ 83  │ 133   │ DHI Group, Inc.                                         │\r\n│ 84  │ 135   │ Centers for Disease Control and Prevention     …\r\n```\r\n\r\nFor more information about a source from FRED, run `get_source(1)` with an Integer specifying the source, e.g.\r\n\r\n```@julia\r\nDict{String,Any} with 5 entries:\r\n  \"realtime_start\" =\u003e \"2020-01-07\"\r\n  \"name\"           =\u003e \"Board of Governors of the Federal Reserve System (US)\"\r\n  \"id\"             =\u003e 1\r\n  \"realtime_end\"   =\u003e \"2020-01-07\"\r\n  \"link\"           =\u003e \"http://www.federalreserve.gov/\"\r\n```\r\n\r\n# Each comment, suggestion or pull request is welcome!\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkushhh%2Ffredapi.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkushhh%2Ffredapi.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkushhh%2Ffredapi.jl/lists"}