# Bundle Size API
> How big is that npm package? Get the minified and gzipped bundle size of any npm package — plus its dependency count, the size contributed by each dependency, peer dependencies, whether it ships an ES module and whether it is side-effect-free — in a single call. Pin a version (react@18.2.0) or get the latest, and pull the bundle size across a package's recent versions to spot regressions over time. Powered by the public Bundlephobia service; results are live (no cache). 3 endpoints. Built for frontend performance budgets, bundle-size CI checks, "cost of adding this dependency" tooling, and dependency dashboards. Distinct from a plain npm registry lookup (metadata) or a dependency-graph service — this measures actual shipped bytes. No upstream key, no cache.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/bundlephobia-api/..."
```

## Pricing
- **Free** (Free) — 2,050 calls/Mo, 2 req/s
- **Starter** ($8/Mo) — 45,000 calls/Mo, 8 req/s
- **Pro** ($26/Mo) — 230,000 calls/Mo, 20 req/s
- **Mega** ($60/Mo) — 1,150,000 calls/Mo, 50 req/s

## Endpoints

### Bundle

#### `GET /v1/history` — Bundle size across versions

**Parameters:**
- `package` (query, required, string) — npm package Example: `express`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/bundlephobia-api/v1/history?package=express"
```

**Response:**
```json
{
    "data": {
        "count": 245,
        "history": [
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "0.14.0"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "0.14.1"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "1.0.0"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "1.0.1"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "1.0.2"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "1.0.3"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "1.0.4"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "1.0.5"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "1.0.6"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "1.0.7"
            },
            {
                "gzip_kb": null,
                "size_kb": null,
                "version": "1.0.8"
            },
         
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/size` — Bundle size of a package

**Parameters:**
- `package` (query, required, string) — npm package, optionally @version Example: `react`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/bundlephobia-api/v1/size?package=react"
```

**Response:**
```json
{
    "data": {
        "name": "react",
        "assets": [
            {
                "gzip": 2909,
                "name": "main",
                "size": 7593,
                "type": "js"
            }
        ],
        "gzip_kb": 2.84,
        "size_kb": 7.42,
        "version": "19.2.7",
        "gzip_bytes": 2909,
        "repository": "https://github.com/facebook/react.git",
        "size_bytes": 7593,
        "description": "React is a JavaScript library for building user interfaces.",
        "has_js_module": false,
        "dependency_count": 0,
        "dependency_sizes": [
            {
                "name": "react",
                "approximate_size_kb": 7.62,
                "approximate_size_bytes": 7798
            }
        ],
        "has_side_effects": true,
        "peer_dependencies": []
    },
    "meta": {
        "timestamp": "2026-06-02T16:52:08.829Z",
        "request_id": "904a613e-fd21-41d3-978a-76ae04cf03f9"
    },
    "status": "ok",
    "message": "Bundle size of a package",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/bundlephobia-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "auth": "none upstream; this gateway requires x-api-key",
        "name": "Bundle Size API",
        "note": "Minified + gzipped bundle size, dependency count and per-dependency size of any npm package. /v1/size?package=react (or react@18.2.0), /v1/history?package=react for size across recent versions. Live, no cache. Very large or never-before-measured packages may take a while to build upstream (504 on timeout).",
        "source": "Bundlephobia (bundlephobia.com/api) — public, no key",
        "endpoints": 3
    },
    "meta": {
        "timestamp": "2026-06-02T16:52:08.952Z",
        "request_id": "c41bca51-fe7d-468a-9de5-bae0b5396451"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/bundlephobia-api
OpenAPI spec: https://www.oanor.com/api/bundlephobia-api/openapi.json
