quandl / quandl-python

MIT License
1.37k stars 336 forks source link

store and read api key from local file #116

Closed ulf1 closed 5 years ago

ulf1 commented 5 years ago

Current Way

import quandl
quandl.ApiConfig.api_key = "mysecretkey"

Store a API Key

Save API Key string in a local text file, e.g. $HOME/.quandl_apikey

quandl.apikey_set("mysecretkey")

or a specified file, e.g.

quandl.apikey_set("mysecretkey", filepath="/data/.quandl_apikey")

Use cases

Implemention

https://github.com/ulf1/updoon/blob/master/updoon/quandl_apikey.py

this would read the file with the api like

import quandl
import updoon 
quandl.ApiConfig.api_key = updoon.quandl_apikey()

Proposal

Add save_key and read_key to api_config.py, e.g.

class ApiConfig:
     ....

def read_key(filepath=None):
    ...
    ApiConfig.api_key = ...

to do

import quandl
quandl.read_key()
...

instead of exposing the API key within a script.

mbasset commented 5 years ago

Thanks @ulf1 ,

We have merged your changes into master. They will go out with our next release.