- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
TransactGetItemsCommand
TransactGetItems
is a synchronous operation that atomically retrieves multiple items from one or more tables (but not from indexes) in a single account and Region. A TransactGetItems
call can contain up to 100 TransactGetItem
objects, each of which contains a Get
structure that specifies an item to retrieve from a table in the account and Region. A call to TransactGetItems
cannot retrieve items from tables in more than one Amazon Web Services account or Region. The aggregate size of the items in the transaction cannot exceed 4 MB.
DynamoDB rejects the entire TransactGetItems
request if any of the following is true:
-
A conflicting operation is in the process of updating an item to be read.
-
There is insufficient provisioned capacity for the transaction to be completed.
-
There is a user error, such as an invalid data format.
-
The aggregate size of the items in the transaction exceeded 4 MB.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { DynamoDBClient, TransactGetItemsCommand } from "@aws-sdk/client-dynamodb"; // ES Modules import
// const { DynamoDBClient, TransactGetItemsCommand } = require("@aws-sdk/client-dynamodb"); // CommonJS import
const client = new DynamoDBClient(config);
const input = { // TransactGetItemsInput
TransactItems: [ // TransactGetItemList // required
{ // TransactGetItem
Get: { // Get
Key: { // Key // required
"<keys>": { // AttributeValue Union: only one key present
S: "STRING_VALUE",
N: "STRING_VALUE",
B: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
SS: [ // StringSetAttributeValue
"STRING_VALUE",
],
NS: [ // NumberSetAttributeValue
"STRING_VALUE",
],
BS: [ // BinarySetAttributeValue
new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
],
M: { // MapAttributeValue
"<keys>": {// Union: only one key present
S: "STRING_VALUE",
N: "STRING_VALUE",
B: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
SS: [
"STRING_VALUE",
],
NS: [
"STRING_VALUE",
],
BS: [
new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
],
M: {
"<keys>": "<AttributeValue>",
},
L: [ // ListAttributeValue
"<AttributeValue>",
],
NULL: true || false,
BOOL: true || false,
},
},
L: [
"<AttributeValue>",
],
NULL: true || false,
BOOL: true || false,
},
},
TableName: "STRING_VALUE", // required
ProjectionExpression: "STRING_VALUE",
ExpressionAttributeNames: { // ExpressionAttributeNameMap
"<keys>": "STRING_VALUE",
},
},
},
],
ReturnConsumedCapacity: "INDEXES" || "TOTAL" || "NONE",
};
const command = new TransactGetItemsCommand(input);
const response = await client.send(command);
// { // TransactGetItemsOutput
// ConsumedCapacity: [ // ConsumedCapacityMultiple
// { // ConsumedCapacity
// TableName: "STRING_VALUE",
// CapacityUnits: Number("double"),
// ReadCapacityUnits: Number("double"),
// WriteCapacityUnits: Number("double"),
// Table: { // Capacity
// ReadCapacityUnits: Number("double"),
// WriteCapacityUnits: Number("double"),
// CapacityUnits: Number("double"),
// },
// LocalSecondaryIndexes: { // SecondaryIndexesCapacityMap
// "<keys>": {
// ReadCapacityUnits: Number("double"),
// WriteCapacityUnits: Number("double"),
// CapacityUnits: Number("double"),
// },
// },
// GlobalSecondaryIndexes: {
// "<keys>": {
// ReadCapacityUnits: Number("double"),
// WriteCapacityUnits: Number("double"),
// CapacityUnits: Number("double"),
// },
// },
// },
// ],
// Responses: [ // ItemResponseList
// { // ItemResponse
// Item: { // AttributeMap
// "<keys>": { // AttributeValue Union: only one key present
// S: "STRING_VALUE",
// N: "STRING_VALUE",
// B: new Uint8Array(),
// SS: [ // StringSetAttributeValue
// "STRING_VALUE",
// ],
// NS: [ // NumberSetAttributeValue
// "STRING_VALUE",
// ],
// BS: [ // BinarySetAttributeValue
// new Uint8Array(),
// ],
// M: { // MapAttributeValue
// "<keys>": {// Union: only one key present
// S: "STRING_VALUE",
// N: "STRING_VALUE",
// B: new Uint8Array(),
// SS: [
// "STRING_VALUE",
// ],
// NS: [
// "STRING_VALUE",
// ],
// BS: [
// new Uint8Array(),
// ],
// M: {
// "<keys>": "<AttributeValue>",
// },
// L: [ // ListAttributeValue
// "<AttributeValue>",
// ],
// NULL: true || false,
// BOOL: true || false,
// },
// },
// L: [
// "<AttributeValue>",
// ],
// NULL: true || false,
// BOOL: true || false,
// },
// },
// },
// ],
// };
TransactGetItemsCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
TransactItems Required | TransactGetItem[] | undefined | An ordered array of up to 100 |
ReturnConsumedCapacity | ReturnConsumedCapacity | undefined | A value of |
TransactGetItemsCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
ConsumedCapacity | ConsumedCapacity[] | undefined | If the ReturnConsumedCapacity value was |
Responses | ItemResponse[] | undefined | An ordered array of up to 100 If a requested item could not be retrieved, the corresponding |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
InternalServerError | server | An error occurred on the server side. |
InvalidEndpointException | client | |
ProvisionedThroughputExceededException | client | Your request rate is too high. The Amazon Web Services SDKs for DynamoDB automatically retry requests that receive this exception. Your request is eventually successful, unless your retry queue is too large to finish. Reduce the frequency of requests and use exponential backoff. For more information, go to Error Retries and Exponential Backoff in the Amazon DynamoDB Developer Guide. |
RequestLimitExceeded | client | Throughput exceeds the current throughput quota for your account. Please contact Amazon Web ServicesSupport to request a quota increase. |
ResourceNotFoundException | client | The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be |
TransactionCanceledException | client | The entire transaction request was canceled. DynamoDB cancels a
DynamoDB cancels a
If using Java, DynamoDB lists the cancellation reasons on the Cancellation reason codes and possible error messages:
|
DynamoDBServiceException | Base exception class for all service exceptions from DynamoDB service. |