PubMed API

The NCBI provides a web service interface to PubMed. For searching this is a two-step process that first performs the search then retrieves the results. Here's an example in PHP5:


if ($xml = simplexml_load_file('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmax=0&usehistory=y&term=' . urlencode($argv[1]))){
  if ($xml = simplexml_load_file("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&retmode=xml&query_key={$xml->QueryKey}&WebEnv={$xml->WebEnv}&retstart=0&retmax=10")){
    $docs = $xml->DocSum;
  }
}
print_r($docs);

The query terms are passed in as a command line argument. The retstart and retmax parameters determine the offset and number of items to return. See the EUtils documentation for full information.

Comments

Is it possible to search by values such as author and title as well as by term?

Yes - just put one of PubMed's filters[1] in square brackets at the end
of the search term, the same as you would in PubMed's web interface. "Melancon B"[AU], for example.

[1] http://www.ncbi.nlm.nih.gov/books/bv.fcgi?rid=helppubmed.section.pubmedhelp.Search_Field_Descrip

Is it possible to retrieve the mesh terms of an article? How do I achieve this by API in my program? Thank you

Posted by: Elwin on March 7, 2009 6:51 AM

How do I retrieve the full abstract for each of the results retrieved ?

The xml returned has a field 1 which indicates whether the article has a abstract or not .

What parameter do I use in the query to fetch the entire abstract ?

Posted by: Hrishi on October 12, 2009 12:58 AM

All fields are optional, email address will not be shown; no HTML, URLs are automatically hyperlinked.