DynamoDB: Get By ID (Guide w/ Code Examples)

Provided by Rafal Wilinski
Last updated: October 23rd, 2026
Use GetCommand with the full primary key to read one item. The document client returns native JavaScript values; Item is undefined when no matching item exists.
Install @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb, use an ES module on a supported Node.js runtime, and configure an AWS Region and credentials. The examples use an existing Orders table with String keys pk and sk unless an index or timestamp key is described.
import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; import { DynamoDBDocumentClient, GetCommand } from "@aws-sdk/lib-dynamodb"; const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({})); const { Item } = await ddb.send(new GetCommand({ TableName: "Orders", Key: { pk: "CUSTOMER#123", sk: "ORDER#001" }, ConsistentRead: true, })); console.log(Item ?? "Item not found");
A TypeScript type assertion does not validate data from DynamoDB at runtime. Validate the returned object before treating it as your domain model.
Reference: AWS GetItem API. For related access patterns, see DynamoDB query examples. For multiple known keys, see the JavaScript BatchGetCommand example.
Similar Code Examples
- DynamoDB: Delete Table
- DynamoDB Get in Typescript
- DynamoDB: Query Items
- DynamoDB: Get Random Item
- DynamoDB: Get All Items
- DynamoDB: GetItem
- DynamoDB: Get Last Inserted Item
- DynamoDB: BatchGetItem
- DynamoDB: Get Multiple Items
- DynamoDB: Attribute Not Null
- DynamoDB: Query Global Secondary Index in Nodejs
- DynamoDB: Create if Not Exists
- DynamoDB: Query Greater Than
- DynamoDB: Delete All Items With Partition Key
- DynamoDB: Query JSON
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
DynamoDB Tools
- SSH GUI Client
- Chat With Cloud
- MongoDB GUI Client
- AWS Cost Monitoring
- DynamoDB Query Builder
- DynamoDB Code Examples
- DynamoDB Node.js Queries
- DynamoDB JSON Converter
- DynamoDB UUID Generator
- DynamoDB Local Admin GUI
- DynamoDB Pricing Calculator
- DynamoDB Single-Table Design
- Best DynamoDB GUI Clients
- Dynobase vs DynoTable