# DownloaderAPI Protocol

    public protocol DownloaderAPI : InterceptableAPI

Downloader Interface.

- `createDownload(_:headers:allowCellularAccess:)` Default implementation

  Creates a download for a given player configuration.

  Player Configuration is verified in the `prepare` method

  #### Default Implementation

  #### Declaration

  Swift

      func createDownload(
          _ config: PlayerConfiguration,
          headers: [String: String],
          allowCellularAccess: Bool
      ) -> Download

  #### Parameters

  `config` | Player configuration.
  `headers` | List of request headers.
  `allowCellularAccess` |

- `prepareDownload(_:completion:)`

  Prepare a single download metadata and track model. The model contains video qualities, audio tracks, and subtitle tracks and implementations need to select which of these tracks should be downloaded.

  #### Declaration

  Swift

      func prepareDownload(
          _ downloadId: String,
          completion: @escaping (Download?, PRESTOerror?) -> Void
      )

  #### Parameters

  `downloadId` | Download identifier.
  `completion` | Called on completion.

- `startDownload(_:delegate:)`

  Starts a given download.

  #### Declaration

  Swift

      func startDownload(
          _ downloadId: String,
          delegate: DownloadDelegate?
      ) -> PRESTOerror?

  #### Parameters

  `downloadId` | Download identifier.
  `delegate` | Download delegate.

  #### Return Value

  The error that can occur when pausing the download of the given `downloadId`.

- `pauseDownload(_:)`

  Pause a download.

  #### Declaration

  Swift

      func pauseDownload(
          _ downloadId: String
      ) -> PRESTOerror?

  #### Parameters

  `downloadId` | Download identifier.

  #### Return Value

  The error that can occur when pausing the download of the given `downloadId`.

- `resumeDownload(_:)`

  Resume a download.

  #### Declaration

  Swift

      func resumeDownload(
          _ downloadId: String
      ) -> PRESTOerror?

  #### Parameters

  `downloadId` | Download identifier.

  #### Return Value

  The error that can occur when resuming the download of the given `downloadId`.

- `cancelDownload(_:)`

  Stops the download progress but keep the content and the reference in the history.

  #### Declaration

  Swift

      func cancelDownload(
          _ downloadId: String
      ) -> PRESTOerror?

  #### Parameters

  `id` | Download identifier.

  #### Return Value

  The error that can occur when cancelling the download of the given `downloadId`.

- `removeDownload(_:)`

  Cancel the download and remove any content and reference from the history.

  #### Declaration

  Swift

      func removeDownload(
          _ downloadId: String
      ) -> PRESTOerror?

  #### Parameters

  `id` | Download identifier.

  #### Return Value

  The error that can occur when removing downloaded content for the given `downloadId`.

- `getDownloads()`

  Get list of ongoing and completed downloads.

  #### Declaration

  Swift

      func getDownloads() -> [Download]

  #### Return Value

  list of downloads