# Cran R Packages Scraper (`b2b_lead_generation/cran-r-packages-scraper`) Actor

CRAN R Packages Scraper extracts public R package metadata, version histories, and download counts. Quickly build lightweight package inventories and export your structured datasets as JSON, CSV, or Excel directly from Apify

- **URL**: https://apify.com/b2b_lead_generation/cran-r-packages-scraper.md
- **Developed by:** [B2B Lead Generation](https://apify.com/b2b_lead_generation) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 results

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

### CRAN R Packages Scraper: R Package Metadata & Stats

CRAN R Packages Scraper lets you easily gather metadata, release history, and download stats for public R packages. Just plug in package names like `ggplot2` or `dplyr`, choose what details you want to extract, and export structured rows directly to JSON, CSV, or Excel on Apify.

Whether you're running a quick audit on dependencies or setting up a recurring inventory to track package adoption, this tool handles the heavy lifting smoothly.

### Use Cases

- **Package Lookups**: Quickly extract key information such as package titles, versions, licenses, maintainers, and import dependencies for any list of CRAN packages.
- **Release Tracking**: Review all past published versions of a given package in one clean dataset without jumping around manual web pages.
- **Download Metrics**: Record download metrics over recent days, weeks, months, or custom date windows to track usage trends.
- **Dependency Auditing**: Keep imported dependencies linked to each package name for lightweight supply chain or repository reviews.
- **Data Exports**: Download structured datasets straight into CSV, JSON, or Excel format whenever your run finishes.
- **Scheduled Monitoring**: Set up recurring runs to automatically maintain an up-to-date inventory of your critical R dependencies.

### Data Extracted

Depending on the mode you select, the scraper collects structured records across three primary focus areas:

- **Metadata**: Collects core package details including title, version, description, license, maintainer, publication date, and dependency lists.
- **Version History**: Lists historical releases for specified packages to track updates over time.
- **Downloads**: Summarizes download metrics across standard or custom timeframes.

### Input Setup

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `mode` | string | `package` | Choose between metadata, version history, or download totals. |
| `packages` | array | `ggplot2`, `dplyr` | List of CRAN package names to query. |
| `period` | string | `last-month` | Download range: `last-day`, `last-week`, `last-month`, or custom `YYYY-MM-DD:YYYY-MM-DD`. |
| `requestDelaySecs` | number | `1` | Pause duration between requests to keep execution steady. |
| `userAgent` | string | Custom User Agent | Identifier sent with outgoing network requests. |
| `timeoutSecs` | integer | `300` | Overall run duration limit in seconds. |
| `requestTimeoutSecs` | integer | `30` | Timeout duration for individual request calls. |
| `proxyConfiguration` | object | `{}` | Optional proxy configuration settings. |

#### Example Input

```json
{
  "mode": "package",
  "packages": ["ggplot2", "dplyr"],
  "period": "last-month",
  "requestDelaySecs": 1,
  "userAgent": "",
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {}
}

```

### Dataset Output

Output data is sent directly to your dataset. Here is a typical output record for package metadata:

```json
{
  "Package": "ggplot2",
  "Title": "Create Elegant Data Visualisations Using the Grammar of Graphics",
  "Version": "4.0.3",
  "Description": "A system for declaratively creating graphics, based on The Grammar of Graphics.",
  "License": "MIT + file LICENSE",
  "URL": "[https://ggplot2.tidyverse.org](https://ggplot2.tidyverse.org)",
  "Maintainer": "Thomas Lin Pedersen <thomas.pedersen@posit.co>",
  "Imports": {
    "cli": "*",
    "rlang": ">= 1.1.0"
  },
  "Date_Publication": "2026-04-22 09:10:03 UTC",
  "downloads_last_month": null,
  "scraped_at": "2026-10-12T00:00:00+00:00"
}

```

| Field | Type | Description |
| --- | --- | --- |
| `Package` | string | Name of the CRAN package. |
| `Title` | string | Official short title of the package. |
| `Version` | string | Current version number. |
| `Description` | string | Summary description of the package purpose. |
| `License` | string | Applicable software license terms. |
| `URL` | string | Official website or repository URL. |
| `Maintainer` | string | Listed primary maintainer or author contact. |
| `Imports` | object | Map of required package dependencies. |
| `Date_Publication` | string | Timestamp of the release publication. |
| `downloads_last_month` | integer | Download count recorded for your specified timeframe. |
| `scraped_at` | string | UTC timestamp indicating when the data was extracted. |

If a package name is typed incorrectly or cannot be located, the run logs a clear error record with details while continuing through the rest of your package list uninterrupted.

### How It Works

1. Parses your input list, mode selection, and time period filters.
2. Formats incoming requests and executes queries sequentially with custom delays.
3. Maps returned structure into standardized key-value outputs.
4. Streams structured records directly into your output dataset for easy viewing and export.

### FAQ

**Can I export my results as CSV or Excel?**

Yes. Once your run completes, you can export the output dataset directly as CSV, JSON, Excel, or XML from the dataset tab.

**What happens if a package name isn't found?**

If a package name is invalid or missing, an error record is saved for that specific item, and the scraper continues processing the remaining package list.

**Which download ranges can I specify?**

You can set predefined ranges like `last-day`, `last-week`, or `last-month`, or specify custom date ranges formatted as `YYYY-MM-DD:YYYY-MM-DD`.

#### Trademark Notice

CRAN R Packages and related names, logos, and trademarks belong to their respective owners. Their use in this documentation is solely to identify the target software ecosystem and does not imply affiliation, sponsorship, or endorsement.

#### Disclaimer

This tool is an independent scraper and is not affiliated with, endorsed by, or sponsored by CRAN R Packages or its maintainers. All data is gathered from publicly available ecosystem records. Users are responsible for complying with relevant usage guidelines, rates, and attribution guidelines.

#### Is web scraping legal?

This scraper only collects publicly available data from CRAN R Packages without bypassing any access restrictions. Extracting public data is generally legal, though how you utilize the extracted datasets remains your responsibility:

- **Personal Data**: If extracted records contain personal details (such as developer names or contact email addresses), compliance regulations such as GDPR or CCPA may apply depending on your region. Collect and process personal data only when you have a clear, legitimate reason to do so.
- **Copyright**: Descriptions, documentation text, and software materials may fall under specific software licenses or copyrights. Ensure you respect license terms when reusing content.
- **Terms & Usage**: Be respectful of target site guidelines, request frequencies, and attribution requirements.
- **Legal Advice**: This overview provides general guidance and is not formal legal advice. Please consult qualified legal counsel if you have specific compliance questions.

To learn more, read Apify's guide: [Is web scraping legal?](https://blog.apify.com/is-web-scraping-legal/)

# Actor input Schema

## `mode` (type: `string`):

What to collect. Metadata reads the current crandb record, version history reads every published release, and downloads reads cranlogs totals for the chosen period.

## `packages` (type: `array`):

CRAN package names, one per line. Names are URL-encoded and looked up on the public crandb or cranlogs endpoints.

## `period` (type: `string`):

Used in downloads mode. One of last-day, last-week, last-month, or a range written as YYYY-MM-DD:YYYY-MM-DD.

## `requestDelaySecs` (type: `number`):

Seconds to wait between HTTP calls so crandb and cranlogs are not burst.

## `userAgent` (type: `string`):

User-Agent sent on every request. Keep a contact address so the source can identify the client.

## `timeoutSecs` (type: `integer`):

Maximum seconds the actor may spend collecting data. The run stops when this elapses and keeps rows already saved.

## `requestTimeoutSecs` (type: `integer`):

Seconds to wait for a single HTTP response before that call is treated as a timeout.

## `proxyConfiguration` (type: `object`):

Optional proxy. The default sends requests with no proxy. Enable Apify Proxy or custom proxy URLs only if you need another IP.

## Actor input object example

```json
{
  "mode": "package",
  "packages": [
    "ggplot2",
    "dplyr"
  ],
  "period": "last-month",
  "requestDelaySecs": 1,
  "userAgent": "",
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Default dataset with package, version, and download rows.

## `overview` (type: `string`):

Table view of the default dataset.

# 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 = {
    "packages": [
        "ggplot2",
        "dplyr"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("b2b_lead_generation/cran-r-packages-scraper").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 = {
    "packages": [
        "ggplot2",
        "dplyr",
    ],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("b2b_lead_generation/cran-r-packages-scraper").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 '{
  "packages": [
    "ggplot2",
    "dplyr"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call b2b_lead_generation/cran-r-packages-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,b2b_lead_generation/cran-r-packages-scraper"
        }
    }
}
```

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/1l6ZQsQPGpoL1gFna/builds/d9ahrwhCiJRLrJZN4/openapi.json
