Use Bootstrap and Stream API with Livefyre Apps

Bootstrap

How can I retrieve content older than the newest 50 pieces?

Bootstrap is all content in a Livefyre App. It is the cached data, typically 12-20 minutes old. It is delivered in chunks of 50 pieces and is paginated so you can retrieve content older than 50 pieces.

API Reference: https://api.livefyre.com/docs/apis/by-category/collections#operation=urn:livefyre:apis:bootstrap:operations:bs3:v3.1:network:site:article:init:method=get

Example request:

https://data.livefyre.com/bs3/v3.1/dharam.fyre.co/384931/NTU1NQ==/init

The example request above loads the init page which contains Collection Settings and the only initial set of ~50 pieces of newest content. To poll older content, you must load subsequent bootstrap pages with N being the page number:

Request: https://{networkName}.bootstrap.fyre.co/bs3/v3.1/{network}/{siteId}/{b64articleId}/N.json

For example, this sample app has 120 pieces of content. To understand the above, note that Content "1" is the oldest piece of content and Content "70" is the newest piece of content

Click here to see the Bootstrap Poll Flowchart.

Stream API

What is Stream API?

Stream is a long poll which by design is intended to stay open for approximately 30secs. Description on Long Polling technique can be found here: https://stackoverflow.com/questions/11077857/what-are-long-polling-websockets-server-sent-events-sse-and-comet

This long-polling endpoint streams new content (e.g. a user posts a comment), content status changes (e.g. user deletes their comment, likes) and moderation changes to content (e.g. moderator approves a piece of content) to a Livefyre App.

The request to Stream API should be ~30 seconds (long-polling) with expected timeout after 30 seconds when no new content streams in.

API Reference: https://api.livefyre.com/docs/apis/by-category/collections#operation=urn:livefyre:apis:stream1:operations:v3.1:collection:updates:method=get

Example request: https://dharam.stream1.fyre.co/v3.1/collection/216689802/1520289057042029/?multi=true

Please note: The maxEventId in a Stream API response is the highest Event ID of the updates in this response. Use this value as lastEventId path parameter when building the URL of your next Stream API request to get updates occurring after all the updates in this response.

The example below uses this App for demonstration:

Comment "First comment" was posted first. "Second Comment" was posted after.

First Comment Stream API response: https://dharam.stream1.fyre.co/v3.1/collection/216689802/1520289136771588/?multi=true

The maxEventId in the above response is "1520289700953369" which will be used as lastEventId to poll the endpoint to get updates (i.e. Second Comment) occurring after all the updates in this response.

Second Comment Stream API response: https://dharam.stream1.fyre.co/v3.1/collection/216689802/1520289700953369/?multi=true

The maxEventID "1520289700953369" in the above response should in turn be used as the lastEventID to build the Stream API response for the next update.