# PubMed MeSH & Citation Metadata Extractor (`dataspryva/pubmed-mesh-and-citation-metadata-extractor`) Actor

Pull structured PubMed article records by keyword, PMID, author, journal, or MeSH term, with abstracts, grant funding, conflict-of-interest statements, and a ready-made citation string. No login or proxy needed.

- **URL**: https://apify.com/dataspryva/pubmed-mesh-and-citation-metadata-extractor.md
- **Developed by:** [Dataspryva](https://apify.com/dataspryva) (community)
- **Categories:** Automation, Developer tools, Other
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.49 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## PubMed MeSH & Citation Metadata Extractor

Read [PubMed](https://pubmed.ncbi.nlm.nih.gov) without fighting the website. This actor calls NCBI's public E-utilities API and turns a search, a list of PMIDs, or a set of filters into structured article records with abstracts, MeSH indexing, chemicals, funding, citation links and a ready-to-use reference string.

No login, cookie, proxy or API key is required. The optional NCBI key only raises the request ceiling for very large runs.

### What it can do

- Search one or many PubMed queries, including full PubMed syntax: `cancer AND immunotherapy[MeSH]`, `Smith J[Author]`, `2024[dp]`.
- Paste PubMed search URLs or article URLs. Search URLs contribute their `term=` query; article URLs become direct PMID lookups.
- Fetch specific PMIDs without searching. Accepts `38123456`, `PMID: 38123456` or a PubMed article URL.
- Run a filter-only search, for example a journal, author, MeSH term, affiliation or publication-date window with no keyword.
- Narrow by publication type, language, species (human or animal), free full text, abstract availability and retraction status.
- Sort by best match, most recent, publication date, first author or journal.
- Enrich every record with structured abstract sections, MeSH headings and major topics, chemicals, grants, author ORCIDs and affiliations, clinical-trial IDs, publication history, linked notices and optional reference lists.
- Add a cited-by count and a compact AMA-style citation string.

### Input

| Field | Type | Default | What it does |
|---|---|---|---|
| `searchTerms` | array | – | PubMed queries. Each term is searched separately and merged by PMID. |
| `searchUrls` | array | `[]` | PubMed search or article URLs. |
| `pmidList` | array | `[]` | Direct PMID lookups, with or without a search. |
| `maxItemsPerTerm` | integer | `25` | Cap per query, 1–9,999. The dataset is the sum across terms. |
| `sortBy` | select | `relevance` | Best match, most recent, publication date, first author or journal. |
| `dateFrom` / `dateTo` | text | – | Publication dates as `YYYY`, `YYYY/MM` or `YYYY/MM/DD`. |
| `articleType` | select | `any` | 46 PubMed publication types, from Review and RCT to Preprint and Retracted Publication. |
| `freeFullTextOnly` | boolean | `false` | Keep only records with a free full-text version. |
| `hasAbstractOnly` | boolean | `false` | Drop records without an abstract. |
| `language` | select | `any` | 33 common PubMed publication languages. |
| `species` | select | `any` | Human studies, animal studies or any. |
| `excludeRetracted` | boolean | `false` | Drop retracted publications, retraction notices and expressions of concern. |
| `journalFilter` | text | – | Journal name or NLM abbreviation. |
| `authorFilter` | text | – | Author in PubMed format, e.g. `Smith J`. |
| `meshFilter` | array | `[]` | MeSH descriptors; all listed terms must match. |
| `affiliationFilter` | text | – | Affiliation substring, e.g. `Harvard`. |
| `includeReferences` | boolean | `false` | Add each article's cited references. Records get much larger, so this is off by default. |
| `includeCitedByCount` | boolean | `false` | Add the number of PubMed articles citing each record. |
| `apiKey` | secret | – | Optional free NCBI key; raises the request rate from 3/s to 10/s. |

Every filter is optional. Fill `searchTerms`/`searchUrls`/`pmidList`, one or more filters, or both. An input with no criteria stops with a clear status message.

#### Examples

Keyword search with a MeSH filter:

```json
{
  "searchTerms": ["lung cancer screening"],
  "meshFilter": ["Early Detection of Cancer"],
  "articleType": "systematic_review",
  "dateFrom": "2023",
  "dateTo": "2025/12/31",
  "maxItemsPerTerm": 200
}
```

Journal-only sweep with reference lists:

```json
{
  "journalFilter": "Nature",
  "dateFrom": "2024/01",
  "dateTo": "2024/12",
  "maxItemsPerTerm": 100,
  "sortBy": "publication_date",
  "includeReferences": true
}
```

Direct PMID lookup with citation counts:

```json
{
  "pmidList": ["38123456", "33301246"],
  "includeCitedByCount": true
}
```

Filter-only search for human RCTs:

```json
{
  "articleType": "randomized_controlled_trial",
  "species": "humans",
  "dateFrom": "2024",
  "maxItemsPerTerm": 250
}
```

### Output

One row per article. Empty fields are omitted at every depth — no nulls, empty strings, empty lists or placeholder values.

Identity and links

- `pmid`, `doi`, `doiUrl`, `pmcId`, `pmcUrl`, `articleUrl`, `shareLinks`

Bibliographic metadata

- `title`, `authors`, `authorsAbbreviated`, `authorsDetails` (first name, last name, initials, ORCID, affiliations), `authorCount`, `firstAuthor`, `lastAuthor`
- `journal`, `journalAbbrev`, `issn`, `eissn`, `journalCountry`, `nlmUniqueId`
- `publicationDate`, `epubDate`, `articleDate`, `volume`, `issue`, `pages`, `elocationId`
- `language`, `articleTypes`, `recordStatus`, `publicationStatus`, `vernacularTitle`, `bookTitle`, `publisher`, `publisherLocation`
- `publicationHistory` with `received`, `accepted`, `revised`, `pubmedEntry`, `medline`, `entrez`, `pmcRelease`, `created`, `completed`, `lastRevised` dates when PubMed has them
- `copyright`

Content and indexing

- `abstract`, `abstractSections` (label + text per section), `otherAbstracts` (non-English abstracts)
- `meshTerms`, `meshMajor`, `meshHeadings` (term, major-topic flag, qualifiers), `keywords`
- `chemicals` (name and registry number), `clinicalTrialIds`, `dataBanks`
- `authorAffiliations`, `conflictOfInterest`, `grants` (grant ID, agency, acronym, country)
- `referenceCount`, `references` (optional; citation text, PMID and DOI)
- `citedByCount` (optional)
- `publicationNotices` (comments, errata, retractions and updates linked by PubMed)

Assessment helpers

- `tags` — compact labels such as Review, Meta-Analysis, Clinical Trial, Preprint, Retracted or Free article
- `integrityStatus` — `retracted`, `retraction-notice`, `expression-of-concern` or `erratum` when applicable
- `isRetracted` — present only for retracted publications
- `humanStudy` — true/false from MeSH when the record has a human or animal signal
- `citation` — AMA-style reference string built from the record

Search context

- `inputQuery`, `resultRank`, `queryTotalMatches`, `scrapedAt`

### How it works

The actor uses four public NCBI endpoints: `esearch` for PMIDs and the total match count, `esummary` for bibliographic metadata, `efetch` for abstracts and indexing details, and `elink` for optional cited-by counts. Requests are paced at NCBI's published limits (3/s without a key, 10/s with one), retried on transient 429/5xx responses, and processed in batches so even 9,999-record runs stream instead of loading everything into memory.

The default test input asks for one article, so the daily check stays cheap.

### Reliability and limits

- **9,999 records per query.** PubMed's search API returns at most 9,999 records for one query. Split a larger topic into date windows or narrower filters and concatenate the datasets. The actor reports the true `queryTotalMatches` even when it returns the 9,999-record window.
- **MeSH lags publication.** New articles can spend months without MeSH terms; `meshTerms` and `humanStudy` appear only after indexing. Filtering by MeSH can therefore miss very recent papers.
- **Abstracts, DOIs, grants and reference lists are not universal.** Letters, editorials, older records and ahead-of-print papers often lack them. The field is omitted rather than invented.
- **Reference lists are optional.** Turn on `includeReferences` when you need the citation graph; it materially increases record size and run time.
- **The public website is not scraped.** PubMed serves a cookie wall to plain HTTP clients, while E-utilities is the API behind the same index. This actor uses the API, so it works without cookies or a browser.
- **No full text.** PubMed Central full-text articles are not downloaded. `pmcId`/`pmcUrl` point to the free full-text version when one exists.

### FAQ

**Do I need an NCBI API key?**
No. The keyless rate is enough for normal runs. A free key helps when you routinely request thousands of records.

**Why is a field missing from one record but present in another?**
PubMed itself does not publish every field for every article. The actor omits what the source does not have and never fills a placeholder.

**Can I use PubMed search tags?**
Yes. `searchTerms` is passed through to PubMed, so `[tiab]`, `[au]`, `[mh]`, `[pt]`, `[dp]`, Boolean operators and nested parentheses all work.

**What happens when nothing matches?**
The run finishes with an empty dataset and a status message saying zero articles matched. Invalid input, such as no criteria at all, fails with an explanatory message.

**Is this an official PubMed or NLM product?**
No. It is an independent third-party actor that reads NCBI's public E-utilities API.

# Actor input Schema

## `searchTerms` (type: `array`):

One or more PubMed queries. Each term is searched independently and the results are merged by PMID. Full PubMed syntax works: `cancer AND immunotherapy[MeSH]`, `Smith J[Author]`, `2024[dp]`.

## `searchUrls` (type: `array`):

Paste PubMed search or article URLs. Search URLs contribute their `term=` query; article URLs (`pubmed.ncbi.nlm.nih.gov/PMID/`) are fetched as PMIDs. Results merge with the other search inputs.

## `pmidList` (type: `array`):

Direct lookup: PubMed IDs to fetch without searching. Accepts IDs as strings or numbers and tokens like `PMID: 38123456`.

## `maxItemsPerTerm` (type: `integer`):

Cap per query, from 1 to 9,999. The dataset is the sum across all terms. PubMed returns at most 9,999 records for one query; split by date range for larger corpora.

## `sortBy` (type: `string`):

Order PubMed returns for each query. `Best match` uses PubMed relevance; the other options mirror the PubMed website. Ignored for PMID lookups.

## `dateFrom` (type: `string`):

Earliest publication date. Use YYYY, YYYY/MM or YYYY/MM/DD (e.g. `2020`, `2020/06`, `2020/06/15`).

## `dateTo` (type: `string`):

Latest publication date. Same formats as the from date.

## `articleType` (type: `string`):

Restrict to one PubMed publication type. `Any` keeps every type.

## `freeFullTextOnly` (type: `boolean`):

Keep only articles with a free full-text version in PubMed Central.

## `hasAbstractOnly` (type: `boolean`):

Drop records that PubMed has no abstract for.

## `language` (type: `string`):

Restrict to one publication language. `Any` keeps every language.

## `species` (type: `string`):

Use PubMed's MeSH signal to keep human or non-human animal studies. `Any` does not filter.

## `excludeRetracted` (type: `boolean`):

Drop retracted publications, retraction notices and expressions of concern.

## `journalFilter` (type: `string`):

Journal name or NLM abbreviation, e.g. `Nature` or `N Engl J Med`.

## `authorFilter` (type: `string`):

Author in PubMed format, e.g. `Smith J` or `Smith JR`.

## `meshFilter` (type: `array`):

One or more MeSH descriptors. All listed terms must be present (AND), e.g. `Lung Neoplasms` and `Machine Learning`.

## `affiliationFilter` (type: `string`):

Keep articles where an author affiliation contains this text, e.g. `Harvard` or `Mayo Clinic`.

## `includeReferences` (type: `boolean`):

Add the article's cited references (citation text, PMID and DOI where PubMed has them). This can make records much larger, so it is off by default.

## `includeCitedByCount` (type: `boolean`):

Add the number of PubMed articles citing each record. Uses one extra elink request per batch of PMIDs.

## `apiKey` (type: `string`):

Optional free key from https://www.ncbi.nlm.nih.gov/account/ — raises the request ceiling from 3 to 10 per second for very large runs. Never required.

## Actor input object example

```json
{
  "searchTerms": [
    "machine learning oncology"
  ],
  "searchUrls": [],
  "pmidList": [],
  "maxItemsPerTerm": 1,
  "sortBy": "relevance",
  "articleType": "any",
  "freeFullTextOnly": false,
  "hasAbstractOnly": false,
  "language": "any",
  "species": "any",
  "excludeRetracted": false,
  "meshFilter": [],
  "includeReferences": false,
  "includeCitedByCount": false
}
```

# Actor output Schema

## `articles` (type: `string`):

Dataset containing all scraped PubMed articles.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchTerms": [
        "machine learning oncology"
    ],
    "maxItemsPerTerm": 1,
    "sortBy": "relevance",
    "articleType": "any",
    "freeFullTextOnly": false,
    "hasAbstractOnly": false,
    "language": "any",
    "species": "any",
    "excludeRetracted": false,
    "includeReferences": false,
    "includeCitedByCount": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("dataspryva/pubmed-mesh-and-citation-metadata-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "searchTerms": ["machine learning oncology"],
    "maxItemsPerTerm": 1,
    "sortBy": "relevance",
    "articleType": "any",
    "freeFullTextOnly": False,
    "hasAbstractOnly": False,
    "language": "any",
    "species": "any",
    "excludeRetracted": False,
    "includeReferences": False,
    "includeCitedByCount": False,
}

# Run the Actor and wait for it to finish
run = client.actor("dataspryva/pubmed-mesh-and-citation-metadata-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchTerms": [
    "machine learning oncology"
  ],
  "maxItemsPerTerm": 1,
  "sortBy": "relevance",
  "articleType": "any",
  "freeFullTextOnly": false,
  "hasAbstractOnly": false,
  "language": "any",
  "species": "any",
  "excludeRetracted": false,
  "includeReferences": false,
  "includeCitedByCount": false
}' |
apify call dataspryva/pubmed-mesh-and-citation-metadata-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dataspryva/pubmed-mesh-and-citation-metadata-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/KhaQaa39DBJwYi8u2/builds/aMLAr4fgFAFVm1v2o/openapi.json
