Registry / messaging / kafka-rest

kafka-rest

JSON →
library0.0.5jsnpmunverified

Node.js library for the Confluent Kafka REST Proxy. Version 0.0.5 provides a thin wrapper around the REST API for cluster metadata, Avro and binary data production/consumption. Requires the async library. Key differentiator: simplifies interaction with Kafka REST Proxy vs raw HTTP calls.

npm install kafka-rest
INSTALL
IMPORT
SIG · KAFKA-REST
K
kafka-rest
messagingjavascriptv0.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

KafkaRest
const KafkaRest = require('kafka-rest')
import KafkaRest from 'kafka-rest'
Uses CommonJS; no default ES export. Use require.
default
const KafkaRest = require('kafka-rest')
const { KafkaRest } = require('kafka-rest')
Library exports single constructor as module.exports.
(none)
const kafka = new KafkaRest({ url: 'http://localhost:8082' })
new KafkaRest('http://localhost:8082')
Config must be an object with url property.

Initialize client, list topics, produce a message, and consume messages from a consumer group.

const KafkaRest = require('kafka-rest'); const kafka = new KafkaRest({ url: process.env.KAFKA_REST_URL ?? 'http://localhost:8082' }); // List topics kafka.topics.list((err, topics) => { if (err) console.error(err); else topics.forEach(t => console.log('Topic:', t.raw)); }); // Produce a message kafka.topic('test').produce('hello world', (err, res) => { if (err) console.error(err); else console.log('Produced:', res); }); // Consume using a consumer group const consumer = kafka.consumer('my-group'); consumer.join('test', (err) => { if (err) console.error(err); else consumer.consume((err, msgs) => { if (err) console.error(err); else msgs.forEach(m => console.log('Msg:', m.value)); }); });
Debug
Known issues
gotchaConfig must be an object with 'url' property, not a string.
fix
Pass { url: 'http://...' } instead of just the string.
affects: >=0.0.0
deprecatedLibrary is no longer actively maintained. Consider using confluent-kafka-javascript or kafkajs for new projects.
fix
Migrate to a maintained Kafka client.
affects: >=0.0.0
gotchaThe REST Proxy must be running and accessible; library does not auto-retry connection.
fix
Ensure KAFKA_REST_URL is correct and proxy is up before using the client.
affects: >=0.0.0
gotchaTopic and partition objects created via kafka.topic('name') are incomplete until get() is called.
fix
Call topic.get() or use the full resource path to fetch metadata.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: kafka.topics.list is not a function
Using ES import or destructuring incorrectly
fix
Use const KafkaRest = require('kafka-rest'); then new KafkaRest({...})
Error: connect ECONNREFUSED 127.0.0.1:8082
Kafka REST Proxy not running or wrong URL
fix
Start the proxy or set KAFKA_REST_URL environment variable to correct endpoint.
TypeError: kafka.topic(...).produce is not a function
Incomplete topic object without metadata
fix
Use kafka.topic('test', callback) to fetch first, or use kafka.topics.topic('test').produce()
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies
asyncrequiredused for control flow in library internals
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
kafka-rest — npm install kafka-rest · libregistry