Downloading Streaming Data

Downloading Stream Data in JSON Format

Initialize a DIS SDK client instance as instructed in Initializing a DIS SDK Client Instance.

The getRecords_sample.py file provides a code sample. Configure the following parameters in this file:

1
2
3
streamname=" "   #Name of the stream.
startSeq=' 0' #Sequence number.
partitionId="shardId-0000000000"   

Run getCursor_test to change the value of cursorType to AT_SEQUENCE_NUMBER.

After configuring the parameters, run the getRecords_sample.py file to call getRecords_test. The following is an example response:

1
2
200
{"records": [{"sequence_number": "21", "data": "abcdefd"}],"next_partition_cursor":   "eyJpdGVyR2VuVGltZSI6MTQ5MDk1MDE1Nzc0NywiU3RyZWFtTmFtZSI6IjY2MCIsIlNoYXJkSWQiOiIwIiwiU2hhcmRJdGVyYXRvclR5cGUiOiJBVF9TRVFVRU5DRV9OVU1CRVIiLCJTdGFydGluZ1NlcXVlbmNlTnVtYmVyIjoiMjIiLCJUaW1lU3RhbXAiOjB9"}

Downloading Streaming Data in Protobuf Format

Initialize a DIS SDK client instance as instructed in Initializing a DIS SDK Client Instance.

The protobuf_getrecords_sample.py file provides a code sample.

Run the protoc --version command to check whether the environment variables are set successfully. If not, install Protobuf.

Configure the following parameters in this file:

1
2
3
streamname=" "   #Name of the stream.
startSeq=' 0'  #Sequence number.
partitionId="shardId-0000000000"   

Run getCursor_test to change the value of cursorType to AT_SEQUENCE_NUMBER.

The test_0 method is used to obtain a cursor and the test method is used to download data. Compared to test_0, test has the bodySerializeType="protobuf" parameter, which is not provided in test_0.

After configuring the parameters, run the protobuf_getrecords_sample.py file to call getRecords_test. The following is an example response:

1
2
200
{"records": [{"sequence_number": "21", "data": "abcdefd"}],"next_partition_cursor":   "eyJpdGVyR2VuVGltZSI6MTQ5MDk1MDE1Nzc0NywiU3RyZWFtTmFtZSI6IjY2MCIsIlNoYXJkSWQiOiIwIiwiU2hhcmRJdGVyYXRvclR5cGUiOiJBVF9TRVFVRU5DRV9OVU1CRVIiLCJTdGFydGluZ1NlcXVlbmNlTnVtYmVyIjoiMjIiLCJUaW1lU3RhbXAiOjB9"}