Downloading Data from a DIS Stream
Function
This API is used to download data from a DIS stream.
When downloading data, you need to specify a data cursor. For details about how to obtain a cursor, see Obtaining a Cursor.
Request
- Example request
GET https://{endpoint}/v2/{project_id}/records?app_name=app1&partition-cursor= eyJpdGVyR2VuVGltZSI6MTQ5MDk0ODk5OTM5NywiU3RyZWFtTmFtZSI6IjY2MCIsIlNoYXJkSWQiOiIwIiwiU2hhcmRJdGVyYXRvclR5cGUiOiJBVF9TRVFVRU5DRV9OVU1CRVIiLCJTdGFydGluZ1NlcXVlbmNlTnVtYmVyIjoiMCIsIlRpbWVTdGFtcCI6MH0= - Parameter description
Table 1 Parameter description Parameter
Mandatory
Type
Description
partition-cursor
Yes
String
Cursor of the partition used to specify the position in the partition from which to start reading data records sequentially.
Value: 1 to 512 characters
NOTE:The validity period of a cursor is 5 minutes.
app_name
No
String
Name of the application that submits the checkpoint operation in the consumption stream.
Response
- Example response
{ "records": [ { "partition_key": "0", "sequence_number": "21", "data": "MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTEx", "timestamp": 1527577402541, "timestamp_type": "CreateTime" } ], "next_partition_cursor": "eyJpdGVyR2VuVGltZSI6MTQ5MDk1MDE1Nzc0NywiU3RyZWFtTmFtZSI6IjY2MCIsIlNoYXJkSWQiOiIwIiwiU2hhcmRJdGVyYXRvclR5cGUiOiJBVF9TRVFVRU5DRV9OVU1CRVIiLCJTdGFydGluZ1NlcXVlbmNlTnVtYmVyIjoiMjIiLCJUaW1lU3RhbXAiOjB9", } - Parameter description
Table 2 Response parameter description Parameter
Type
Description
records
List<PullRecord>
Information of data records.
For more information, see Table 3.
next_partition_cursor
String
Next cursor, which specifies the next position in the partition from which to start reading data records sequentially.
NOTE:The validity period of a cursor is 5 minutes.
Table 3 PullRecord parameter description Parameter
Type
Description
data
String
Data pulled from the DIS stream.
partition_key
String
Partition key set when data is being uploaded.
NOTE:If the partition_key parameter is transferred when data is uploaded, this parameter is returned when data is downloaded. If the partition_key parameter is not transferred but the partition_id parameter is transferred when data is uploaded, no partition_key is returned.
sequence_number
String
Sequence number of an individual data record. Each data record has a sequence number that is unique within its partition. The sequence number is assigned by DIS when a data producer calls PutRecords to add data to a DIS stream. Sequence numbers for the same partition key generally increase over time; the longer the time period between write requests (PutRecords requests), the larger the sequence numbers become.
timestamp
Long
Timestamp when the record is written to DIS.
timestamp_type
String
Type of the timestamp.
The value is CreateTime, specifying the creation time.
- The data obtained through this API is the data encoded from the raw data using Base64 encoding.
- If a user downloads data using SDK provided by DIS, the SDK will automatically decode the data using Base64 decoding, and the user will obtain the raw data.
Status Code
- Normal
- Failed
For more information, see Error Codes.
Last Article: Obtaining a Cursor
Next Article: Creating an Application
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.