# Bundlephobia Package Size Scraper (`b2b_lead_generation/bundlephobia-package-size-scraper`) Actor

Scrape minified and gzipped sizes, dependency counts, and metadata for npm packages instantly. Export clean JSON, CSV, or Excel datasets.

- **URL**: https://apify.com/b2b_lead_generation/bundlephobia-package-size-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

### Bundlephobia Package Size Scraper

Get minified and gzip bundle sizes for npm packages instantly. results are neatly formatted in your Apify dataset for easy export as JSON, CSV, or Excel.

Provide a simple package name like `react`, or pin a specific release version using `lodash@4.17.21`. The scraper processes your list sequentially, handles missing items gracefully without stopping the run, and records helpful error details if a package cannot be found.

### Use cases

- **Frontend budget**: Compare gzip bytes for the libraries you plan to add to your project
- **Dependency review**: Record minified size, gzip size, and dependency counts across a sample of packages
- **Version pin checks**: Target specific releases when the latest tag isn't what you ship in production
- **Recurring watch**: Schedule regular runs for your package lists to monitor size changes over time
- **Spreadsheet export**: Download CSV or Excel files for your platform or design reviews
- **Missing package handling**: Keep runs moving even if a package name returns a 404, logging status details cleanly

### What data does this actor extract?

| Field | Type | Description |
| --- | --- | --- |
| `name` | string | Package name |
| `version` | string | Resolved package version |
| `packageDescription` | string | Short description from the package info |
| `size` | integer | Minified size in bytes |
| `gzip` | integer | Gzipped size in bytes |
| `dependencyCount` | integer | Total dependency count |
| `hasJSModule` | boolean | Whether an ESM entry is reported |
| `hasSideEffects` | boolean | Whether side effects are declared |
| `repository` | string | Repository URL if available |
| `scraped_at` | string | UTC timestamp |
| `error` | string | Failure note on error rows |
| `url` | string | Request URL on error rows |
| `status` | integer | HTTP status on error rows |
| `message` | string | Failure message for error views |

***

### Input configuration

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | string | `sizes` | Size checking mode |
| `packages` | array | `["react", "lodash@4.17.21"]` | List of npm names and optional `@version` tags |
| `requestDelaySecs` | number | `1` | Wait time between requests |
| `userAgent` | string | `BigiByteActorResearch/1.0` | Custom client identifier |
| `timeoutSecs` | integer | `300` | Overall run time limit in seconds |
| `requestTimeoutSecs` | integer | `30` | Individual request timeout limit |
| `proxyConfiguration` | object | `{"useApifyProxy": false}` | Optional proxy settings |

#### Example input

```json
{
  "mode": "sizes",
  "packages": ["react", "lodash@4.17.21"],
  "requestDelaySecs": 1,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": { "useApifyProxy": false }
}

```

***

#### Trademark Notice

All product names, logos, and brands belong to their respective owners. Use of these names does not imply endorsement or official partnership.

***

### FAQ

**Can I export CSV?**
Yes. Open the dataset and export JSON, CSV, or Excel.

**What happens if a package name is wrong?**
You get one error row with status 404 and the request URL. The rest of the list still runs.

**Why is the description field called packageDescription?**
Apify reserves the name `description` in dataset schemas. The text is the same field the size payload calls description.

***

### Is web scraping legal?

This Actor only collects publicly available data without bypassing any access controls or restrictions. Scraping public data is generally standard practice, but how you use the data matters:

- **Personal data:** If results include personal details, applicable privacy regulations like GDPR or CCPA may govern how you store and process that information. Only collect personal data when you have a valid, legitimate purpose.
- **Copyright:** Content such as descriptions or text snippets may be protected by copyright. Avoid republishing full copyrighted materials without permission.
- **Terms of use:** Always respect platform guidelines, stated rate limits, and attribution requirements.
- **Legal advice:** This overview is for general informational purposes and does not constitute legal counsel. Consult a professional if you have specific legal 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`):

Bundle size calls GET https://bundlephobia.com/api/size?package= for each npm package name, with an optional @version.

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

npm package names, one per line. Add @version when you want a specific release, for example lodash@4.17.21. Scoped names such as @scope/name are sent as the package query.

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

Seconds to wait before each request after the first. The size endpoint advertises 120 requests per minute. Keep the default of 1 second.

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

User-Agent sent on every request. Include an app name and a contact so the host can identify the client.

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

Stop the run after this many seconds and keep rows already collected. Default 300. Maximum 3600.

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

How long to wait for one response before treating that call as failed. Default 30 seconds.

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

Optional proxy for size requests. Leave useApifyProxy off. The public Bundlephobia size endpoint does not need a proxy.

## Actor input object example

```json
{
  "mode": "sizes",
  "packages": [
    "react",
    "lodash@4.17.21"
  ],
  "requestDelaySecs": 1,
  "userAgent": "",
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Package name, version, minified bytes, gzip bytes, dependency count, and source URL.

## `errors` (type: `string`):

Failed requests with URL, HTTP status, and message.

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

Every row from the run, without a table view applied.

# 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": [
        "react",
        "lodash@4.17.21"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("b2b_lead_generation/bundlephobia-package-size-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": [
        "react",
        "lodash@4.17.21",
    ],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("b2b_lead_generation/bundlephobia-package-size-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": [
    "react",
    "lodash@4.17.21"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call b2b_lead_generation/bundlephobia-package-size-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,b2b_lead_generation/bundlephobia-package-size-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/hOtzm4EG5rYmHf5dz/builds/iZCZs6Xpn9v0ASM2G/openapi.json
