New to Kestra?
Use blueprints to kickstart your first workflows.
Call a REST API, then publish the JSON response to a Kafka topic with Kestra. Declarative YAML, retries, and event-driven orchestration for streaming pipelines.
id: produce-kafka-message
namespace: company.team
tasks:
- id: api
type: io.kestra.plugin.core.http.Request
uri: https://dummyjson.com/products
- id: produce
type: io.kestra.plugin.kafka.Produce
from:
key: mykey
value: "{{ outputs.api.body }}"
timestamp: "{{ execution.startDate }}"
headers:
x-header: some value
keySerializer: STRING
valueSerializer: JSON
topic: mytopic
properties:
bootstrap.servers: my.kafka.k8s.com:9094
Move data from an HTTP REST API into Apache Kafka without writing a producer service. This flow calls a REST endpoint, captures the JSON response, and publishes it as a message to a Kafka topic, giving you a repeatable, observable bridge between request-response APIs and your event-streaming backbone. It solves the common problem of getting external or internal API data onto a Kafka topic so downstream consumers, stream processors, and sinks can react to it in real time.
api task (io.kestra.plugin.core.http.Request) sends an HTTP request to https://dummyjson.com/products and stores the response body.produce task (io.kestra.plugin.kafka.Produce) builds a message from a from map containing key, value, timestamp, and headers. The value is set to {{ outputs.api.body }}, the JSON body returned by the api task, and the timestamp uses {{ execution.startDate }}.keySerializer: STRING and valueSerializer: JSON, then written to the topic mytopic on the cluster defined by properties.bootstrap.servers.Kafka producers run inside application code, but Kestra makes producing messages a first-class, scheduled, and event-driven workflow. You get declarative YAML instead of bespoke producer services, automatic retries on transient API or broker failures, and end-to-end lineage from the upstream API call to the published record. Kafka's own tooling has no scheduler or dependency engine: it cannot fetch the API, sequence the request before the publish, or retry the whole pipeline as a unit. Kestra fills that gap with triggers, conditional logic, and full observability.
properties.bootstrap.servers.mytopic (or update the topic property to match yours).This example connects to an open API and a broker address inline, so no secret() values are required. For production, move broker credentials and any API tokens into secrets and reference them, for example {{ secret('KAFKA_BOOTSTRAP_SERVERS') }}.
properties.bootstrap.servers with your cluster URL and confirm the topic exists.mytopic to confirm the API payload arrived as a JSON message.api task URI for your own endpoint, or chain multiple requests.from to publish several messages in one run.Schedule or webhook trigger to publish on a cadence or on demand.