pubmed-client (Node.js)
    Preparing search index...

    Class PubMedClient

    PubMed/PMC API client

    Index

    Constructors

    Methods

    • Check if a PubMed article has full-text available in PMC

      Parameters

      • pmid: string

        PubMed ID

      Returns Promise<string | null>

      PMC ID if available, null otherwise

    • Upload a list of PMIDs to the NCBI History server using EPost

      Stores UIDs on the server and returns WebEnv/query_key identifiers that can be used with subsequent API calls.

      Parameters

      • pmids: string[]

        Array of PubMed IDs as strings

      Returns Promise<EPostResult>

      EPostResult containing webenv and query_key

      const client = new PubMedClient();
      const result = await client.epost(["31978945", "33515491", "25760099"]);
      console.log(`WebEnv: ${result.webenv}, Query Key: ${result.queryKey}`);
    • Fetch all articles for a list of PMIDs using EPost and the History server

      Uploads the PMID list via EPost (HTTP POST), then fetches articles in paginated batches. Recommended for large PMID lists (hundreds or thousands).

      Parameters

      • pmids: string[]

        Array of PubMed IDs as strings

      Returns Promise<Article[]>

      Array of article metadata

      const client = new PubMedClient();
      const articles = await client.fetchAllByPmids(["31978945", "33515491", "25760099"]);
      articles.forEach(a => console.log(a.title));
    • Fetch a single article by PMID

      Parameters

      • pmid: string

        PubMed ID

      Returns Promise<Article>

      Article metadata

    • Fetch multiple articles by PMIDs in a single batch request

      This is significantly more efficient than fetching articles one by one. For large numbers of PMIDs, requests are automatically batched (200 per request).

      Parameters

      • pmids: string[]

        Array of PubMed IDs

      Returns Promise<Article[]>

      Array of article metadata

    • Fetch full-text article from PMC

      Parameters

      • pmcid: string

        PMC ID (e.g., "PMC7906746")

      Returns Promise<FullTextArticle>

      Full-text article data

    • Fetch PMC article and convert to Markdown

      Parameters

      • pmcid: string

        PMC ID (e.g., "PMC7906746")

      • Optionaloptions: MarkdownOptions | null

        Markdown conversion options

      Returns Promise<string>

      Markdown string

    • Fetch lightweight article summaries by PMIDs using the ESummary API

      Returns basic metadata (title, authors, journal, dates, DOI) without abstracts, MeSH terms, or chemical lists. Faster than fetchArticles().

      Parameters

      • pmids: string[]

        Array of PubMed IDs

      Returns Promise<Summary[]>

      Array of article summaries

    • Check if a PMC article is in the OA (Open Access) subset

      The OA subset contains articles with programmatic access to full-text XML. Some publishers restrict programmatic access even though the article may be viewable on the PMC website.

      Parameters

      • pmcid: string

        PMC ID (e.g., "PMC7906746")

      Returns Promise<OaSubsetInfo>

      OaSubsetInfo containing detailed information about OA availability

      const client = new PubMedClient();
      const info = await client.isOaSubset("PMC7906746");

      if (info.isOaSubset) {
      console.log("Article is in OA subset");
      console.log("Download:", info.downloadLink);
      } else {
      console.log("Not in OA subset:", info.errorCode);
      }
    • Search PubMed and fetch article metadata

      Parameters

      • query: string

        Search query string (PubMed syntax supported)

      • Optionallimit: number | null

        Maximum number of results to return

      Returns Promise<Article[]>

      Array of article metadata

    • Search PubMed and fetch lightweight summaries

      Combines search and ESummary fetch. Faster than search() when you only need basic metadata.

      Parameters

      • query: string

        Search query string

      • Optionallimit: number | null

        Maximum number of results

      Returns Promise<Summary[]>

      Array of article summaries

    • Check spelling of a search term using the ESpell API

      Provides spelling suggestions for terms within a single text query. Uses the PubMed database by default.

      Parameters

      • term: string

        The search term to spell-check

      Returns Promise<SpellCheckResult>

      Spelling suggestions with corrected query

    • Check spelling of a search term against a specific database using the ESpell API

      Spelling suggestions are database-specific, so use the same database you plan to search.

      Parameters

      • term: string

        The search term to spell-check

      • db: string

        The NCBI database to check against (e.g., "pubmed", "pmc")

      Returns Promise<SpellCheckResult>

      Spelling suggestions with corrected query