Support / Knowledge Base / HOW TO: Paginate a Data Stream to receive more than 1000 Data Points

HOW TO: Paginate a Data Stream to receive more than 1000 Data Points

Introduction

The Device Cloud has proven to be a very useful tool for those who learn to use it to their advantage.  This article will cover the subject of Data Streams, and how to receive more than 1000 Data Points of Data Stream information using the Device Cloud Web Services API.

Problem:

When a Web Services request to read a Data Stream is sent to Device Cloud, the maximum number of Data Points which can be received in one response is 1000.   Many Data Streams being pushed up to Device Cloud today consist of more than 1000 Data Points however.  In today's busy Internet of Things, Smart Energy and Sensor Networking devices by the thousands are reporting new data every moment.

Solution:

The maximum number of Data Points returned per Data Stream call is 1000. However, you can get the next 1000 Data Points in the stream by utilizing <pageCursor>:
 
First call:
 
/ws/DataPoint/dia/channel/00000000-00000000-012345FF-FFABCDEF/sensor0/temperature
 
Returns this:
 
<result>
   <resultSize>1000</resultSize>
   <requestedSize>1000</requestedSize>
   <pageCursor>62f54937-8c67-11e2-8d08-4040e60fa8d8</pageCursor>
   <requestedStartTime>-1</requestedStartTime>
   <requestedEndTime>-1</requestedEndTime>
   <DataPoint>
 
The second call to get the next 1000 Data Points would be:
 
/ws/DataPoint/dia/channel/00000000-00000000-012345FF-FFABCDEF/sensor0/temperature?pageCursor=62f54937-8c67-11e2-8d08-4040e60fa8d8
 
You could then get a third thousand (if additional Data Points exist) by replacing the page cursor with the one returned in the second call, and so on.

Further Reading:
Device Cloud Programming Guide - See the Data Streams chapter
Last updated: Aug 08, 2017

Recently Viewed Articles

No recently viewed articles
Contact a Digi expert and get started today! Contact Us