POST
request to an endpoint exposed by Tyk Gateway (e.g., /chat
).POST
request. An API definition configured with Tyk Streams defines this endpoint as an input. Tyk takes the request payload and publishes it as a message onto a designated backend topic (e.g., the chat
topic in Kafka).chat
topic for incoming requests./chat
endpoint before the message even enters the Kafka system.discussion
topic in Kafka).discussion
topic.discussion
topic, it pushes the message content (the joke) to the appropriate client(s) (provided they have already established a connection) using a suitable real-time protocol like Server-Sent Events (SSE) or WebSockets.
Note: In case of multiple clients, events would round-robin amongst the consumers..env
file and populate it with the values below:
DASHBOARD_LICENCE
: Add your license key. Contact support to obtain a license.GATEWAY_IMAGE_REPO
: Tyk Streams is available as part of the Enterprise Edition of the Gateway.TYK_DB_STREAMING_ENABLED
and TYK_GW_STREAMING_ENABLED
: These must be set to true
to enable Tyk Streams in the Dashboard and Gateway, respectively. Refer to the configuration options for more details.Kafka
within a Docker container, which is necessary for this guide.producer.json
with the below content: (Note: tyk-demo-kafka-1
is the hostname used to access Kafka running in a container; alternatively, you can use the IP address assigned to your computer.)
Create the API by executing the following command. Be sure to replace <your-api-key>
with the API key you saved earlier:
consumer.json
with the below content: (Note: tyk-demo-kafka-1
is the hostname used to access Kafka running in a container; alternatively, you can use the IP address assigned to your computer.)
Create the API by executing the following command. Be sure to replace <your-api-key>
with the API key you saved earlier:
joker-service.sh
with the below content:
Make the file executable and start the service.
Stream Instances
. It ensures the correct streaming infrastructure is ready based on the API definition.Stream Middleware
. It checks the request path against the stream routes defined in the API configuration.Stream Middleware
does nothing, and the request continues down the standard Tyk middleware chain, typically being proxied to the configured upstream service. Stream Middleware
takes control of the request handling.Stream Manager
associated with the API’s stream configuration. The Stream Manager
ensures the required Stream Instance
(s) are initialized and running based on the loaded configuration. This might involve creating a new instance or reusing a cached one.Upstream Service / Event Broker
(e.g., publishing a message to Kafka, subscribing to an MQTT topic, forwarding data over a WebSocket).Stream Analytics
component captures relevant metrics throughout the stream handling process.x-tyk-streaming
extension. This is where you specify how data flows for a particular asynchronous API.enabled
to true
in the streaming
section of your tyk.conf
file or via environment variables.
tyk_analytics.conf
) to expose Streams-related UI elements and functionality.
x-tyk-streaming
vendor extension.
The core structure under x-tyk-streaming
is the streams
object, which contains one or more named stream configurations. Each named stream defines:
input
: Specifies how data enters this stream (e.g., via an HTTP request, by consuming from Kafka, connecting via WebSocket).output
: Specifies where the data goes after processing (e.g., published to Kafka, sent over WebSocket, delivered via webhook).input
and output
. The specific types available (like http_server
, kafka
, http_client
, etc.) and their respective configuration parameters are detailed in the Tyk Streams Configuration Reference. Please consult this reference page for the full list of options and how to configure each one.
Example Configuration:
x-tyk-streaming
, see the Tyk OAS Extension documentation.Mapping
processor is currently available and working, but it will be officially supported starting from version 5.9.0.You’re welcome to explore and experiment with this feature in non-production environments today. For production use, we recommend waiting for the official release in 5.9.0 to ensure full support.Mapping
script that performs the following operations:
<portal-api-secret>
with the secret key for signing the webhook messages.
Enabling webhook subscriptions allows developers to easily integrate real-time updates and notifications from async APIs into their applications, enhancing the overall developer experience and facilitating seamless communication between systems.
With Tyk Streams and the Developer Portal integration, API publishers can effectively manage and expose async APIs, while developers can discover, subscribe to, and consume event streams effortlessly, enabling powerful real-time functionality in their applications.
What is Tyk Streams and what problem does it solve?
Which event brokers and protocols does Tyk Streams support?
How can I enable Tyk Streams on Tyk Cloud?
Can I publish Tyk Streams APIs to the Developer Portal?
What deployment considerations should I keep in mind for Tyk Streams?
Is Tyk Streams available in all Tyk editions?
enterprise
edition. Currently, it is only accessible for hybrid customers using Tyk Cloud. Please refer to the latest documentation or reach out to Tyk support for specific availability in your edition.