dynobase-icon
Dynobase

DynamoDB: Get Multiple Items (Guide w/ Code Examples)

Rafal Wilinski

Provided by Rafal Wilinski

Last updated: October 23rd, 2026

Use BatchGetCommand with known full primary keys. Results can be unordered or partial; the loop below retries only unprocessed keys with a bounded backoff.

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, BatchGetCommand } from "@aws-sdk/lib-dynamodb"; const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({})); let pending = { Orders: { Keys: [ { pk: "CUSTOMER#123", sk: "ORDER#001" }, { pk: "CUSTOMER#456", sk: "ORDER#002" }, ] }, }; for (let attempt = 0; Object.keys(pending).length > 0; attempt++) { if (attempt === 8) throw new Error("Batch read incomplete: persist pending keys for retry"); if (attempt > 0) await new Promise(resolve => setTimeout(resolve, Math.random() * Math.min(5000, 100 * 2 ** attempt))); const result = await ddb.send(new BatchGetCommand({ RequestItems: pending })); for (const item of result.Responses?.Orders ?? []) console.log(item); pending = result.UnprocessedKeys ?? {}; }

Deduplicate keys and split requests at 100 keys. Missing items are omitted. If retries are exhausted, retain pending keys in your application and surface the partial failure.

Reference: AWS BatchGetItem API. For related access patterns, see DynamoDB query examples.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.