1.1.0 • Published 7 years ago

pull-streamdata.io v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

pull-streamdata.io

streamdata.io server-sent events as a pull-stream source

Creates a pull-stream source from streamdata.io sever-sent events (SSE) in Node.js and the browser

Usage

var streamdata = require('pull-streamdata.io')
var pull = require('pull-stream')

var URL = 'https://www.reddit.com/r/random.json?obey_over18=true'
var appToken = 'ODRlZDNmYmUtMDAxZC00NWJmLTgwMzQtNTkzMWJiYjFhYjVj'

var SSE = streamdata(URL, appToken)

// pull from streamdata.io 4 times and then closes the SSE
pull(
  SSE,
  pull.take(4),
  pull.log()
)

outputs

{kind: "Listing", data: {…}}
{kind: "Listing", data: {…}}
{kind: "Listing", data: {…}}
{kind: "Listing", data: {…}}
streamdataio.min.js:1 Closing the SSE Stream.

API

var streamdata = require('pull-streamdata.io')

streamdata(url, appToken, headers, privateKey)

  • url: (String) The rest endpoint you set https://streamdata.io to poll for changes.
  • appToken: (String) Your auth key from https://streamdata.io
  • headers: (Optional) (Array) Additional headers for the SSE
  • privateKey (Optional) (String): Your private auth key from streamdata.io if you chose to generate one

Install

With npm installed, run

$ npm install pull-streamdata.io

See Also

License

MIT