# arXiv Scraper for RAG: Papers as Chunked JSON (`devanshlive/arxiv-rag-extractor`) Actor

Scrape arXiv papers by date and category. Strips LaTeX and returns RAG-ready JSON with tokenizer-aware chunks (cl100k\_base, 512/50). Drop-in for LangChain, LlamaIndex, Qdrant, Pinecone, Weaviate, pgvector, Chroma. Skip GROBID / Nougat / pandoc. $0.015 per paper.

- **URL**: https://apify.com/devanshlive/arxiv-rag-extractor.md
- **Developed by:** [Devansh Tiwari](https://apify.com/devanshlive) (community)
- **Categories:** AI, Agents, Developer tools
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $15.00 / 1,000 papers

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## arXiv Scraper for RAG: Papers as Chunked JSON

**Scrape arXiv research papers into RAG-ready JSON in one call.** Pulls papers by date range and category, strips the LaTeX source to clean text, and 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 and anyone who's fought GROBID, Nougat, or pandoc trying to get arXiv into an embedding pipeline.

### What does arXiv Scraper for RAG do?

This Apify Actor scrapes **[arXiv](https://arxiv.org/)** papers within a date range and category filter, fetches the LaTeX source for each paper, strips the markup, 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 (title, authors, categories, DOI, PDF URL, published/updated dates) 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 category (e.g. `cs.LG`), a date range, a paper cap, and hit Start. Download the 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 when needed, monitoring, and alerts. No infrastructure to run yourself.

### Why use arXiv Scraper for RAG?

- **Skip the LaTeX parsing hell.** Papers are delivered as plain text, not `\begin{equation}...\end{equation}` soup. No GROBID, no Nougat, no custom macro handlers.
- **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.** Drops straight into **Qdrant, Pinecone, Weaviate, pgvector (Supabase / Neon), Chroma, and Milvus** without reformatting.
- **Framework-ready.** Works out of the box with **LangChain, LlamaIndex, Haystack, and LangGraph** pipelines.
- **Dates + categories**, not URLs. No need to scrape arXiv listing pages yourself.
- **Respects arXiv's rate limits.** 1 request per 3 seconds, handled server-side, so you won't get IP-banned.
- **Cheap.** $0.015 per paper. A week of cs.LG submissions (~500 papers) costs under $8.

### How to use arXiv RAG Extractor

1. **Open the Actor** in Apify Console.
2. **Set `dateFrom` and `dateTo`** in `YYYY-MM-DD` format (these are inclusive submission-date bounds).
3. **(Optional) Set `categoriesFilter`**: an array of arXiv category tags like `["cs.LG", "cs.AI", "stat.ML"]`. Leave empty to include all categories.
4. **(Optional) Set `maxPapers`**: default 1000. A hard upper bound per run.
5. **Click Start.** Expect ~3 seconds per paper due to arXiv's rate limit (1000 papers ≈ 50 min minimum).
6. **Download results** from the Storage tab as JSON, CSV, or Excel, or hit the API endpoint programmatically.

### Input

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `dateFrom` | string (`YYYY-MM-DD`) | ✅ | | Inclusive lower bound of paper submission date |
| `dateTo` | string (`YYYY-MM-DD`) | ✅ | | Inclusive upper bound of paper submission date |
| `categoriesFilter` | string[] | | `[]` | arXiv category tags. Empty = all categories |
| `maxPapers` | integer | | `1000` | Hard cap on papers returned (1 to 100000) |

**Example input:**

```json
{
    "categoriesFilter": ["cs.LG", "cs.AI"],
    "dateFrom": "2024-01-01",
    "dateTo": "2024-01-07",
    "maxPapers": 500
}
````

### Output

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

```json
{
    "arxiv_id": "2401.12345",
    "title": "Attention Is All You Need",
    "abstract": "The dominant sequence transduction models...",
    "authors": ["Ashish Vaswani", "Noam Shazeer", "..."],
    "categories": ["cs.LG", "cs.CL"],
    "published": "2024-01-15T00:00:00Z",
    "updated": "2024-01-18T00:00:00Z",
    "doi": "10.48550/arXiv.2401.12345",
    "pdf_url": "https://arxiv.org/pdf/2401.12345v1",
    "source": "latex",
    "chunks": [
        { "idx": 0, "text": "...", "tokens": 512 },
        { "idx": 1, "text": "...", "tokens": 512 },
        { "idx": 2, "text": "...", "tokens": 487 }
    ]
}
```

#### Data table

| Field | Type | Description |
|---|---|---|
| `arxiv_id` | string | arXiv identifier (e.g. `2401.12345`) |
| `title` | string | Paper title (whitespace-normalized) |
| `abstract` | string | Abstract as returned by arXiv |
| `authors` | string\[] | Author display names, order preserved |
| `categories` | string\[] | arXiv category tags |
| `published` | ISO date | First submission datetime |
| `updated` | ISO date | Latest update datetime |
| `doi` | string? | DOI (when provided by arXiv) |
| `pdf_url` | string | Direct PDF link |
| `source` | `"latex"` | `"abstract"` | Text origin: `latex` if source was extractable, `abstract` as fallback |
| `chunks` | Chunk\[] | Fixed-token chunks ready for embedding |
| `chunks[].idx` | number | 0-indexed position |
| `chunks[].text` | string | Chunk text |
| `chunks[].tokens` | number | Token count under cl100k\_base (≤ 512) |

### Pricing

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

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

| Volume | Estimated cost |
|---|---|
| 100 papers | **~$1.50** |
| 1,000 papers | **~$15** |
| 10,000 papers | **~$150** |
| 100,000 papers | **~$1,500** |

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

### Tips

- **Narrow the category filter.** Running on all of arXiv will hit your `maxPapers` cap fast. Use specific cats like `cs.LG`, `stat.ML`, `q-bio.QM`.
- **Short date windows for testing.** 1-week windows are a good smoke test (200-800 papers for cs.LG).
- **`source: "abstract"` means no LaTeX source was available.** Either arXiv only hosts a PDF, or the tarball was unreadable. About 5 to 10% of papers fall into this category depending on era.
- **Schedule weekly runs** to keep an embedding index fresh on newly-published research.
- **For large backfills**, split into month-sized windows and run in parallel (separate Actor runs) to stay under the 3-sec rate limit cleanly.

### FAQ and limitations

#### Is scraping arXiv legal?

arXiv offers an open API expressly for programmatic access ([arXiv API Access](https://info.arxiv.org/help/api/index.html)). This Actor respects arXiv's stated rate limit of 1 request every 3 seconds on `export.arxiv.org` and fetches only publicly-available content.

#### What's *not* in v1?

- **Multi-source** (PubMed, bioRxiv, Semantic Scholar). arXiv only for v1.
- **Entity extraction** (datasets, tasks, models).
- **Section-aware splitting** (we chunk by fixed tokens across the whole paper).
- **Equation / figure / table preservation**. These are dropped by the LaTeX stripper.
- **Semantic chunking**. Fixed-token only.
- **Custom chunk sizes**. Hardcoded at 512/50 for v1.

Many of these land in v2. Open an issue (Issues tab) if one is blocking for you.

#### Rate limits

- **arXiv API:** 1 request per 3 seconds (enforced). ~1000 papers minimum run time ≈ 50 minutes.
- **arXiv e-print:** Same rate limit, handled independently.

#### Support

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

#### Disclaimer

Output metadata is from arXiv's public API. Full text, when available, is from arXiv's public e-print archive. All content remains under the license specified by the paper's authors on arXiv. Check `arxiv.org/abs/<arxiv_id>` for each paper's license before downstream use (CC-BY, CC-0, arXiv non-exclusive, etc. Some papers do not permit commercial redistribution).

***

**Built with Apify + Crawlee + TypeScript.** Part of the [actorstack](https://github.com/devanshtiwari/actorstack) portfolio.

# Actor input Schema

## `categoriesFilter` (type: `array`):

arXiv category tags (e.g. cs.LG, cs.AI, stat.ML). Leave empty to include all categories.

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

Inclusive lower bound of paper submission date.

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

Inclusive upper bound of paper submission date.

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

Hard cap on how many papers will be returned. Rate limit is 1 request per 3 seconds, so 1000 papers takes around 50 minutes.

## Actor input object example

```json
{
  "categoriesFilter": [
    "cs.LG"
  ],
  "dateFrom": "2024-01-01",
  "dateTo": "2024-01-02",
  "maxPapers": 50
}
```

# Actor output Schema

## `results` (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 = {
    "categoriesFilter": [
        "cs.LG"
    ],
    "dateFrom": "2024-01-01",
    "dateTo": "2024-01-02",
    "maxPapers": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("devanshlive/arxiv-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 = {
    "categoriesFilter": ["cs.LG"],
    "dateFrom": "2024-01-01",
    "dateTo": "2024-01-02",
    "maxPapers": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("devanshlive/arxiv-rag-extractor").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "categoriesFilter": [
    "cs.LG"
  ],
  "dateFrom": "2024-01-01",
  "dateTo": "2024-01-02",
  "maxPapers": 50
}' |
apify call devanshlive/arxiv-rag-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=devanshlive/arxiv-rag-extractor",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "arXiv Scraper for RAG: Papers as Chunked JSON",
        "description": "Scrape arXiv papers by date and category. Strips LaTeX and returns RAG-ready JSON with tokenizer-aware chunks (cl100k_base, 512/50). Drop-in for LangChain, LlamaIndex, Qdrant, Pinecone, Weaviate, pgvector, Chroma. Skip GROBID / Nougat / pandoc. $0.015 per paper.",
        "version": "0.1",
        "x-build-id": "VXgkdVaNVNyerwZsh"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/devanshlive~arxiv-rag-extractor/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-devanshlive-arxiv-rag-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/devanshlive~arxiv-rag-extractor/runs": {
            "post": {
                "operationId": "runs-sync-devanshlive-arxiv-rag-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/devanshlive~arxiv-rag-extractor/run-sync": {
            "post": {
                "operationId": "run-sync-devanshlive-arxiv-rag-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "categoriesFilter": {
                        "title": "Categories",
                        "type": "array",
                        "description": "arXiv category tags (e.g. cs.LG, cs.AI, stat.ML). Leave empty to include all categories.",
                        "items": {
                            "type": "string"
                        },
                        "default": [
                            "cs.LG"
                        ]
                    },
                    "dateFrom": {
                        "title": "From date (YYYY-MM-DD)",
                        "type": "string",
                        "description": "Inclusive lower bound of paper submission date.",
                        "default": "2024-01-01"
                    },
                    "dateTo": {
                        "title": "To date (YYYY-MM-DD)",
                        "type": "string",
                        "description": "Inclusive upper bound of paper submission date.",
                        "default": "2024-01-02"
                    },
                    "maxPapers": {
                        "title": "Max papers per run",
                        "minimum": 1,
                        "maximum": 100000,
                        "type": "integer",
                        "description": "Hard cap on how many papers will be returned. Rate limit is 1 request per 3 seconds, so 1000 papers takes around 50 minutes.",
                        "default": 50
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
