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('' . urlencode($argv[1]))){
  if ($xml = simplexml_load_file("{$xml->QueryKey}&WebEnv={$xml->WebEnv}&retstart=0&retmax=10")){
    $docs = $xml->DocSum;

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.