Options
All
  • Public
  • Public/Protected
  • All
Menu

Simplified client to the Livepeer API, exposing only the VOD endpoints.

remarks

This class can be used directly to make requests to the VOD API of Livepeer. In the most common case you should be using the {@link VideoNft} class instead for higher level utilities for uploading, processing and minting video files.

Hierarchy

  • VodApi

Index

Constructors

Properties

client: AxiosInstance

Methods

  • exportAsset(id: string, params: undefined | { custom: { headers?: {}; method?: string; url: string } } | { ipfs: { nftMetadata?: {}; pinata?: { jwt: string } | { apiKey: string; apiSecret: string } } }): Promise<{ task: Task }>
  • Requests for an asset to be exported from the Livepeer API to any external location, most commonly to IPFS.

    remarks

    Refer to the API reference for more info.

    Parameters

    • id: string

      the ID of the asset to be exported.

    • params: undefined | { custom: { headers?: {}; method?: string; url: string } } | { ipfs: { nftMetadata?: {}; pinata?: { jwt: string } | { apiKey: string; apiSecret: string } } }

      the export task parameters. Set ipfs field to export to IPFS and the optional nftMetadata sub-field to customize the NFT metadata.

    Returns Promise<{ task: Task }>

    the export task object that can be used to track progress and wait for the output (check getTask).

  • getAsset(id: string): Promise<Asset>
  • Gets an asset from the API by ID.

    remarks

    Refer to the API reference for more info.

    Parameters

    • id: string

      the ID of the asset to fetch

    Returns Promise<Asset>

    the asset object as returned by the API.

  • getTask(id: string): Promise<Task>
  • Gets a task from the API by ID.

    remarks

    Refer to the API reference for more info.

    Parameters

    • id: string

      the ID of the task to fetch

    Returns Promise<Task>

    the task object as returned by the API.

  • makeRequest<T>(method: Method, url: string, data?: any): Promise<T>
  • Type parameters

    • T

    Parameters

    • method: Method
    • url: string
    • Optional data: any

    Returns Promise<T>

  • requestUploadUrl(assetName: string): Promise<{ asset: Asset; task: Task; url: string }>
  • This is used to request a direct upload URL for a file to be uploaded to the API.

    remarks

    This API is especially useful if you want to avoid proxying the whole file upload from your end-user. Your backend can just create an upload URL in the Livepeer API and return that URL to the frontend application, and your frontend itself can upload the file contents directly without any proxying.

    remarks

    Refer to the API reference for more info.

    Parameters

    • assetName: string

      the name of the asset that will be created for the file in the API.

    Returns Promise<{ asset: Asset; task: Task; url: string }>

    An object with the url, and created asset and task. The url is the one that should be used to upload the file directly through uploadFile. The asset and task are the ones created for the file, which will get processed as soon as the contents are uploaded to the url. Check getTask to track task progress.

  • Requests for an asset stored in the Livepeer API to be transcoded to a different video profile.

    Parameters

    • assetId: string

      the ID of the input asset to be transcoded.

    • name: string

      the name of the output asset to be created.

    • profile: FfmpegProfile

      descripiton of the desired video profile for the output asset.

    Returns Promise<{ asset: Asset; task: Task }>

    an object with the created asset and task. The task can be used to poll for the transcoding progress (check getTask) and after it is done the finalized asset can be fetched with getAsset.

  • uploadFile(url: string, content: File | ReadableStream, reportProgress?: (progress: number) => void, mimeType?: string): Promise<void>
  • This is used to upload a file to a direct upload URL obtained from the requestUploadUrl method.

    remarks

    This works both from a browser or from node.js. The file content should be a File object when using this from the browser or a ReadableStream when using this from Node.js. To get a stream from a file in node use fs.createReadStream(filename).

    Parameters

    • url: string

      The url returned by requestUploadUrl.

    • content: File | ReadableStream

      The content of the file to upload. A File from the browser or a ReadableStream from node.js.

    • Optional reportProgress: (progress: number) => void

      An optional callback that will be called with the upload progress, useful for giving some UI feedback to users. This is currently only supported from the browser.

        • (progress: number): void
        • Parameters

          • progress: number

          Returns void

    • Optional mimeType: string

      An optional mimeType for the file. Defaults to octet-stream and exact type will be detected automatically later.

    Returns Promise<void>

    A promise that will be completed when the upload is done. Will throw an exception on any error. Refer back to the asset and task objects returned by requestUploadUrl for updates on the file processing.

Generated using TypeDoc