# How to stream events from a specified offset using json-api?

**URL:** <https://forum.canton.network/t/how-to-stream-events-from-a-specified-offset-using-json-api/1227>\
**Category:** App Development\
**Tags:** json-api\
**Created:** [September 14, 2020, 11:29pm UTC](https://forum.canton.network/t/how-to-stream-events-from-a-specified-offset-using-json-api/1227 "2020-09-14T23:29:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thejaswani](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/thejaswani/32/640_2.png) [@Thejaswani](https://forum.canton.network/u/Thejaswani)\
**Post date:** [September 14, 2020, 11:29pm UTC](https://forum.canton.network/t/how-to-stream-events-from-a-specified-offset-using-json-api/1227/1 "2020-09-14T23:29:13Z")

</div>

Hi,  
I tried sending out this message to WebSocket to listen the events from the given offset. Got a WebSocket connection closure. I can’t find any example in DAML docs, is this the right way?

> daml json-api --ledger-host localhost --ledger-port 6865 --http-port 7575 --application-id IouApp --websocket-config maxDuration=120,heartBeatPer=5

Message sent:

> [{"offset": "00000000000000080000000000000000"}, {"templateIds":["e7d9277285b7bca99a69d3658c542ce24ba35f38b6234c462f33f37322380901:TestingToolkit.Master:Master", "e7d9277285b7bca99a69d3658c542ce24ba35f38b6234c462f33f37322380901:TestingToolkit.Master:Wallet", "e7d9277285b7bca99a69d3658c542ce24ba35f38b6234c462f33f37322380901:TestingToolkit.Coin:Coin"]}]

Received

> CloseReason[1000]

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [September 15, 2020, 7:11am UTC](https://forum.canton.network/t/how-to-stream-events-from-a-specified-offset-using-json-api/1227/2 "2020-09-15T07:11:01Z")

</div>

The offset should be sent as a separate message, not within the array of queries.

However, it is worth noting that you should only ever use an `offset` that you got from a previous query. The streaming API is still a state-based API not an event-based API and not targeted at usecases like streaming all events since the beginning. Offsets are mainly there as an optimization: If you have a large ACS, streaming only the delta since the last offset can be faster than starting with a full ACS query again.

If you do really want individual transactions and events since a given ledger API offset, you have to resort to the gRPC API for now.
