Congratulations, you are successfully sending data to the Stream! Even though the JS Bin example runs locally in your browser, go ahead and delete the “Tutorial” API key on the Profile page, just in case.

Using streamr-client in node.js

The client works similarly in node.js. In your project, first install the client library:

npm install --save streamr-client

Then, let’s create a little node.js script which sends an event to your Stream (again, replace MY-STREAM-ID and MY-API-KEY with your Stream ID and your API key):

const StreamrClient = require('streamr-client') const STREAM_ID = 'MY-STREAM-ID'

const API_KEY = 'MY-API-KEY' // Create the client and give the API key to use by default

const client = new StreamrClient({

apiKey: API_KEY

}) // Here is the event we'll be sending

const msg = {

hello: 'world',

random: Math.random()

} // Produce the event to the Stream

client.produceToStream(STREAM_ID, msg)

.then(() => console.log('Sent successfully: ', msg))

.catch((err) => console.error(err))

Note that the library requires node.js ≥ 8. When you run the above, a new event should immediately appear under “Recent Events” on your Stream page!

What if my app is not in JavaScript?

You can interact with the Streamr API using any HTTP library of your choice. You will find all the details in the API docs, but here’s a brief rundown:

You’ll be making HTTP POST requests to a URL, which contains your Stream ID:

https://www.streamr.com/api/v1/streams/MY-STREAM-ID/data

The body of the request will be your data payload in JSON

Add your API key to the HTTP headers as follows:

Authorization: token MY-API-KEY

This is how a test request would look in the fabulous Postman app, with the URL and Authorization header set: