# npm Download Stats (`npm.downloads`)

Download counts of an npm package for the last week, month or year, day by day (weekly totals for a year).

- **Route:** `POST /v1/run/npm.downloads`
- **Price:** $0.0008 per request ($0.80 per 1,000) · `cost_usd` on every response
- **Source:** npm registry (`npm`) · failover: no
- **Measured latency:** p50 684 ms · p95 684 ms · p99 684 ms (1 calls, 30d)
- **Heavy response:** no

## Input

| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
| `name` | string | yes |  | Package name |
| `period` | string | no | "last-month" | Period |

## Output (`output` in the run envelope)

| Field | Meaning |
|---|---|
| `total_downloads` | Sum over the period. |
| `daily_average` | Average per day. |
| `daily` | date and downloads per day (week and month). |
| `weekly` | Weekly totals (year). |

## Example

```bash
curl -s -X POST https://getallapis.com/v1/run/npm.downloads \
  -H "Authorization: Bearer $GETALLAPIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"react","period":"last-week"}'
```

```python
from getallapis_client import Client
client = Client()  # reads GETALLAPIS_API_KEY
result = client.run('npm.downloads', {'name': 'react', 'period': 'last-week'})
print(result['cost_usd'], result['output'])
```

```bash
getallapis run npm.downloads '{"name":"react","period":"last-week"}'
```

Quote first (free, validates input): `POST /v1/quote/npm.downloads` with the same body.
