This is a test version of Biostars. For the public version, visit https://www.biostars.org.
NCBI / Entrez eSearch via HTTP POST

ESearch is the Entrez method for searching the NCBI databases including NucCore / GenBank.

In the documentation for Entrez/ESearch it mentions:

Entrez text query. All special characters must be URL encoded. Spaces may be replaced by '+' signs. For very long queries (more than several hundred characters long), consider using an HTTP POST call.

I would like to use this HTTP POST rather than an HTTP GET with all the terms in the URL. However, I can't find any documentation indicating how the payload of such an HTTP POST request would be structured.

Can anyone show me where this is documented or how it is done?

cheers,
josh

ncbi esearch entrez

2 answers

Am I missing something? For a POST method, you would only provide the query string in the POST body.

$ curl "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi" -d 'db=nuccore&term=Hepatitis%20C[Organism]+AND+7000:10000[SLEN]' |\
  xmllint --format -

Yes, that also works.

I guess that answers the question.

I also found you can do this:

curl "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=nuccore" -d 'term="Hepatitis C"[Organism] AND 7000:10000[SLEN]'

which is good because this allows me to pass through the term without translating the URL special characters.

josh

I think the parameters would be the same as for the GET method, but using a POST instead. For example the following code will produce a link:

<form name='epostform' target='_blank' method='post' action='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/epost.fcgi'>
<input type='hidden' name='db' value='pubmed'/>
<input type='hidden' name='id' value='11237011,12466850'/>
</form>

Link to <a href=\"javascript: document.forms['epostform'].submit();\">Query Results</a>

Yes, that does work. I'm using entrez as a programmatic API, rather than from a web UI.

Currently I'm encoding the search terms in the URL, like this:

http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=nuccore&term=Hepatitis%20C[Organism]+AND+7000:10000[SLEN]

What I was hoping was that in the case of an HTTP POST, I could put the search terms in the payload of the request, in a nicer format, and perhaps inside an XML document, like this:

<term>
    "Hepatitis C"[Organism] AND 7000:10000[SLEN]
</term>

josh

Log in to answer this question.