Streams

Setting up a streaming API with Pivotal Web Services and Streamdata.io

We are thrilled to have our service available in the marketplace of Pivotal.io.

Pivotal.io is the premier platform for running modern applications atop either public or private clouds. Streamdata.io provides a proxy-as-a-service that turns any request-response REST API into an event-driven streaming API. You can learn more about Streamdata.io by visiting our product page and about the technologies we use on our developer’s page.
To give you a quick summary:

– If you are hosting your API on Pivotal, you’re minutes away from being able to provide a streaming version of your API to your customers. (Why should I sell a streaming version of my API?)

– If you are hosting your apps on Pivotal, Streamdata.io allows you to build amazing animated interfaces with real-time data updates. (Why streaming provides better UX than polling?)

In order to make your life easier if you’re new to Streamdata.io, we wrote this tutorial to help you set up the service as a Pivotal user. Following the tutorial should take you about five minutes, at the end of which you’ll have a fully operational streaming API.

Step-by-step Tutorial

Let’s walk through the different steps to register for a Streamdata.io account through Pivotal.io Marketplace. If you are not a Pivotal user yet, you easily can create an account here.

Once you have set up your Pivotal account, click on Marketplace at the left menu of your Pivotal console.

Search for Streamdata.io and select it. It will bring you here:

Select the plan that fits with your needs and configure the name of the service instance and the target environment. For testing purposes, we will use a development environment.

Then click Add.

You have successfully added a Streamdata.io service instance to your environment. You can now click on Streamdata.io service and click manage.

It will redirect you to Streamdata.io Portal where you have access to your dashboard provisioned with a default app.

Click on the MyApp card. It will take you to a getting started page where you can make the first test using cURL and that provides you quick access to the different client libraries & demos to integrate real-time streaming in your application.

Go to My APIs by clicking on the left menu entry. It should be empty, so let’s auto-provision an API by running the cURL request provided in the getting started guide. We are using a public API hosted by Streamdata.io which randomly generates data each time it is called. This API can be reached using the following URL.

Once done, you should see the first entry like this:

Click on Configure.

A form is displayed that allows you to configure the polling frequency that Streamdata.io will apply to fetch data from the target endpoint. You can also inject specific query params and headers to be added to the polling requests made by Streamdata.io to the target URL.

Now let’s have a deeper look at the stream while testing our first API. Run the previous cURL command again.

curl -v "https://streamdata.motwin.net/http://stockmarket.streamdata.io/prices?X-Sd-Token=<YOUR-SD-APP-TOKEN>"

Note: Make sure to keep the “https://streamdata.motwin.net/” as a prefix and do not forget to replace <YOUR-SD-APP-TOKEN> by the appropriate value.

You should receive a first snapshot of your content (event:data) followed by JSON patch updates (event:patch) whenever a change is happening.

If you change the polling frequency in the Portal while the curl is running, you will see that the rate of push updates will dynamically adapt.

I hope you have enjoyed! If you want to know more about Streamdata.io, read our How it works page.

**Original source: streamdata.io blog