[Yandex Cloud documentation](../../../index.md) > [Yandex Data Streams](../../index.md) > [Step-by-step guides](../index.md) > Working with the AWS CLI > Reading data from a stream

# Reading data from a stream in the AWS CLI

{% list tabs group=instructions %}

- CLI {#cli}

  To get data from a [stream's](../../concepts/glossary.md#stream-concepts) _first_ shard, run this command:

  ```bash
  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:

  ```bash
  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:
  ```json
  {
    "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:

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

{% endlist %}