Build Streaming APIs with AMPLIFY API Management and Streamdata

With streaming APIs, it’s possible to push relevant updates to client devices from the server, which offers a couple of interesting benefits for large, distributed systems. In this post, I’ll show you how to use a combination of Axway’s API Management solution and Streamdata to securely virtualize and stream a JSON/REST API to end clients.

To do this exercise, we need the following:

Let’s get started! You can choose to host the setup on a machine in the cloud. Here, I’m running all components (except, of course, Streamdata) on my laptop. After starting the Stock Quote service, we can inspect the JSON data in the browser:

Now, we’re virtualizing the API in API Manager. To do this, we can import the Swagger using the URL that the Yoisho service exposes:

In this scenario, API Manager helps us to protect the backend with quota settings, preventing malicious content and only allowing authorized access. Specifically, we’re keen to ensure that only Streamdata can access the endpoint. For this, we’re definining API Keys as the authentication mechanism and specifying that the key has to be in the HTTP Query String:

We now have a secured REST endpoint, protected with an API Key. This is the URL we need to specify in the streamdata interface. Let’s test it in the browser to see if it works:

In the Streamdata admin tool, we can now create a new stream API. Here, we’re adding the URL of our endpoint and the API Key that the service needs to use in order to authenticate [2]:

And we’re done! Now we can use cURL to trigger a client request and see the initial content and the updated stock quotes. Your command should look something like the following:

curl -v ""

You will see the difference to a “classic” API request immediately – the connection does not terminate, which you can also notice from the Content-Type: text/event-stream header. Furthermore, while the initial response will return all data fields, the subsequent pushs will only return the ones that have changed (JSON-Patch) since the last poll from Streamdata to the backend.

I hope this helps you understand the concept of streaming APIS, the benefits and how this can be implemented using the Axway API Management solution.

[1] Important Note: If you’re keen to try this yourself, please enable the Content-Length setting in API Manager as described in this KB article.

[2] I’m using ngrok to expose the HTTP service running on my laptop to the internet. It’s even giving me an HTTPS endpoint with a valid certificate – Streamdata requires this