micahjsmith / FredData.jl

Pull data from Federal Reserve Economic Data (FRED) directly into Julia
https://micahjsmith.github.io/FredData.jl/dev
Other
64 stars 19 forks source link

API keys #14

Closed greimel closed 5 years ago

greimel commented 5 years ago

Thank you for putting up this package!,

I wanted to use it, so I followed the link to the API key application. There it says

Each user of an application may use the same API key. Developers should request an API key for each application they build.

So wouldn't it suffice if you put an application-wide key into this repo and everybody could use it? The R package quantmodseems to work that way.

micahjsmith commented 5 years ago

Thanks for your question! The text you quote from the St Louis Fed page refers to a different scenario.

internet user      <--------->     
internet user      <--------->       application server
internet user      <--------->

In the case that you build an application that allows people over the internet to use or request data from FRED, your application needs only one API key. That is, rather than storing a separate key for every user of your application on your own computer, you store a single key for all of your users combined. However, none of your users ever sees your API key!

FredData.jl is a library, not an application, and can be used to build an application like above or can be for personal use to download data, in which every user needs their own API key.

Note that API keys should be treated like passwords and should never be exposed publicly.

The R package you reference deals with API keys the same was as FredData.jl. Some data providers, like Yahoo Finance, don't necessarily need an API key to be provided in order to return data to the user. So if you use getQuote.yahoo, you might think that quantmod is providing everyone an API key, but that's not the case -- no one needs one. Take a look at https://github.com/joshuaulrich/quantmod/blob/master/R/getQuote.R#L279, you can see that the library requires the user to provide an api.key argument. Let me know if you still think otherwise.

greimel commented 5 years ago

Thank you for your answer.

I've used quantmod for loading FRED data. I don't remember applying for an API key though. Maybe I don't fully get what the code is doing, but could it be that quantmod has a different strategy for downloading FRED data?

It seems that getSymbols.FRED() loads the data in csv format. Could it be that this works without an API key? I don't see it floating around. Probably it's hidden somewhere.

https://github.com/joshuaulrich/quantmod/blob/8e2c2cb966502fd0c02c88945a4fea83373c974f/R/getSymbols.R#L761

micahjsmith commented 5 years ago

There is a separate (public) FRED endpoint that just allows you to download CSVs of series. Software libraries can then parse these CSVs and return data to the user. It's equivalent to going to https://fred.stlouisfed.org/series/GDPC1 for example and clicking on "Download Data". This returns just (date, value) pairs and doesn't support things like metadata, searching, or vintages. FredData.jl does not support this alternative and less powerful way of downloading data from FRED.