Yandex Cloud
Documentation
PresentationContact UsTry it for free
© 2026 Direct Cursus Technology L.L.C.
Yandex Data Streams
    • All guides
    • Managing data streams
      • Creating a data stream
      • Getting stream info
      • Sending data to a stream
      • Reading data from a stream
      • Deleting a stream
  • Access management
  • Pricing policy
  • FAQ
  1. Step-by-step guides
  2. Working with the AWS CLI
  3. Reading data from a stream

Reading data from a stream in the AWS CLI

Written by
Yandex Cloud
Updated at July 15, 2025
View in Markdown
CLI

To get data from a stream's first shard, run this command:

SHARD_ITERATOR=$(aws kinesis get-shard-iterator \
  --endpoint <endpoint> \
  --shard-id shard-000001 \
  --shard-iterator-type LATEST \
  --stream-name <stream_ID> \
  --query 'ShardIterator'| tr -d \")
aws kinesis get-records \
  --endpoint <endpoint> \
  --shard-iterator $SHARD_ITERATOR

Where:

  • --endpoint: Specify the https://yds.serverless.yandexcloud.net endpoint to read stream data over the AWS Kinesis Data Streams protocol.

  • --stream-name: Consists of the availability zone, folder ID, Yandex Managed Service for YDB database ID, and stream name.

    For example, your stream ID will appear as /ru-central1/aoeu1kuk2dht********/cc8029jgtuab********/aws_stream if:

    • aws_stream: Stream name.
    • ru-central1: Region.
    • aoeu1kuk2dht********: Folder ID.
    • cc8029jgtuab********: YDB database ID.

Command example:

SHARD_ITERATOR=$(aws kinesis get-shard-iterator \
  --endpoint https://yds.serverless.yandexcloud.net \
  --shard-id shard-000001 \
  --shard-iterator-type LATEST \
  --stream-name /ru-central1/aoeu1kuk2dht********/cc8029jgtuab********/aws_stream
  --query 'ShardIterator'| tr -d \")
aws kinesis get-records \
  --endpoint https://yds.serverless.yandexcloud.net \
  --shard-iterator $SHARD_ITERATOR

Result example:

{
  "Records": [
      {
          "SequenceNumber": "0",
          "Data": "eyJ1c2VyX2lkIjoidXNlcjEiLCJzY29yZSI6MTAwfQ==",
          "PartitionKey": "1"
      },
      {
          "SequenceNumber": "1",
          "Data": "eyJ1c2VyX2lkIjoidXNlcjEiLCJzY29yZSI6MTAwfQ==",
          "PartitionKey": "1"
      },
  ...
}

In the example above, the data output in the Data field are BASE64-encoded. If you decode it, the following string is returned:

  {"user_id":"user1","score":100}

Was the article helpful?

Previous
Sending data to a stream
Next
Deleting a stream
© 2026 Direct Cursus Technology L.L.C.