# download

> Download and extract files

Latest version **8.0.0** (published 2020-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install download
pnpm add download
yarn add download
bun add download
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.0.0 |
| Published | 2020-04-02 |
| First published | 2013-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/download) |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 11 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1298 |
| Author | Kevin Mårtensson |
| Maintainers | kevva, shinnn, silverwind, sindresorhus |
| Keywords | download, extract, http, request, url |

## Links

- npm: https://www.npmjs.com/package/download
- Repository: https://github.com/kevva/download
- Homepage: https://github.com/kevva/download#readme
- Issues: https://github.com/kevva/download/issues
- npm.io page: https://npm.io/package/download

## Dependencies (11)

- [got](https://npm.io/package/got.md) ^8.3.1
- [pify](https://npm.io/package/pify.md) ^4.0.1
- [p-event](https://npm.io/package/p-event.md) ^2.1.0
- [ext-name](https://npm.io/package/ext-name.md) ^5.0.0
- [make-dir](https://npm.io/package/make-dir.md) ^2.1.0
- [file-type](https://npm.io/package/file-type.md) ^11.1.0
- [decompress](https://npm.io/package/decompress.md) ^4.2.1
- [filenamify](https://npm.io/package/filenamify.md) ^3.0.0
- [get-stream](https://npm.io/package/get-stream.md) ^4.1.0
- [archive-type](https://npm.io/package/archive-type.md) ^4.0.0
- [content-disposition](https://npm.io/package/content-disposition.md) ^0.5.2

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 8.0.0 (latest) — 2020-04-02
- 4.0.1-rc.1 (rc) — 2015-02-09
- 7.1.0 — 2018-07-11
- 7.0.0 — 2018-05-02
- 6.2.5 — 2017-06-28
- 6.2.4 — 2017-06-28
- 6.2.3 — 2017-06-18
- 6.2.2 — 2017-05-29
- 6.2.1 — 2017-05-26
- 6.2.0 — 2017-05-23
- 6.1.0 — 2017-05-12
- 6.0.0 — 2017-04-28
- 5.0.3 — 2017-01-24
- 5.0.2 — 2016-06-09
- 5.0.1 — 2016-06-08
- … 55 more at https://npm.io/package/download/versions

## README

# download [![Build Status](https://travis-ci.org/kevva/download.svg?branch=master)](https://travis-ci.org/kevva/download)

> Download and extract files

*See [download-cli](https://github.com/kevva/download-cli) for the command-line version.*


## Install

```
$ npm install download
```


## Usage

```js
const fs = require('fs');
const download = require('download');

(async () => {
	await download('http://unicorn.com/foo.jpg', 'dist');

	fs.writeFileSync('dist/foo.jpg', await download('http://unicorn.com/foo.jpg'));

	download('unicorn.com/foo.jpg').pipe(fs.createWriteStream('dist/foo.jpg'));

	await Promise.all([
		'unicorn.com/foo.jpg',
		'cats.com/dancing.gif'
	].map(url => download(url, 'dist')));
})();
```

### Proxies

To work with proxies, read the [`got documentation`](https://github.com/sindresorhus/got#proxies).


## API

### download(url, destination?, options?)

Returns both a `Promise<Buffer>` and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with [additional events](https://github.com/sindresorhus/got#streams-1).

#### url

Type: `string`

URL to download.

#### destination

Type: `string`

Path to where your file will be written.

#### options

Type: `Object`

Same options as [`got`](https://github.com/sindresorhus/got#options) and [`decompress`](https://github.com/kevva/decompress#options) in addition to the ones below.

##### extract

Type: `boolean`<br>
Default: `false`

If set to `true`, try extracting the file using [`decompress`](https://github.com/kevva/decompress).

##### filename

Type: `string`

Name of the saved file.

---
_Source: https://npm.io/package/download · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
