This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to use NCBI API key for Entrez (Biopython)?

Hello all,

I have a script that fetches DOI for papers that were found given search term. However if I don't set Entrez.mail I get a warning saying "To make use of NCBI's E-utilities, NCBI requires you to specify your email address with each request."

When using only a mail, you are limited to 3 requests per second. I need this limit to go up, which is why I requested an API key. The issue is that it does not seem to recognize the API key at all. I set it like so:

# Entrez.email = getenv('EntrezMail')
Entrez.api_key = getenv('EntrezAPI')

In other words I am loading it from an .env file. I have checked and made sure that it is working by printing the results of getenv(). Why doesn't it work? Am I doing something wrong?

ncbi entrez

1 answer

You can simply set an environment variable in your shell.

export NCBI_API_KEY='abcdef012'

Add to your shell initialization file to have it set automatically.

Log in to answer this question.