Stream your AWS API Gateway

This quick & easy tutorial aims to explain how to stream an API powered by AWS API Gateway using in 4 steps.

Let’s start with an introduction to AWS API Gateway: It provides a managed service to enable developers to create, publish, maintain, monitor, and secure APIs. As we will see, it requires only a few clicks in the AWS Management Console, to create an API that acts as a “front door” for applications to access data, business logic, or functionality from your back-end services.

1 – Create a new API
First step required by AWS when getting started with their API Gateway is to create an new API:

create new api

Enter a name and click Create API

2 – Create a Method
After having clicked on Create Method, you first need to select the HTTP Verb of your API. We will choose GET as we only need an API to retrieve data.
Then, AWS ask you to select the Integration type. AWS provides many different Integration types to enable you to quickly expose an API from a Lambda function or many other AWS services (through the advanced option).
As we already have an HTTP Endpoint called that mocks a market data feed, we will use AWS API Gateway in HTTP proxy mode.

create method

Click Save. AWS should display the Method Execution of your previously created API and you see something like that:

api method execution

There is a lot of interesting stuff here, clicking on the different block of the workflow will give you access to different features modify the behavior of your API. As an example clicking on Method Request gives you the ability to change the Authorization setting or inject additional Query Parameters and Request Headers.
We will not go through all the possibilities but I invite you to take a look at AWS API Gateway Documentation, it will give you a better idea of all the capabilities.

3 – Deploy your API
Now that everthing is setup let’s deploy our API but simply clicking on Deploy API. AWS will prompt you to select a Deployment stage. If you do not have one yet, create it by selecting “New stage” in the dialog box.

deploy api


Then, click Deploy.

After having successfully created your stage, AWS gives you access to additional stage settings such as Caching, CloudWatch Alarms, Rate limiting. You can also export your API definition compatible with Swagger format. Nice!
The most important thing for us is to get the Invoke URL from which your API can be called.

Let’s make a quick test with cURL:

curl "https://<your-subdomain><stage-name>"

You should get a response like this:

    {"title":"Value 0","price":56,"param1":"value1","param2":"value2",
    {"title":"Value 1","price":25,"param1":"value1","param2":"value2",
    {"title":"Value 2","price":32,"param1":"value1","param2":"value2",
    {"title":"Value 3","price":58,"param1":"value1","param2":"value2","param3":"value3",...

4 – Stream your API
Now that we have a working API let’s stream it using
You can use our demo proxy to make a quick test it using following cURL command:

curl "<your-subdomain><>"

Note: Make sure to keep the as a prefix and do not forget to replace <your-subdomain> by the Invoke URL provided by AWS API Gateway.

You should now receive a first snapshot of your content followed by JSON patch updates whenever a change is happening.

data:[{"title":"Value 0","price":94,"param1":"value1","param2":"value2","param3":"value3",
{"title":"Value 1","price":14,"param1":"value1","param2":"value2", ...


Hope you have enjoyed! If you are not a user yet, you can quickly create an free account here.

**Original source: blog