# PubMed Scraper for RAG: Papers as Chunked JSON (`getascraper/pubmed-rag-extractor`) Actor

Scrape PubMed citations by search term, MeSH, and article type. Returns RAG-ready JSON with full-text chunks from PMC Open Access (cl100k_base, 512/50) and abstract fallback. Drop-in for LangChain, LlamaIndex, Qdrant, Pinecone, Weaviate, pgvector. Skip GROBID / Pubmed Parser.

- **URL**: https://apify.com/getascraper/pubmed-rag-extractor.md
- **Developed by:** [GetAScraper](https://apify.com/getascraper) (community)
- **Categories:** AI, Developer tools, Agents
- **Features:** Limited permissions
- **Stats:** 7 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.53 / 1,000 literature records

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

Learn more: https://docs.apify.com/actors/running/actors-in-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 Scraper for RAG: Papers as Chunked JSON

<table width="100%" style="display:table;width:100%;border-collapse:separate;border-spacing:0;table-layout:fixed;margin-bottom:0">
<tr>
<td colspan="4" style="padding:14px 18px;background:#E6F5F3;border:none;border-top:3px solid #0F766E;border-left:1px solid #D6D3D1;border-right:1px solid #D6D3D1;color:#1C1917;border-radius:10px 10px 0 0">
<span style="font-size:16px;font-weight:700;color:#1C1917">Turn PubMed biomedical literature into RAG-ready chunks in one call.</span> <span style="font-size:15px;color:#57534E">Search by free text, MeSH terms, or article type, fetch PMC Open Access full text where it exists, and get 512-token chunks with full metadata.</span>
</td>
</tr>
<tr>
<td colspan="4" style="padding:10px 14px;background:#0F766E;border:none;border-left:1px solid #D6D3D1;border-right:1px solid #D6D3D1;color:#FFFFFF">
<span style="color:#FFFFFF;font-size:14px;font-weight:700;letter-spacing:0.5px">RESEARCH AND REGULATORY RAG EXTRACTORS</span>
<span style="color:#FFFFFF;font-size:13px">&nbsp;&nbsp;&bull;&nbsp;&nbsp;Turns arXiv, bioRxiv/medRxiv, PubMed, CourtListener case law, and SEC EDGAR filings into RAG-ready, chunked JSON for grounded LLM retrieval.</span>
</td>
</tr>
<tr>
<td style="padding:10px 12px;border:none;border-left:1px solid #D6D3D1;border-bottom:1px solid #D6D3D1;vertical-align:top;width:25.0%;background:#E6F5F3;color:#1C1917">
<span style="overflow-wrap:break-word;word-break:break-word"><img src="https://apify-image-uploads-prod.s3.us-east-1.amazonaws.com/jNDbFabbVxMhnQNb4-actor-Zd6dqQcd4Ikxz2zKK-ybjn9mBfFS-icon.svg.png" width="20" height="20" style="vertical-align:middle;border-radius:4px">&nbsp;<a href="https://apify.com/getascraper/pubmed-rag-extractor" style="color:#0F766E;text-decoration:none;font-weight:700;font-size:13px">PubMed RAG</a></span><br>
<span style="color:#0F766E;font-size:11px;font-weight:700">&#10148; You are here</span>
</td>
<td style="padding:10px 12px;border:none;border-left:1px solid #D6D3D1;border-bottom:1px solid #D6D3D1;vertical-align:top;width:25.0%;background:#FFFFFF;color:#1C1917">
<span style="overflow-wrap:break-word;word-break:break-word"><img src="https://apify-image-uploads-prod.s3.us-east-1.amazonaws.com/jNDbFabbVxMhnQNb4-actor-6IBhuHNwM30iCkbw5-7wwI4rHpZp-icon.svg.png" width="20" height="20" style="vertical-align:middle;border-radius:4px">&nbsp;<a href="https://apify.com/getascraper/sec-edgar-rag-extractor" style="color:#1C1917;text-decoration:none;font-weight:700;font-size:13px">SEC EDGAR</a></span><br>
<span style="color:#57534E;font-size:11px">10-K/10-Q/8-K, chunked</span>
</td>
<td style="padding:10px 12px;border:none;border-left:1px solid #D6D3D1;border-bottom:1px solid #D6D3D1;vertical-align:top;width:25.0%;background:#FFFFFF;color:#1C1917">
<span style="overflow-wrap:break-word;word-break:break-word"><img src="https://apify-image-uploads-prod.s3.us-east-1.amazonaws.com/jNDbFabbVxMhnQNb4-actor-fTIeAjdm2wmoKI6l5-PFGPaNefV5-icon.svg.png" width="20" height="20" style="vertical-align:middle;border-radius:4px">&nbsp;<a href="https://apify.com/getascraper/arxiv-rag-extractor" style="color:#1C1917;text-decoration:none;font-weight:700;font-size:13px">arXiv RAG</a></span><br>
<span style="color:#57534E;font-size:11px">arXiv papers, chunked</span>
</td>
<td style="padding:10px 12px;border:none;border-left:1px solid #D6D3D1;border-right:1px solid #D6D3D1;border-bottom:1px solid #D6D3D1;vertical-align:top;width:25.0%;background:#FFFFFF;color:#1C1917">
<span style="overflow-wrap:break-word;word-break:break-word"><img src="https://apify-image-uploads-prod.s3.us-east-1.amazonaws.com/jNDbFabbVxMhnQNb4-actor-JHXsUCtHdrMkkWuqm-OtzFbGBR1q-icon.svg.png" width="20" height="20" style="vertical-align:middle;border-radius:4px">&nbsp;<a href="https://apify.com/getascraper/biorxiv-medrxiv-rag-extractor" style="color:#1C1917;text-decoration:none;font-weight:700;font-size:13px">bioRxiv/medRxiv</a></span><br>
<span style="color:#57534E;font-size:11px">Preprints, chunked JSON</span>
</td>
</tr>
</table>
<table width="100%" style="display:table;width:100%;border-collapse:separate;border-spacing:0;margin-top:0;margin-bottom:0">
<tr>
<td style="padding:24px 28px;background:#E6F5F3;border:1px solid #B9E4DF;border-top:none;color:#1C1917">
<span style="font-size:23px;font-weight:800;color:#1C1917;line-height:1.3">PubMed literature, delivered as clean chunked JSON</span><br>
<span style="font-size:15px;color:#57534E;line-height:1.6">Fetches PMC Open Access full text where it exists, falls back to the abstract, and splits everything into tokenizer-aware chunks ready to embed.</span>
</td>
</tr>
</table>
<table width="100%" style="display:table;width:100%;border-collapse:separate;border-spacing:0;table-layout:fixed;margin-top:0">
<tr>
<td style="padding:14px 12px;width:25%;background:#FFFFFF;border:1px solid #B9E4DF;vertical-align:top;border-top:none;color:#1C1917;border-radius:0 0 0 10px">
<span style="font-size:15px;font-weight:800;color:#0F766E">🔬&nbsp;MeSH + article-type filters</span><br>
<span style="font-size:12px;color:#57534E">Search by MeSH ontology or narrow to reviews</span>
</td>
<td style="padding:14px 12px;width:25%;background:#FFFFFF;border:1px solid #B9E4DF;border-left:none;vertical-align:top;border-top:none;color:#1C1917">
<span style="font-size:15px;font-weight:800;color:#0F766E">📖&nbsp;PMC full text when it exists</span><br>
<span style="font-size:12px;color:#57534E">NXML stripped to readable prose, abstract fallback</span>
</td>
<td style="padding:14px 12px;width:25%;background:#FFFFFF;border:1px solid #B9E4DF;border-left:none;vertical-align:top;border-top:none;color:#1C1917">
<span style="font-size:15px;font-weight:800;color:#0F766E">🧩&nbsp;Tokenizer-aware chunks</span><br>
<span style="font-size:12px;color:#57534E">512 tokens, 50 overlap, cl100k_base</span>
</td>
<td style="padding:14px 12px;width:25%;background:#FFFFFF;border:1px solid #B9E4DF;border-left:none;vertical-align:top;border-top:none;color:#1C1917;border-radius:0 0 10px 0">
<span style="font-size:15px;font-weight:800;color:#0F766E">🗄️&nbsp;Vector-DB neutral</span><br>
<span style="font-size:12px;color:#57534E">Drops into Qdrant, Pinecone, Weaviate, Chroma</span>
</td>
</tr>
</table>

**Scrape PubMed biomedical research into RAG-ready JSON in one call.** Pulls papers by free-text search, MeSH ontology, article type, and date range. Fetches PMC Open Access full-text when available and falls back to the abstract otherwise. Returns fixed-token chunks (cl100k_base, 512 tokens / 50 overlap) with full metadata, ready to drop into **LangChain, LlamaIndex, Qdrant, Pinecone, Weaviate, pgvector, or Chroma**. Built for AI training data teams, pharma/biotech researchers, and anyone who's written "just one more PubMed Parser patch" at 2 AM.

### 🔍 What does PubMed Scraper for RAG do?

This Apify Actor scrapes **[PubMed](https://pubmed.ncbi.nlm.nih.gov/)** citations matching your search criteria, fetches PMC Open Access full-text where available, and splits the resulting plain text into **tokenizer-aware chunks (512 tokens, 50-token overlap, tiktoken cl100k_base)** ready to embed or feed into a RAG index.

Each output record contains clean metadata (PMID, PMCID, DOI, title, authors, journal, MeSH terms, article types, publication date) and a `chunks` array of `{ idx, text, tokens }` ready for direct ingestion into a vector database.

**Try it in the Apify Console.** Fill in a search term (e.g. `SARS-CoV-2 vaccines`), optional MeSH terms or article types, a date range, a paper cap, and hit Start. Download results as JSON, CSV, or Excel.

Built on the Apify platform, you also get: scheduled runs, HTTP API access, integrations with Zapier / n8n / Make, proxy rotation, monitoring, and alerts. No infrastructure to run yourself.

### 💡 Why use PubMed Scraper for RAG?

- **Skip the PubMed XML parsing grind.** Clean Paper records, not raw E-utilities `<PubmedArticle>` trees.
- **PMC Open Access full-text when it exists.** Around 20-30% of PubMed articles are in PMC OA; this Actor grabs NXML and strips it to readable prose. Abstract fallback otherwise.
- **MeSH + article-type filtering built in.** Search by MeSH ontology (e.g. `Neoplasms`) or limit to `Review` / `Meta-Analysis` / `Clinical Trial`.
- **Pre-chunked for RAG.** `tiktoken cl100k_base` tokenization, compatible with OpenAI `text-embedding-3`, Claude, Cohere, and most BGE/E5/nomic embedding models.
- **Vector-DB neutral.** Drop into **Qdrant, Pinecone, Weaviate, pgvector (Supabase / Neon), Chroma, Milvus** without reformatting.
- **Framework-ready.** Works with **LangChain, LlamaIndex, Haystack, LangGraph**.
- **Respects NCBI rate limits.** 3 requests per second without an API key, 10 per second with one.
- **Cheap.** $0.02 per paper. A week of clinical-trial reviews (~200 papers) costs around $4.

### 🚀 How to use PubMed Scraper for RAG

<table width="100%" style="display:table;width:100%;border-collapse:separate;border-spacing:0;table-layout:fixed">
<tr>
<td style="padding:16px 14px;width:33%;background:#E6F5F3;border:1px solid #B9E4DF;border-radius:10px 0 0 10px;vertical-align:top;color:#1C1917">
<span style="font-size:12px;font-weight:800;color:#0F766E;letter-spacing:1px">STEP 1</span><br>
<span style="font-size:14px;font-weight:700;color:#1C1917">Set your search</span><br>
<span style="font-size:12px;color:#57534E">Free-text <span style="font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:0.9em;background:#FFFFFF;color:#1C1917;border:1px solid #D6D3D1;padding:1px 6px;border-radius:4px;white-space:nowrap">searchTerm</span>, optional <span style="font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:0.9em;background:#FFFFFF;color:#1C1917;border:1px solid #D6D3D1;padding:1px 6px;border-radius:4px;white-space:nowrap">meshTerms</span>/<span style="font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:0.9em;background:#FFFFFF;color:#1C1917;border:1px solid #D6D3D1;padding:1px 6px;border-radius:4px;white-space:nowrap">articleTypes</span>, and a date range.</span>
</td>
<td style="padding:16px 14px;width:33%;background:#E6F5F3;border:1px solid #B9E4DF;border-left:none;vertical-align:top;color:#1C1917">
<span style="font-size:12px;font-weight:800;color:#0F766E;letter-spacing:1px">STEP 2</span><br>
<span style="font-size:14px;font-weight:700;color:#1C1917">Run the extractor</span><br>
<span style="font-size:12px;color:#57534E">Fetches PMC Open Access full text where available, falls back to abstract.</span>
</td>
<td style="padding:16px 14px;width:33%;background:#E6F5F3;border:1px solid #B9E4DF;border-left:none;border-radius:0 10px 10px 0;vertical-align:top;color:#1C1917">
<span style="font-size:12px;font-weight:800;color:#0F766E;letter-spacing:1px">STEP 3</span><br>
<span style="font-size:14px;font-weight:700;color:#1C1917">Download chunked JSON</span><br>
<span style="font-size:12px;color:#57534E">Get token-aware chunks ready to embed, from the Storage tab.</span>
</td>
</tr>
</table>

### 📥 Input

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `searchTerm` | string | | `SARS-CoV-2 vaccines` | Free-text PubMed query, supports `[mh]`, `[ti]`, `[pt]` syntax |
| `meshTerms` | string\[] | | `[]` | MeSH headings. Each entry wrapped with `[mh]`, OR-combined |
| `articleTypes` | string\[] | | `[]` | Enum values: clinical_trial / review / meta_analysis / case_report / observational_study |
| `dateFrom` | string (YYYY-MM-DD) | | `2024-01-01` | Inclusive publication-date lower bound |
| `dateTo` | string (YYYY-MM-DD) | | `2024-01-15` | Inclusive publication-date upper bound |
| `maxPapers` | integer | | `50` | Hard cap on papers returned (1 to 100000) |
| `ncbiApiKey` | string (secret) | | | Optional NCBI API key for 10 req/s instead of 3 |

**Example input:**

```json
{
    "searchTerm": "SARS-CoV-2 vaccines",
    "articleTypes": ["review", "meta_analysis"],
    "dateFrom": "2024-01-01",
    "dateTo": "2024-01-31",
    "maxPapers": 100
}
```

### 📤 Output

Each paper becomes one dataset item. You can download the dataset in JSON, HTML, CSV, or Excel.

```json
{
    "pmid": "38012345",
    "pmcid": "PMC10123456",
    "doi": "10.1038/s41586-024-01234-5",
    "title": "Durable protection against SARS-CoV-2 variants after boosting",
    "abstract": "...",
    "authors": ["Jane Smith", "John Doe"],
    "journal": "Nature",
    "mesh_terms": ["SARS-CoV-2", "Vaccines", "Immunization, Secondary"],
    "article_types": ["Journal Article", "Research Support, N.I.H., Extramural"],
    "publication_date": "2024-03-15",
    "pubmed_url": "https://pubmed.ncbi.nlm.nih.gov/38012345",
    "pdf_url": "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC10123456/pdf/",
    "source": "full_text",
    "chunks": [
        { "idx": 0, "text": "...", "tokens": 487 },
        { "idx": 1, "text": "...", "tokens": 512 }
    ]
}
```

`pmcid`, `doi`, `pdf_url` may be null. `source` is `"full_text"` when PMC OA NXML was parsed, `"abstract"` when it fell back.

#### Data table

| Field | Type | Description |
|---|---|---|
| `pmid` | string | PubMed ID (primary identifier) |
| `pmcid` | string? | PubMed Central ID (present for PMC OA papers) |
| `doi` | string? | DOI (when provided by PubMed) |
| `title` | string | Paper title |
| `abstract` | string | Abstract as returned by E-utilities |
| `authors` | string\[] | Author display names, order preserved |
| `journal` | string | Journal title |
| `mesh_terms` | string\[] | MeSH Descriptor headings assigned by NLM |
| `article_types` | string\[] | PubMed publication types |
| `publication_date` | ISO date | `YYYY-MM-DD` |
| `pubmed_url` | string | Link to the PubMed citation |
| `pdf_url` | string? | PMC PDF link, when available |
| `source` | `"full_text"` | `"abstract"` | Text origin |
| `chunks` | Chunk\[] | Token-aware chunks for RAG |
| `chunks[].idx` | number | 0-indexed position |
| `chunks[].text` | string | Chunk text |
| `chunks[].tokens` | number | Token count (≤ 512) |

### 💰 Pricing

**$0.02 per paper** (PPR, pay per result).

#### How much does it cost to scrape PubMed?

| Volume | Estimated cost |
|---|---|
| 100 papers | **~$2** |
| 1,000 papers | **~$20** |
| 10,000 papers | **~$200** |
| 100,000 papers | **~$2,000** |

No subscription. No minimum. You pay only for successful records.

### ⭐ Enjoying PubMed Scraper for RAG?

<table width="100%" style="display:table;width:100%;border-collapse:separate;border-spacing:0">
<tr>
<td style="padding:20px 24px 14px;background:#E6F5F3;border:1px solid #E6F5F3;border-left:5px solid #0F766E;border-radius:10px 10px 0 0;color:#1C1917">
<span style="font-size:20px;letter-spacing:4px">⭐ ⭐ ⭐ ⭐ ⭐</span><br>
<span style="font-size:17px;font-weight:800;color:#1C1917">If this Actor saved you from writing another PubMed XML parser, leave a quick review.</span><br>
<span style="font-size:14px;color:#57534E">A 5-star rating takes 10 seconds and helps other RAG engineers and biomedical researchers find it. Your feedback also tells us what to build next.</span>
</td>
</tr>
<tr>
<td style="padding:0;background:#0F766E;border:1px solid #0F766E;border-left:5px solid #0F766E;border-top:none;border-radius:0 0 10px 10px;text-align:center;color:#FFFFFF">
<a href="https://apify.com/getascraper/pubmed-rag-extractor/reviews" style="display:block;padding:13px 16px;color:#FFFFFF;text-decoration:none;font-weight:800;font-size:15px;letter-spacing:0.3px">★&nbsp;&nbsp;Rate this Actor on Apify</a>
</td>
</tr>
</table>

### ✨ Tips

- **Get an NCBI API key** (free at https://www.ncbi.nlm.nih.gov/account/settings/) for 10 req/s. Turns a 55-min run into roughly 17 min for 1000 papers.
- **Use specific `searchTerm` syntax.** PubMed query operators like `[ti]`, `[mh]`, `[au]`, `[dp]` work inside the `searchTerm` field. Example: `cancer[mh] AND immunotherapy[ti] AND 2024[dp]`.
- **Filter article types** to cut noise. `["review", "meta_analysis"]` removes editorials, letters, and news pieces.
- **`source: "abstract"` is expected for most records.** Only PMC OA papers have full-text NXML. Plan your RAG index accordingly (abstracts are dense and still make good chunks).
- **Schedule weekly runs** to keep an embedding index fresh on newly-published biomedical research.
- **For large backfills**, split into month-sized windows and run in parallel (separate Actor runs) to stay under the rate limit cleanly.

### ❓ FAQ and limitations

#### Is scraping PubMed legal?

PubMed's E-utilities API is explicitly designed for programmatic access ([E-utilities docs](https://www.ncbi.nlm.nih.gov/books/NBK25501/)). This Actor respects NCBI's stated rate limits (3 req/s without API key, 10 with) and fetches only publicly-available content. Full-text comes from the PMC Open Access subset, which is licensed for reuse under CC-BY or equivalent.

#### What's not in v1?

- **Other databases** (bioRxiv, medRxiv, ClinicalTrials.gov, Semantic Scholar). arXiv has its own companion Actor in this portfolio.
- **Species / affiliation / journal / language filters** are deferred to a v2 premium tier.
- **Citation graph** extraction.
- **PDF OCR** for non-PMC papers (they fall back to abstract).
- **Section-aware splitting** (Abstract / Methods / Results as separate records).
- **MeSH hierarchy expansion** (searching `Cancer` does not auto-include child terms).
- **Real-time streaming** or incremental sync.

#### Rate limits

- **Without API key:** 3 req/s (~55 min for 1000 papers)
- **With API key:** 10 req/s (~17 min for 1000 papers)

Get a free key at https://www.ncbi.nlm.nih.gov/account/settings/.

#### Support

Found a bug or want a feature? Use the **Issues** tab on the Actor's page. Custom requirements (other databases, different chunking, section-aware splitting)? Reach out via the Actor's Support link.

#### Disclaimer

Output metadata is from PubMed's public E-utilities API. Full text, when available, comes from the PMC Open Access archive, which is licensed under CC-BY or equivalent open licenses. Check individual papers' licenses on their PMC page before downstream commercial use.

**Built with Apify + Crawlee + TypeScript.** Part of the [actorstack](https://github.com/Devansh-365/actorstack) portfolio. Sister Actor: [arXiv Scraper for RAG](https://apify.com/devanshlive/arxiv-rag-extractor).

### 🔗 Other actors

- [arXiv scraper for RAG: papers as chunked JSON](https://apify.com/getascraper/arxiv-rag-extractor) ↗ - turns arXiv preprints into token-aware chunks for RAG pipelines.
- [bioRxiv and medRxiv scraper for RAG: chunked JSON](https://apify.com/getascraper/biorxiv-medrxiv-rag-extractor) ↗ - chunks bioRxiv and medRxiv preprints into RAG-ready JSON.
- [SEC EDGAR Scraper for RAG: 10-K/10-Q/8-K as JSON](https://apify.com/getascraper/sec-edgar-rag-extractor) ↗ - extracts SEC filings as chunked JSON for financial RAG systems.
- [CourtListener RAG extractor](https://apify.com/getascraper/courtlistener-rag-extractor) ↗ - converts US court opinions into chunked JSON for legal RAG pipelines.

# Actor input Schema

## `searchTerm` (type: `string`):

Enter any search query (such as 'heart disease' or 'SARS-CoV-2 vaccines').

## `meshTerms` (type: `array`):

Add specific Medical Subject Headings if you want to narrow down your medical topic.

## `articleTypes` (type: `array`):

Filter by article type (such as clinical trials, reviews, or meta-analyses). Leave empty for all.

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

Collect papers published on or after this date.

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

Collect papers published on or before this date.

## `maxPapers` (type: `integer`):

Set the maximum number of papers you want to save for this run.

## `ncbiApiKey` (type: `string`):

Paste your free NCBI API key to speed up collection. Get one on your NCBI settings page.

## Actor input object example

```json
{
  "searchTerm": "SARS-CoV-2 vaccines",
  "meshTerms": [],
  "articleTypes": [],
  "dateFrom": "2024-01-01",
  "dateTo": "2024-01-15",
  "maxPapers": 50
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

# 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 = {
    "searchTerm": "SARS-CoV-2 vaccines",
    "meshTerms": [],
    "articleTypes": [],
    "dateFrom": "2024-01-01",
    "dateTo": "2024-01-15",
    "maxPapers": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("getascraper/pubmed-rag-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 = {
    "searchTerm": "SARS-CoV-2 vaccines",
    "meshTerms": [],
    "articleTypes": [],
    "dateFrom": "2024-01-01",
    "dateTo": "2024-01-15",
    "maxPapers": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("getascraper/pubmed-rag-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 '{
  "searchTerm": "SARS-CoV-2 vaccines",
  "meshTerms": [],
  "articleTypes": [],
  "dateFrom": "2024-01-01",
  "dateTo": "2024-01-15",
  "maxPapers": 50
}' |
apify call getascraper/pubmed-rag-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,getascraper/pubmed-rag-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/Zd6dqQcd4Ikxz2zKK/builds/MVKDBQcVMiEUXtW2r/openapi.json
