# downloads
Documentation: [Chrome Downloads API](https://developer.chrome.com/docs/extensions/reference/downloads)
A promise-based wrapper for the Chrome `downloads` API.
## Methods
- [acceptDownloadDanger(downloadId)](#acceptDownloadDanger)
- [cancelDownload(downloadId)](#cancelDownload)
- [download(options)](#download)
- [eraseDownload(query)](#eraseDownload)
- [getDownloadFileIcon(downloadId, options)](#getDownloadFileIcon)
- [openDownload(downloadId)](#openDownload)
- [pauseDownload(downloadId)](#pauseDownload)
- [removeDownloadFile(downloadId)](#removeDownloadFile)
- [resumeDownload(downloadId)](#resumeDownload)
- [searchDownloads(query)](#searchDownloads)
- [setDownloadsUiOptions(enabled)](#setDownloadsUiOptions)
- [showDownloadFolder()](#showDownloadFolder)
- [showDownload(downloadId)](#showDownload)
- [findDownload(downloadId)](#findDownload)
- [isDownloadExists(downloadId)](#isDownloadExists)
- [getDownloadState(downloadId?)](#getDownloadState)
## Events
- [onDownloadsChanged(callback)](#onDownloadsChanged)
- [onDownloadsCreated(callback)](#onDownloadsCreated)
- [onDownloadsDeterminingFilename(callback)](#onDownloadsDeterminingFilename)
---
### acceptDownloadDanger
```
acceptDownloadDanger(downloadId: number): Promise
```
Accepts a dangerous download, allowing it to proceed.
### cancelDownload
```
cancelDownload(downloadId: number): Promise
```
Cancels the specified download.
### download
```
download(options: chrome.downloads.DownloadOptions): Promise
```
Initiates a download with the given options, resolving to the download ID. The wrapper sets `conflictAction: "uniquify"` by default and validates early errors. May throw `BlockDownloadError` if the download is interrupted (e.g., `USER_CANCELED`).
### eraseDownload
```
eraseDownload(query: chrome.downloads.DownloadQuery): Promise
```
Removes the download history entries that match the given query, returning the list of erased download IDs.
### getDownloadFileIcon
```
getDownloadFileIcon(downloadId: number, options: chrome.downloads.GetFileIconOptions): Promise
```
Retrieves the icon URL for the downloaded file, if available.
### openDownload
```
openDownload(downloadId: number): Promise
```
Opens the downloaded file.
### pauseDownload
```
pauseDownload(downloadId: number): Promise
```
Pauses an active download.
### removeDownloadFile
```
removeDownloadFile(downloadId: number): Promise
```
Deletes the downloaded file from the local disk.
### resumeDownload
```
resumeDownload(downloadId: number): Promise
```
Resumes a paused download.
### searchDownloads
```
searchDownloads(query: chrome.downloads.DownloadQuery): Promise
```
Searches for downloads matching the specified query.
### setDownloadsUiOptions
```
setDownloadsUiOptions(enabled: boolean): Promise
```
Enables or disables the browser's default download UI.
### showDownloadFolder
```
showDownloadFolder(): void
```
Shows the default download folder in the file explorer.
### showDownload
```
showDownload(downloadId: number): Promise
```
Attempts to reveal the specified download in the file explorer, returning `true` if it exists.
### findDownload
```
findDownload(downloadId: number): Promise
```
Retrieves the download item for the given download ID, if it exists.
### isDownloadExists
```
isDownloadExists(downloadId: number): Promise
```
Checks whether a download with the specified ID exists.
### getDownloadState
```
getDownloadState(downloadId?: number): Promise
```
Retrieves the state (`in_progress`, `complete`, or `interrupted`) of the given download.
### onDownloadsChanged
```
onDownloadsChanged(
callback: (downloadDelta: chrome.downloads.DownloadDelta) => void
): () => void
```
Adds a listener triggered when a download's state or properties change. Returns an unsubscribe function.
### onDownloadsCreated
```
onDownloadsCreated(
callback: (downloadItem: chrome.downloads.DownloadItem) => void
): () => void
```
Adds a listener triggered when a new download is created. Returns an unsubscribe function.
### onDownloadsDeterminingFilename
```
onDownloadsDeterminingFilename(
callback: (
downloadItem: chrome.downloads.DownloadItem,
suggest: (suggestion?: chrome.downloads.FilenameSuggestion) => void
) => void
): () => void
```
Adds a listener triggered when a download's filename is being determined. Returns an unsubscribe function.