Skip to navigation

Manage Kafka APIs using Postman

View as Markdown

Postman can make requests using Kafka, a distributed event-streaming platform used for publishing and consuming ordered, replayable streams of records across producers and consumers. Kafka requests can produce a message to a topic, consume messages from a topic with a bounded stop condition, and inspect the payload, headers, and key of each message, without writing your own consumer or producer code.

A Kafka request in Postman operates in one of two modes:

  • Producer: sends one or more messages to a topic. You can compose the message value, key, and headers, and reuse variables from earlier steps in a run.
  • Consumer: subscribes to one or more topics and reads messages until a stop condition is met. Because a live topic is an unbounded stream, every consumer request in Postman runs as a bounded consume: it stops after one configured bound, such as a message count, duration, idle timeout, or timestamp. See Create and configure a Kafka request for how to set stopAfter.

You can also generate a Kafka collection directly from an AsyncAPI specification in Spec Hub, with brokers, topics, and example payloads already filled in from the spec.

Kafka requests support JSON message payloads. Avro and protobuf (protocol buffers) aren’t supported yet.

What you can do with a Kafka request

  • Create and configure a Kafka request: set up brokers, authentication, topics, and bounded consume settings.
  • Validate messages against a schema: link a topic or message to an AsyncAPI schema so Postman can flag missing fields or type mismatches as you produce and consume.
  • Write scripts for Kafka requests: use the Before produce, After produce, Before consume, On message, and After consume hooks to read and write variables, edit the request before it runs with pm.request, read each consumed message’s content with pm.message, and assert on produce and consume results with pm.response.
  • Mix Kafka steps with HTTP (and other protocol) steps in a single collection run, passing variables across protocols in one sequence.
  • Run the same mixed-protocol collection headlessly with the Postman CLI as a CI gate.