![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@aws-sdk/client-dynamodb-streams
Advanced tools
AWS SDK for JavaScript Dynamodb Streams Client for Node.js, Browser and React Native
@aws-sdk/client-dynamodb-streams is a part of the AWS SDK for JavaScript, which allows you to interact with Amazon DynamoDB Streams. DynamoDB Streams capture a time-ordered sequence of item-level modifications in a DynamoDB table and store this information for up to 24 hours. This package enables you to work with these streams, allowing you to capture and process changes to your DynamoDB tables.
List Streams
This feature allows you to list all the streams associated with a DynamoDB table. The code sample demonstrates how to create a DynamoDBStreamsClient, create a ListStreamsCommand, and send the command to list the streams.
{"language":"javascript","content":"const { DynamoDBStreamsClient, ListStreamsCommand } = require('@aws-sdk/client-dynamodb-streams');\n\nconst client = new DynamoDBStreamsClient({ region: 'us-west-2' });\n\nconst listStreams = async () => {\n const command = new ListStreamsCommand({ TableName: 'YourTableName' });\n const response = await client.send(command);\n console.log(response.Streams);\n};\n\nlistStreams();"}
Describe Stream
This feature allows you to describe a specific stream. The code sample demonstrates how to create a DescribeStreamCommand with a given StreamArn and send the command to get the stream description.
{"language":"javascript","content":"const { DynamoDBStreamsClient, DescribeStreamCommand } = require('@aws-sdk/client-dynamodb-streams');\n\nconst client = new DynamoDBStreamsClient({ region: 'us-west-2' });\n\nconst describeStream = async (streamArn) => {\n const command = new DescribeStreamCommand({ StreamArn: streamArn });\n const response = await client.send(command);\n console.log(response.StreamDescription);\n};\n\ndescribeStream('your-stream-arn');"}
Get Shard Iterator
This feature allows you to get a shard iterator, which is used to read stream records from a shard. The code sample demonstrates how to create a GetShardIteratorCommand with the necessary parameters and send the command to get the shard iterator.
{"language":"javascript","content":"const { DynamoDBStreamsClient, GetShardIteratorCommand } = require('@aws-sdk/client-dynamodb-streams');\n\nconst client = new DynamoDBStreamsClient({ region: 'us-west-2' });\n\nconst getShardIterator = async (streamArn, shardId) => {\n const command = new GetShardIteratorCommand({\n StreamArn: streamArn,\n ShardId: shardId,\n ShardIteratorType: 'TRIM_HORIZON'\n });\n const response = await client.send(command);\n console.log(response.ShardIterator);\n};\n\ngetShardIterator('your-stream-arn', 'your-shard-id');"}
Get Records
This feature allows you to get records from a shard using a shard iterator. The code sample demonstrates how to create a GetRecordsCommand with a given ShardIterator and send the command to retrieve the records.
{"language":"javascript","content":"const { DynamoDBStreamsClient, GetRecordsCommand } = require('@aws-sdk/client-dynamodb-streams');\n\nconst client = new DynamoDBStreamsClient({ region: 'us-west-2' });\n\nconst getRecords = async (shardIterator) => {\n const command = new GetRecordsCommand({ ShardIterator: shardIterator });\n const response = await client.send(command);\n console.log(response.Records);\n};\n\ngetRecords('your-shard-iterator');"}
The 'kinesis' package allows you to interact with Amazon Kinesis Streams, which is similar to DynamoDB Streams but designed for real-time processing of streaming data at scale. While DynamoDB Streams is specific to DynamoDB table changes, Kinesis Streams can handle a broader range of streaming data use cases.
The 'aws-sdk' package is the older version of the AWS SDK for JavaScript, which includes support for DynamoDB Streams among many other AWS services. The newer modular packages like '@aws-sdk/client-dynamodb-streams' offer more fine-grained control and smaller bundle sizes.
AWS SDK for JavaScript DynamoDBStreams Client for Node.js, Browser and React Native.
Amazon DynamoDB
Amazon DynamoDB Streams provides API actions for accessing streams and processing stream records. To learn more about application development with Streams, see Capturing Table Activity with DynamoDB Streams in the Amazon DynamoDB Developer Guide.
To install the this package, simply type add or install @aws-sdk/client-dynamodb-streams using your favorite package manager:
npm install @aws-sdk/client-dynamodb-streams
yarn add @aws-sdk/client-dynamodb-streams
pnpm add @aws-sdk/client-dynamodb-streams
The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the DynamoDBStreamsClient
and
the commands you need, for example ListStreamsCommand
:
// ES5 example
const { DynamoDBStreamsClient, ListStreamsCommand } = require("@aws-sdk/client-dynamodb-streams");
// ES6+ example
import { DynamoDBStreamsClient, ListStreamsCommand } from "@aws-sdk/client-dynamodb-streams";
To send a request, you:
send
operation on client with command object as input.destroy()
to close open connections.// a client can be shared by different commands.
const client = new DynamoDBStreamsClient({ region: "REGION" });
const params = {
/** input parameters */
};
const command = new ListStreamsCommand(params);
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.
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.
});
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.
});
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-dynamodb-streams";
const client = new AWS.DynamoDBStreams({ 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.
});
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;
* }
*/
}
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.
aws-sdk-js
on AWS Developer Blog.aws-sdk-js
.To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-dynamodb-streams
package is updated.
To contribute to client you can check our generate clients scripts.
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.
3.679.0 (2024-10-24)
FAQs
AWS SDK for JavaScript Dynamodb Streams Client for Node.js, Browser and React Native
The npm package @aws-sdk/client-dynamodb-streams receives a total of 73,976 weekly downloads. As such, @aws-sdk/client-dynamodb-streams popularity was classified as popular.
We found that @aws-sdk/client-dynamodb-streams demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.