PA About

Pubmed Api

What is PubMed?

Pubmed is a website clinicians and researchers visit to look for research articles. I recently visited the API website, only to be disappointed with its outdated design.

I've extracted and emphasized the key points from that information, while also acknowledging some potential gaps. A more detailed account can be found by following the link provided earlier.

The base URI for the API is https://eutils.ncbi.nlm.nih.gov/entrez/eutils/

See the demo here

Table of contents:

1. API Key

2. Basic Searching

3. Storing Search Results

4. Getting Summaries

5. Getting Full Data

6. Spelling Suggestions

7. Related Articles

8. Database Statistics annd Search Terms

1

API Key

API keys can be obtained from http://www.ncbi.nlm.nih.gov/account/ after you create an account
Once the key has been generated, users are required to incorporate it into every E-utility request by assigning it to the api_key parameter.
Example request including an API key:

esummary.fcgi?db=pubmed&id=123456&api_key=ABCDE12345

2

Basic Searching

Endpoint: esearch.fcgi?db=&term=

By utilizing this API endpoint, you can initiate a search for a specific term, and in response, you will receive a collection of UIDs, which serve as unique identifiers for articles.

Functions: Provides a list of UIDs matching a text query.
UID: Unique Identifier
Base Url: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed
Output: List of UIDs matching a query
Example: Get the PMIDs (PubMed Ids) for articles about breast cancer published in Science 2008
URI: URI
Try it here

            

You can remove the &retmode=json to default it to xml.

{
    "header":  {
    "type":  "esearch",
    },
    "esearchresult":  {
        "querykey": "1",
        "idlist": [
            "19008416",
            "19208416",
            "18008416",
            "16208416",
        ],
    "translationset": "..."
}
3

Storing Search Results

Can be used to save your results in the pubmed server.

Later on, when combining the results as I will explain, it will be necessary for you to utilize this information.

esearch.fcgi?db=&term=&usehistory=y

Input: Any query; Entrez database (&db); &usehistory=y
Output: Web environment (&WebEnv) and query key (&query_key).
Example: Get the PubMed IDs (PMIDs) for articles about breast cancer published in Science in 2008.

Check this URI

Use &retmode=json to get the json output

This will return a WebEnvId in the response

Use WebEnvId in a subsequent request like this.

esearch.fcgi?db=&term=&usehistory=y&WebEnv=$web1

Use the "epost" endpoint to save the set of UIDs in the database

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/epost.fcgi?db=gene&id=7173,22018,54314,403521,525013

This will also return a WebEnvId which you can use in a subsequent request.

{
    "header":  {
    "type":  "esearch",
    },
    "esearchresult":  {
        "querykey": "1",
        "webenv": "MCID_63a5a3e077047a",
        "idlist": [
            "19008416",
            "19208416",
            "18008416",
            "16208416",
        ],
    "translationset": "..."
}
4

Getting Summary

It provides summaries of studies for a given list of pubmed IDs separate by commas.

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&id=16899775,33164953&version=2.0

Use &retmode=json to get the json output

5

Getting Full Data

Endpoint: efetch.fcgi?db=&id= &rettype=&retmode=json
Input: List of UIDs (&id); Entrez database (&db); Retrieval type (&rettype); Retrieval mode (&retmode)`

Link

6

Spelling Suggestions

EndPoint: espell.fcgi?term=&db=/database/
Input: Entrez text query (&term); Entrez database (&db)
Output: XML or json containing the original query and spelling suggestions.
Example: Find spelling suggestions for the PubMed Central query ‘fiberblast cell grwth’.
7

Related Articles

Responds to a list of UIDs in a given database with either a list of related UIDs (and relevancy scores) in the same database or a list of linked UIDs in another Entrez database
Batch mode – finds only one set of linked UIDs
elink.fcgi?dbfrom=&db=&id=uid_list/uid_list
Input: List of UIDs (&id); Source Entrez database (&dbfrom); Destination Entrez database (&db)
Output: XML containing linked UIDs from source and destination databases
Example: Find one set of Gene IDs linked to nuccore GIs 34577062 and 24475906
8

Optional Parameters

retmode:

Set this to json to return in a json format

restart:

Index of first UID to be shown

restart:

Total number of UIDs to be shown

    sort:
  • Sort by the following:
  • - relevance (default)
  • - pub_date (descending order by publication date)
  • - Author - (by first author)
  • - JournalName
3. datetype:
  • - &datetype=mdat - modification date
  • - &datetype=pdat - publication date
  • - &datetype=edat - entrez date
3. mindate, maxdate:
  • - self-explanatory
  • - format should be yyyy/mm/dd or yyyy or yyyy/mm
8

Database Statistics and Search Fields

Endpoint: einfo.fcgi?db=/database/
Output: XML containing database statistics
Note: If no database parameter is supplied, einfo will return a list of all valid Entrez databases
Example: Find database statistics for Entrez Pubmed
Use &retmode=json to get the json output