New API Documentation - Developer Preview Available
We are excited to announce the developer preview of our new API documentation for AWS SDK for JavaScript v3. Please follow instructions on the landing page to leave us your feedback.
The GetItem operation returns a set of attributes for the item with the
given primary key. If there is no matching item, GetItem does not return
any data and there will be no Item element in the response.
GetItem provides an eventually consistent read by default. If your
application requires a strongly consistent read, set ConsistentRead to
true. Although a strongly consistent read might take more time than an
eventually consistent read, it always returns the last updated value.
Example
Use a bare-bones client and the command you need to make an API call.
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.
Base exception class for all service exceptions from DynamoDB service.
Example
To read an item from a table
// This example retrieves an item from the Music table. The table has a partition key and a sort key (Artist and SongTitle), so you must specify both of these attributes. constinput = { "Key": { "Artist": { "S":"Acme Band" }, "SongTitle": { "S":"Happy Day" } }, "TableName":"Music" }; constcommand = newGetItemCommand(input); constresponse = awaitclient.send(command); /* response == { "Item": { "AlbumTitle": { "S": "Songs About Life" }, "Artist": { "S": "Acme Band" }, "SongTitle": { "S": "Happy Day" } } } */ // example id: to-read-an-item-from-a-table-1475884258350
The
GetItem
operation returns a set of attributes for the item with the given primary key. If there is no matching item,GetItem
does not return any data and there will be noItem
element in the response.GetItem
provides an eventually consistent read by default. If your application requires a strongly consistent read, setConsistentRead
totrue
. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value.Example
Use a bare-bones client and the command you need to make an API call.
Param
GetItemCommandInput
Returns
GetItemCommandOutput
See
input
shape.response
shape.config
shape.Throws
InternalServerError (server fault)
An error occurred on the server side.
Throws
InvalidEndpointException (client fault)
Throws
ProvisionedThroughputExceededException (client fault)
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.
Throws
RequestLimitExceeded (client fault)
Throughput exceeds the current throughput quota for your account. Please contact Amazon Web Services Support to request a quota increase.
Throws
ResourceNotFoundException (client fault)
The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be
ACTIVE
.Throws
DynamoDBServiceException
Base exception class for all service exceptions from DynamoDB service.
Example
To read an item from a table