Franklin + API keys

I am trying to build a website that just displays some sexy PlotlyJS plots using Franklin. So far, so good! But part of my code will rely on, which requires an API key. When my Franklin site is deployed on GitHub, how can I have it access the key (without just saving the key in the public repo of course)?

That README does state that I can:
“Populate the environment variable FRED_API_KEY such that it remains across sessions.”

I am guessing that I can use this with GitHub secrets, but not quite sure what that would look like or entail. Any help is appreciated.

1 Like

Not sure if you are deploying this on a Windows or Linux machine…or something else.

If it’s windows you should be able to search for “environment” in the start menu then define the FRED_API_KEY with the correct value.

On linux if you start the process with a bash script to can also set an environment variable with:

export FRED_API_KEY="blah blah blah"

Or possibly add that to one of the startup scripts for the user.

With either platform the value of the key is not defined in the source at all. You just need to document in the install/deployment process that the FRED_API_KEY must be defined as an environment variable for the application to work correctly.

Sorry, I mean for GitHub deployment. Like GitHub actions. Locally, I have it defined. But when GitHub deploys the site it also needs to evaluate the code, thus it also needs the key. Right?

You should be able to add it as a key on GitHub with the same process as for the DEPLOY_KEY (see and then just write it to ~./fredconfig with the GitHub action.

Another way would be to access the key from the julia -e block but I’m not sure how that would work (I’m not very confident with how GitHub actions work yet)

I’ll try the first way in a bit and report if I get lucky

Ok this works:

The source repo:

in terms of the github action workflow, you need to do the same stuff as pointed out in the link in my previous message (that’s for the Franklin github action) then you just need to add a new secret FRED_API_KEY on GitHub which is written to ~/.freddatarc in the action (see

Hope this helps!

PS: you may have to look up how to avoid showing “API key loaded” with FredData but that seems like a minor nuisance that should be easy to fix :smile:


Above and beyond the call of duty. Thanks a bunch! Exactly what I was looking for

1 Like