The downloads API allows you to programmatically initiate, monitor, manipulate, and search for downloads.

Manifest

You must declare the 'downloads' permission in the extension manifest to use this API, along with host permissions for any hosts that you may pass to $ref:downloads.download.

{
  'name': 'My extension',
  ...
  'permissions': [
    'downloads',
    '*://*.google.com'
  ],
  ...
}

If the URL's hostname is not specified in the permissions, then $ref:downloads.download will call its callback with a null downloadId and set the $ref:runtime.lastError object to indicate that the extension does not have permission to access that hostname.

Examples

You can find simple examples of using the downloads module in the examples/api/downloads directory. For other examples and for help in viewing the source code, see Samples.