Replay a Stream

GET /replay

The Replay Stream is intended to be used by customers that want to replay the event stream. For instance, if there were errors processing events from the Stream, a connection to the Replay stream would allow customers to replay and reprocess events. By default, each connection will send all the data for all the users processed over the last 30 days.

Opens a connection and streams data for the customer using Server Sent Events (SSE). This creates a long-lived HTTP connection where a poke event will be sent every 5 seconds. As soon as new content is available, information will be sent in a data event.

A Content-Type response header of text/event-stream will be returned, indicating a long-lived HTTP connection, in which data will be streamed to the client.

❗️

REPLAY LIMITS

  • Replay streams do not offer load balancing, the connection is limited as one stream per client and each client that connects to a replay stream will receive the entire stream.
NameRequired FieldsTypeDescription
dateoptionalstringUsed to change request date. The client will only receive events where the created_at date of the event (also known as the processed time) is on or after the provided date parameter. Must be in YYYY-MM-DD format. Ex: ?date=2017-04-01
Note: If you do provide a date parameter, all 30 days will still be processed and only records on or after the date will be displayed. Therefore you may see a high number of POKE events before you see any data events.
resourcesoptionalstringUsed to limit events to only the specified resource types. The client will only receive events where the resource type matches one of the provided values. Ex: ?resources=summary OR ?resources=summary,measurement
Valid values:
measurement
nutrition
sleep
summary
* workout
event_typesoptionalstringOptional SSE filter that is applied which will only send events if the event type is in the provided list. Ex: ?event_types=data

Valid values:
data
rule

Note: poke events are required and will not be filtered even if added to the list.

Note: Connection events are not available in the replay stream. The user marketplace endpoint can be used to determine the current connection status for a given user.

HTTP Response Status

Response CodeDescription
200 (OK)Indicates the request was received and a result was returned.
400 (Bad Request)Indicates that the request was invalid.

Code Samples

https://streams.v2.validic.com/replay?resources=summary,measurement&token=6f46db36dd6543d2b82d91698fcd0896&date=2017-07-30
https://streams.v2.validic.com/replay?resources=summary,measurement&token=6f46db36dd6543d2b82d91698fcd0896&date=2017-07-30
event:poke 
data:{  
   "ts":"2017-08-04T19:29:18.921Z"
}

event:data 
data:{  
   "category":"daily",
   "checksum":"57e5f8fc1605a695a7070ae6631424fa",
   "created_at":"2017-07-30T00:05:34.965Z",
   "deleted_at":null,
   "end_time":"2017-07-30T03:59:59Z",
   "id":"5de711ed704b3652d66c26132e01bdff",
   "log_id":"2017-07-29",
   "metrics":[  
      {  
         "origin":"device",
         "type":"active_energy_burned",
         "unit":"kcal",
         "value":79.0
      },
      {  
         "origin":"device",
         "type":"basal_energy_burned",
         "unit":"kcal",
         "value":1636.0
      },
      {  
         "origin":"device",
         "type":"distance",
         "unit":"m",
         "value":240.0
      },
      {  
         "origin":"device",
         "type":"elevation",
         "unit":"m",
         "value":3.05
      },
      {  
         "origin":"device",
         "type":"energy_burned",
         "unit":"kcal",
         "value":1702.0
      },
      {  
         "origin":"device",
         "type":"floors_climbed",
         "unit":"count",
         "value":1
      },
      {  
         "origin":"device",
         "type":"steps",
         "unit":"count",
         "value":341
      },
      {  
         "origin":"device",
         "type":"heart_rate_zone_very_low",
         "unit":"s",
         "value":0.0
      },
      {  
         "origin":"device",
         "type":"heart_rate_zone_low",
         "unit":"s",
         "value":0.0
      },
      {  
         "origin":"device",
         "type":"heart_rate_zone_medium",
         "unit":"s",
         "value":0.0
      },
      {  
         "origin":"device",
         "type":"heart_rate_zone_high",
         "unit":"s",
         "value":24240.0
      },
      {  
         "origin":"device",
         "type":"resting_heart_rate",
         "unit":"bpm",
         "value":62
      }
   ],
   "offset_origin":"profile",
   "segments":[  

   ],
   "source":{  
      "type":"fitbit"
   },
   "start_time":"2017-07-29T04:00:00Z",
   "type":"summary",
   "user":{  
      "organization_id":"597752338a5da500014a1f9a",
      "uid":"277040620-sol3",
      "user_id":"5978f4198a5da50001809f82"
   },
   "user_notes":[  

   ],
   "utc_offset":-14400,
   "version":"1.0"
}

event:poke 
data:{  
   "ts":"2017-08-04T19:29:28.921Z"
}

event:poke 
data:{  
   "ts":"2017-08-04T19:29:33.922Z"
}

Response Field Descriptions

versionstringIndicates the resource payload version. Validic will make future updates to the structure of the resource payload where breaking changes will receive a new version.
tsstringTime stamp which identifies when data entered the stream.
event:pokestringA pke event acts as a "heart beat" which indicates the stream is active.
idstringUnique identifier for the record.
checksumstringA derived value useful when comparing records with the same id for data updates.
typestringThe Validic Resource type. For Measurement records the type will be measurements.
start_timestringThe start time of the event represented in UTC. Format: YYYY-MM-DDThh:mm:ssZ.
end_timestringThe end time of the event represented in UTC. Format: YYYY-MM-DDThh:mm:ssZ.
utc_offsetintegerThe offset in seconds from UTC.
offset_originstringThe source of the UTC offset. Valid values: source (UTC offset received from the original record), profile (UTC offset received from the source's user profile), user_defined (UTC offset provided by user's time zone selection upon authorization through the Validic Marketplace).
userobjectA User object that contains identifiers related to the user.
user>uidstringThe customer's user ID.
user>user_idstringValidic user ID.
user>customer_idstringValidic customer ID.
log_idstringThe unique identifier for the record provided by the source.
sourceA source object that contains source specific information.
source>typestringThe source Validic retrieved the data from.
source>deviceobjectA device object containing information about the device that generated the data if available.
source>device>namestringThe name of the device.
source>device>typestringThe type of the device.
namestringA free form field that defines the meal type or food type for the record.
categorystringThe category of the meal. Valid values: food, meal, other.
metricsarrayAn array of Metrics. Refer to the Metrics documentation for further information.
segmentsarrayAn array of Segments. A more granular view of the items that compose the nutrition event.
segment>namestringA free form field that defines the food type for the segment.
segment>metricsarrayMetrics for the given segment.
created_atstringThe record processed time represented in UTC. Format: YYYY-MM-DDThh:mm:ssZ.