Reading the entire log

Is there any sample code available that can show us how to record say 10 events to a stream, and then later read back all 10? We’re finding we can see the first and last only.

It’s possible to do by loading a commitId, although keep in mind that this code path is not optimized so you might run into performance issues.

  1. Get all commitIds of a stream
  2. Load a stream with a commitId using loadStream

We are working on a new API that provides more low level access to events: Ceramic API | Ceramic Improvement Proposals. This is very much a work in progress, have a look in the forum for discussions on this topic.

1 Like

Joel’s comment above links to the http API docs. If you are using the standard javascript Ceramic HTTP client in your application code, you can load the stream with the loadStream, then on the resulting Stream handle you can call the allCommitIds accessor to get the list of all CommitIDs from the stream history. You can then pass those CommitIDs back to loadStream to load the stream at the state it was at at that commit. This might be easier than working with the underlying raw http requests directly.

As Joel mentioned, be aware that loading streams at historical commits is not a well optimized codepath and may cause performance issues if you are doing it frequently.