@aws-sdk/client-ivs
TypeScript icon, indicating that this package has built-in type declarations

3.556.0 • Public • Published

@aws-sdk/client-ivs

Description

AWS SDK for JavaScript Ivs Client for Node.js, Browser and React Native.

Introduction

The Amazon Interactive Video Service (IVS) API is REST compatible, using a standard HTTP API and an Amazon Web Services EventBridge event stream for responses. JSON is used for both requests and responses, including errors.

The API is an Amazon Web Services regional service. For a list of supported regions and Amazon IVS HTTPS service endpoints, see the Amazon IVS page in the Amazon Web Services General Reference.

All API request parameters and URLs are case sensitive.

For a summary of notable documentation changes in each release, see Document History.

Allowed Header Values

  • Accept: application/json

  • Accept-Encoding: gzip, deflate

  • Content-Type: application/json

Key Concepts

  • Channel — Stores configuration data related to your live stream. You first create a channel and then use the channel’s stream key to start your live stream.

  • Stream key — An identifier assigned by Amazon IVS when you create a channel, which is then used to authorize streaming. Treat the stream key like a secret, since it allows anyone to stream to the channel.

  • Playback key pair — Video playback may be restricted using playback-authorization tokens, which use public-key encryption. A playback key pair is the public-private pair of keys used to sign and validate the playback-authorization token.

  • Recording configuration — Stores configuration related to recording a live stream and where to store the recorded content. Multiple channels can reference the same recording configuration.

  • Playback restriction policy — Restricts playback by countries and/or origin sites.

For more information about your IVS live stream, also see Getting Started with IVS Low-Latency Streaming.

Tagging

A tag is a metadata label that you assign to an Amazon Web Services resource. A tag comprises a key and a value, both set by you. For example, you might set a tag as topic:nature to label a particular video category. See Tagging Amazon Web Services Resources for more information, including restrictions that apply to tags and "Tag naming limits and requirements"; Amazon IVS has no service-specific constraints beyond what is documented there.

Tags can help you identify and organize your Amazon Web Services resources. For example, you can use the same tag for different resources to indicate that they are related. You can also use tags to manage access (see Access Tags).

The Amazon IVS API has these tag-related endpoints: TagResource, UntagResource, and ListTagsForResource. The following resources support tagging: Channels, Stream Keys, Playback Key Pairs, and Recording Configurations.

At most 50 tags can be applied to a resource.

Authentication versus Authorization

Note the differences between these concepts:

  • Authentication is about verifying identity. You need to be authenticated to sign Amazon IVS API requests.

  • Authorization is about granting permissions. Your IAM roles need to have permissions for Amazon IVS API requests. In addition, authorization is needed to view Amazon IVS private channels. (Private channels are channels that are enabled for "playback authorization.")

Authentication

All Amazon IVS API requests must be authenticated with a signature. The Amazon Web Services Command-Line Interface (CLI) and Amazon IVS Player SDKs take care of signing the underlying API calls for you. However, if your application calls the Amazon IVS API directly, it’s your responsibility to sign the requests.

You generate a signature using valid Amazon Web Services credentials that have permission to perform the requested action. For example, you must sign PutMetadata requests with a signature generated from a user account that has the ivs:PutMetadata permission.

For more information:

Amazon Resource Names (ARNs)

ARNs uniquely identify AWS resources. An ARN is required when you need to specify a resource unambiguously across all of AWS, such as in IAM policies and API calls. For more information, see Amazon Resource Names in the AWS General Reference.

Channel Endpoints

  • CreateChannel — Creates a new channel and an associated stream key to start streaming.

  • GetChannel — Gets the channel configuration for the specified channel ARN.

  • BatchGetChannel — Performs GetChannel on multiple ARNs simultaneously.

  • ListChannels — Gets summary information about all channels in your account, in the Amazon Web Services region where the API request is processed. This list can be filtered to match a specified name or recording-configuration ARN. Filters are mutually exclusive and cannot be used together. If you try to use both filters, you will get an error (409 Conflict Exception).

  • UpdateChannel — Updates a channel's configuration. This does not affect an ongoing stream of this channel. You must stop and restart the stream for the changes to take effect.

  • DeleteChannel — Deletes the specified channel.

Playback Restriction Policy Endpoints

  • CreatePlaybackRestrictionPolicy — Creates a new playback restriction policy, for constraining playback by countries and/or origins.

  • DeletePlaybackRestrictionPolicy — Deletes the specified playback restriction policy

  • GetPlaybackRestrictionPolicy — Gets the specified playback restriction policy.

  • ListPlaybackRestrictionPolicies — Gets summary information about playback restriction policies.

  • UpdatePlaybackRestrictionPolicy — Updates a specified playback restriction policy.

Private Channel Endpoints

For more information, see Setting Up Private Channels in the Amazon IVS User Guide.

  • ImportPlaybackKeyPair — Imports the public portion of a new key pair and returns its arn and fingerprint. The privateKey can then be used to generate viewer authorization tokens, to grant viewers access to private channels (channels enabled for playback authorization).

  • GetPlaybackKeyPair — Gets a specified playback authorization key pair and returns the arn and fingerprint. The privateKey held by the caller can be used to generate viewer authorization tokens, to grant viewers access to private channels.

  • ListPlaybackKeyPairs — Gets summary information about playback key pairs.

  • DeletePlaybackKeyPair — Deletes a specified authorization key pair. This invalidates future viewer tokens generated using the key pair’s privateKey.

  • StartViewerSessionRevocation — Starts the process of revoking the viewer session associated with a specified channel ARN and viewer ID. Optionally, you can provide a version to revoke viewer sessions less than and including that version.

  • BatchStartViewerSessionRevocation — Performs StartViewerSessionRevocation on multiple channel ARN and viewer ID pairs simultaneously.

Recording Configuration Endpoints

  • CreateRecordingConfiguration — Creates a new recording configuration, used to enable recording to Amazon S3.

  • GetRecordingConfiguration — Gets the recording-configuration metadata for the specified ARN.

  • ListRecordingConfigurations — Gets summary information about all recording configurations in your account, in the Amazon Web Services region where the API request is processed.

  • DeleteRecordingConfiguration — Deletes the recording configuration for the specified ARN.

Stream Endpoints

  • GetStream — Gets information about the active (live) stream on a specified channel.

  • GetStreamSession — Gets metadata on a specified stream.

  • ListStreams — Gets summary information about live streams in your account, in the Amazon Web Services region where the API request is processed.

  • ListStreamSessions — Gets a summary of current and previous streams for a specified channel in your account, in the AWS region where the API request is processed.

  • StopStream — Disconnects the incoming RTMPS stream for the specified channel. Can be used in conjunction with DeleteStreamKey to prevent further streaming to a channel.

  • PutMetadata — Inserts metadata into the active stream of the specified channel. At most 5 requests per second per channel are allowed, each with a maximum 1 KB payload. (If 5 TPS is not sufficient for your needs, we recommend batching your data into a single PutMetadata call.) At most 155 requests per second per account are allowed.

Stream Key Endpoints

  • CreateStreamKey — Creates a stream key, used to initiate a stream, for the specified channel ARN.

  • GetStreamKey — Gets stream key information for the specified ARN.

  • BatchGetStreamKey — Performs GetStreamKey on multiple ARNs simultaneously.

  • ListStreamKeys — Gets summary information about stream keys for the specified channel.

  • DeleteStreamKey — Deletes the stream key for the specified ARN, so it can no longer be used to stream.

Amazon Web Services Tags Endpoints

  • TagResource — Adds or updates tags for the Amazon Web Services resource with the specified ARN.

  • UntagResource — Removes tags from the resource with the specified ARN.

  • ListTagsForResource — Gets information about Amazon Web Services tags for the specified ARN.

Installing

To install the this package, simply type add or install @aws-sdk/client-ivs using your favorite package manager:

  • npm install @aws-sdk/client-ivs
  • yarn add @aws-sdk/client-ivs
  • pnpm add @aws-sdk/client-ivs

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the IvsClient and the commands you need, for example ListStreamsCommand:

// ES5 example
const { IvsClient, ListStreamsCommand } = require("@aws-sdk/client-ivs");
// ES6+ example
import { IvsClient, ListStreamsCommand } from "@aws-sdk/client-ivs";

Usage

To send a request, you:

  • Initiate client with configuration (e.g. credentials, region).
  • Initiate command with input parameters.
  • Call send operation on client with command object as input.
  • If you are using a custom http handler, you may call destroy() to close open connections.
// a client can be shared by different commands.
const client = new IvsClient({ region: "REGION" });

const params = {
  /** input parameters */
};
const command = new ListStreamsCommand(params);

Async/await

We recommend using await operator to wait for the promise returned by send operation as follows:

// async/await.
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  // error handling.
} finally {
  // finally.
}

Async-await is clean, concise, intuitive, easy to debug and has better error handling as compared to using Promise chains or callbacks.

Promises

You can also use Promise chaining to execute send operation.

client.send(command).then(
  (data) => {
    // process data.
  },
  (error) => {
    // error handling.
  }
);

Promises can also be called using .catch() and .finally() as follows:

client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });

Callbacks

We do not recommend using callbacks because of callback hell, but they are supported by the send operation.

// callbacks.
client.send(command, (err, data) => {
  // process err and data.
});

v2 compatible style

The client can also send requests using v2 compatible style. However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post on modular packages in AWS SDK for JavaScript

import * as AWS from "@aws-sdk/client-ivs";
const client = new AWS.Ivs({ region: "REGION" });

// async/await.
try {
  const data = await client.listStreams(params);
  // process data.
} catch (error) {
  // error handling.
}

// Promises.
client
  .listStreams(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks.
client.listStreams(params, (err, data) => {
  // process err and data.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  const { requestId, cfId, extendedRequestId } = error.$metadata;
  console.log({ requestId, cfId, extendedRequestId });
  /**
   * The keys within exceptions are also parsed.
   * You can access them by specifying exception names:
   * if (error.name === 'SomeServiceException') {
   *     const value = error.specialKeyInException;
   * }
   */
}

Getting Help

Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-ivs package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

BatchGetChannel

Command API Reference / Input / Output

BatchGetStreamKey

Command API Reference / Input / Output

BatchStartViewerSessionRevocation

Command API Reference / Input / Output

CreateChannel

Command API Reference / Input / Output

CreatePlaybackRestrictionPolicy

Command API Reference / Input / Output

CreateRecordingConfiguration

Command API Reference / Input / Output

CreateStreamKey

Command API Reference / Input / Output

DeleteChannel

Command API Reference / Input / Output

DeletePlaybackKeyPair

Command API Reference / Input / Output

DeletePlaybackRestrictionPolicy

Command API Reference / Input / Output

DeleteRecordingConfiguration

Command API Reference / Input / Output

DeleteStreamKey

Command API Reference / Input / Output

GetChannel

Command API Reference / Input / Output

GetPlaybackKeyPair

Command API Reference / Input / Output

GetPlaybackRestrictionPolicy

Command API Reference / Input / Output

GetRecordingConfiguration

Command API Reference / Input / Output

GetStream

Command API Reference / Input / Output

GetStreamKey

Command API Reference / Input / Output

GetStreamSession

Command API Reference / Input / Output

ImportPlaybackKeyPair

Command API Reference / Input / Output

ListChannels

Command API Reference / Input / Output

ListPlaybackKeyPairs

Command API Reference / Input / Output

ListPlaybackRestrictionPolicies

Command API Reference / Input / Output

ListRecordingConfigurations

Command API Reference / Input / Output

ListStreamKeys

Command API Reference / Input / Output

ListStreams

Command API Reference / Input / Output

ListStreamSessions

Command API Reference / Input / Output

ListTagsForResource

Command API Reference / Input / Output

PutMetadata

Command API Reference / Input / Output

StartViewerSessionRevocation

Command API Reference / Input / Output

StopStream

Command API Reference / Input / Output

TagResource

Command API Reference / Input / Output

UntagResource

Command API Reference / Input / Output

UpdateChannel

Command API Reference / Input / Output

UpdatePlaybackRestrictionPolicy

Command API Reference / Input / Output

Readme

Keywords

none

Package Sidebar

Install

npm i @aws-sdk/client-ivs

Weekly Downloads

100,358

Version

3.556.0

License

Apache-2.0

Unpacked Size

739 kB

Total Files

200

Last publish

Collaborators

  • mattsb42-aws
  • kuhe
  • amzn-oss
  • aws-sdk-bot
  • trivikr-aws