Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Data Streams
  • Access management
  • Pricing policy
    • Overview
    • All methods
      • CreateStream
      • DecreaseStreamRetentionPeriod
      • DeleteStream
      • DescribeStream
      • IncreaseStreamRetentionPeriod
      • GetRecords
      • GetShardIterator
      • ListStreams
      • PutRecord
      • PutRecords
      • UpdateShardCount
    • Common errors
    • Examples
  • FAQ

In this article:

  • Request
  • Request parameters
  • Response
  • Response parameters
  • Errors
  1. Amazon Kinesis Data Streams compatible HTTP API
  2. Methods
  3. GetShardIterator

GetShardIterator

Written by
Yandex Cloud
Updated at February 10, 2023
  • Request
    • Request parameters
  • Response
    • Response parameters
  • Errors

Returns an iterator of a stream shard.

The iterator's lifetime expires 5 minutes after it is received.

The iterator sets the position in the shard to start reading the sequence of messages from using the GetRecords method. The position is set using the sequence number of the message in the shard.

The request must specify the type of iterator.

For example, to get an iterator to read a sequence starting from a message with a certain sequence number, specify the AT_SEQUENCE_NUMBER iterator type and the message number in the StartingSequenceNumber parameter. The AFTER_SEQUENCE_NUMBER iterator type returns a value for reading the sequence starting from the message following the one specified in the StartingSequenceNumber parameter. The sequence numbers used are those returned when calling the PutRecord, PutRecords, GetRecords, and DescribeStream methods.

To get an iterator for reading a sequence starting at a certain point in time, specify the AT_TIMESTAMP iterator type and the time in the Timestamp parameter.

The TRIM_HORIZON iterator type allows reading a sequence starting from the oldest record and the LATEST type from the most recent record in the shard.

When reading stream messages in a loop with GetRecords, use GetShardIterator to get the shard iterator to be used in the first GetRecords request. For subsequent reads, you can use the NextShardIterator value returned by GetRecords.

If you call the GetShardIterator method too often, a ProvisionedThroughputExceededException may be thrown.

If a shard no longer exists (for example, as a result of updating the number of shards), the method returns an iterator for the last message in the shard.

There is a limit of five transactions per second per open shard when using GetShardIterator.

RequestRequest

The request contains data in JSON format.

{
  "ShardId": "string",
  "ShardIteratorType": "string",
  "StartingSequenceNumber": "string",
  "StreamName": "string",
  "Timestamp": number
}

Request parametersRequest parameters

Parameter Description
ShardId The ID of the shard that the iterator is requested for.

Type: String.
Size: 1-128 characters.
Possible values: [a-zA-Z0-9_.-]+.
Required: Yes.
ShardIteratorType The type of shard iterator.

Type: ShardIteratorType.
Possible values:
  • AT_SEQUENCE_NUMBER: Indicates the message with the number specified in StartingSequenceNumber.
  • AFTER_SEQUENCE_NUMBER: Indicates the message following the one specified in StartingSequenceNumber.
  • AT_TIMESTAMP: Indicates the message that the time is set for.
  • TRIM_HORIZON: Indicates the oldest message in the shard.
  • LATEST: Indicates the most recent message in the shard.
Required: Yes.
StartingSequenceNumber The sequence number of a message.
Used with the AT_SEQUENCE_NUMBER or AFTER_SEQUENCE_NUMBER iterator type.

Type: String.
Size: 1-256 characters.
Required: No.
StreamName The name of a stream.

Type: String.
Size: 1-128 characters.
Possible values: Lowercase Latin letters, numbers, and hyphens (the first character must be a letter and the last character can't be a hyphen).
Required: No.
Timestamp The timestamp of writing the message to start sequential reads from.
Used with the AT_TIMESTAMP iterator type.

Type: Integer.

ResponseResponse

If successful, HTTP code 200 and data in JSON format are returned.

{
  "Iterator": "string"
}

Response parametersResponse parameters

Parameter Description
Iterator The position in a shard to start sequential message reads from. The iterator value is defined by the message sequence number in a shard.

Type: String
Size: 1-512 characters.
Required: Yes

ErrorsErrors

Parameter Description HTTP code
InvalidArgumentException The argument is invalid. For more information, see the error message. 400
ProvisionedThroughputExceededException Insufficient throughput to execute the request. 400
ResourceNotFoundException The requested resource was not found. 400

Errors that are common to all methods may occur.

Was the article helpful?

Previous
GetRecords
Next
ListStreams
© 2025 Direct Cursus Technology L.L.C.