# packagephobia (API)
> API wrapper for [Package Phobia](https://github.com/styfle/packagephobia): get the publish and install size from any package in the [NPM registry](https://www.npmjs.com).

## Features
- Written using TypeScript (and thus fully typed, supporting TypeScript and JavaScript).
- Lightweight.
- Supports ESM and CJS.

## Installation
```
# npm
npm i packagephobia

# yarn
yarn add packagephobia
```

## Usage
```ts
import packagephobia from 'packagephobia'
const data = await packagephobia( 'undici' )
```

```json
{
  name: 'undici',
  version: '4.14.1',
  publish: { bytes: 792635, files: 109, pretty: '774 kB', color: '#97CA00' },
  install: { bytes: 792635, files: 109, pretty: '774 kB', color: '#97CA00' }
}
```

### Notes
- By default, it uses API v2. To use API v1, pass a second parameter to the function with the number.
```ts
import packagephobia from 'packagephobia'
const data = await packagephobia( 'undici', 1 )
```

```json
{
	installSize: 792635,
	publishSize: 792635
}
```

- For more information about Package Phobia, [check its repository](https://github.com/styfle/packagephobia).

## Why?
This package is typed, so you can be sure about the available properties in the response.

### Alternatives
Run your favorite requests package (`node-fetch`, `request`, `undici`) and make the request yourself.
