Back to Aws Sdk Js V3

@aws-sdk/client-ivs

clients/client-ivs/README.md

3.1043.029.1 KB
Original Source
<!-- generated file, do not edit directly -->

@aws-sdk/client-ivs

Description

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

<p> <b>Introduction</b> </p> <p>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.</p> <p>The API is an Amazon Web Services regional service. For a list of supported regions and Amazon IVS HTTPS service endpoints, see the <a href="https://docs.aws.amazon.com/general/latest/gr/ivs.html">Amazon IVS page</a> in the <i>Amazon Web Services General Reference</i>.</p> <p> <i> <b>All API request parameters and URLs are case sensitive. </b> </i> </p> <p>For a summary of notable documentation changes in each release, see <a href="https://docs.aws.amazon.com/ivs/latest/userguide/doc-history.html"> Document History</a>.</p> <p> <b>Allowed Header Values</b> </p> <ul> <li> <p> <code> <b>Accept:</b> </code> application/json</p> </li> <li> <p> <code> <b>Accept-Encoding:</b> </code> gzip, deflate</p> </li> <li> <p> <code> <b>Content-Type:</b> </code>application/json</p> </li> </ul> <p> <b>Key Concepts</b> </p> <ul> <li> <p> <b>Channel</b> — 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.</p> </li> <li> <p> <b>Stream key</b> — An identifier assigned by Amazon IVS when you create a channel, which is then used to authorize streaming. <i> <b>Treat the stream key like a secret, since it allows anyone to stream to the channel.</b> </i> </p> </li> <li> <p> <b>Playback key pair</b> — 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.</p> </li> <li> <p> <b>Recording configuration</b> — Stores configuration related to recording a live stream and where to store the recorded content. Multiple channels can reference the same recording configuration.</p> </li> <li> <p> <b>Playback restriction policy</b> — Restricts playback by countries and/or origin sites.</p> </li> </ul> <p>For more information about your IVS live stream, also see <a href="https://docs.aws.amazon.com/ivs/latest/LowLatencyUserGuide/getting-started.html">Getting Started with IVS Low-Latency Streaming</a>.</p> <p> <b>Tagging</b> </p> <p>A <i>tag</i> is a metadata label that you assign to an Amazon Web Services resource. A tag comprises a <i>key</i> and a <i>value</i>, both set by you. For example, you might set a tag as <code>topic:nature</code> to label a particular video category. See <a href="https://docs.aws.amazon.com/tag-editor/latest/userguide/best-practices-and-strats.html">Best practices and strategies</a> in <i>Tagging Amazon Web Services Resources and Tag Editor</i> for details, including restrictions that apply to tags and "Tag naming limits and requirements"; Amazon IVS has no service-specific constraints beyond what is documented there.</p> <p>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 <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html"> Access Tags</a>). </p> <p>The Amazon IVS API has these tag-related operations: <a>TagResource</a>, <a>UntagResource</a>, and <a>ListTagsForResource</a>. The following resources support tagging: Channels, Stream Keys, Playback Key Pairs, and Recording Configurations.</p> <p>At most 50 tags can be applied to a resource. </p> <p> <b>Authentication versus Authorization</b> </p> <p>Note the differences between these concepts:</p> <ul> <li> <p> <i>Authentication</i> is about verifying identity. You need to be authenticated to sign Amazon IVS API requests.</p> </li> <li> <p> <i>Authorization</i> is about granting permissions. Your IAM roles need to have permissions for Amazon IVS API requests. In addition, authorization is needed to view <a href="https://docs.aws.amazon.com/ivs/latest/userguide/private-channels.html">Amazon IVS private channels</a>. (Private channels are channels that are enabled for "playback authorization.")</p> </li> </ul> <p> <b>Authentication</b> </p> <p>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.</p> <p>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 <code>ivs:PutMetadata</code> permission.</p> <p>For more information:</p> <ul> <li> <p>Authentication and generating signatures — See <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html">Authenticating Requests (Amazon Web Services Signature Version 4)</a> in the <i>Amazon Web Services General Reference</i>.</p> </li> <li> <p>Managing Amazon IVS permissions — See <a href="https://docs.aws.amazon.com/ivs/latest/userguide/security-iam.html">Identity and Access Management</a> on the Security page of the <i>Amazon IVS User Guide</i>.</p> </li> </ul> <p> <b>Amazon Resource Names (ARNs)</b> </p> <p>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 <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Names</a> in the <i>AWS General Reference</i>.</p>

Installing

To install this package, use the CLI of 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:

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

Usage

To send a request:

  • Instantiate a client with configuration (e.g. credentials, region).
  • Instantiate a command with input parameters.
  • Call the send operation on the client, providing the command object as input.
js
const client = new IvsClient({ region: "REGION" });

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

Async/await

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

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

Promises

You can also use Promise chaining.

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

Aggregated client

The aggregated client class is exported from the same package, but without the "Client" suffix.

Ivs extends IvsClient and additionally supports all operations, waiters, and paginators as methods. This style may be familiar to you from the AWS SDK for JavaScript v2.

If you are bundling the AWS SDK, we recommend using only the bare-bones client (IvsClient). More details are in the blog post on modular packages in AWS SDK for JavaScript.

ts
import { Ivs } from "@aws-sdk/client-ivs";

const client = new 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 (not recommended).
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).

js
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;
   * }
   */
}

See also docs/ERROR_HANDLING.

Getting Help

Please use these community resources for getting help. We use 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)

<details> <summary> BatchGetChannel </summary>

Command API Reference / Input / Output

</details> <details> <summary> BatchGetStreamKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> BatchStartViewerSessionRevocation </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateAdConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateChannel </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreatePlaybackRestrictionPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateRecordingConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateStreamKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteAdConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteChannel </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeletePlaybackKeyPair </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeletePlaybackRestrictionPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteRecordingConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteStreamKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetAdConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetChannel </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetPlaybackKeyPair </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetPlaybackRestrictionPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetRecordingConfiguration </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetStream </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetStreamKey </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetStreamSession </summary>

Command API Reference / Input / Output

</details> <details> <summary> ImportPlaybackKeyPair </summary>

Command API Reference / Input / Output

</details> <details> <summary> InsertAdBreak </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAdConfigurations </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListChannels </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListPlaybackKeyPairs </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListPlaybackRestrictionPolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListRecordingConfigurations </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListStreamKeys </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListStreams </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListStreamSessions </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListTagsForResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> PutMetadata </summary>

Command API Reference / Input / Output

</details> <details> <summary> StartViewerSessionRevocation </summary>

Command API Reference / Input / Output

</details> <details> <summary> StopStream </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateChannel </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdatePlaybackRestrictionPolicy </summary>

Command API Reference / Input / Output

</details>