...
POST /topics/test/partitions/1 HTTP/1.1 Host:kafkarest.host.com Content-Type: application/vnd.kafka.binary.v1+json Accept: application/vnd.kafka.v1+json { "records": [ { "key": "a2V5", "value": "dmFsdWU=" }, { "value": "dmFsdWU=" } ] } |
Example response:
HTTP/1.1 200 OK Content-Type: application/vnd.kafka.v1+json { "offsets": [ { "partition": 1, "offset": 1, }, { "partition": 1, "offset": 2, } ] } |
Consumer API
Description : Create a new consumer instance in the consumer group.
POST /consumers/:group |
Parameters:
group (String) - group name
Request:
JSON Object contains name, dataformat, consumer properties.
Response:
JSON Object contains response objects.
Response includes a URL including the host since the consumer is stateful and tied to a specific REST proxy instance
Status Codes:
404 Not Found
Error Code 40401 - topic Not Found
Error Code 40402 - partition Not Found
500 Internal Server Error
Error Code 50001 - Kafka Error
Example request:
POST /consumers/group/ HTTP/1.1 Accept: application/vnd.kafka.v1+json, application/vnd.kafka+json, application/json { "name": "Instance1", "format": "binary", "auto.offset.reset": "smallest", "auto.commit.enable": "false" } |
Example response:
HTTP/1.1 200 OK Content-Type: application/vnd.kafka.v1+json { "id": "Instance1", "url": "http://kafkarest1.com/consumers/group/instances/Instance1" } |
...
HTTP/1.1 200 OK Content-Type: application/vnd.kafka.binary.v1+json [ { "key": "a2V5", "value": "dmFsdWU=", "partition": 1, "offset": 1, }, { "key": "a2V5", "value": "dmFsdWU=", "partition": 1, "offset": 2, } ] |
POST /topics/:group/offsets
Description : Commit offsets for the consumer instance associated with group.
POST /consumers/:group/:instance/offsets |
Parameters:
group (String) - consumer group id
Instance (String) - consumer instance name
Response:
JSON Object contains response objects
Status Codes: 404
404 Not Found
Error Code 40401 - group Not Found
Error Code 40402 - consumer instance Not Found
500 Internal Server Error
Error Code 50001 - Kafka Error
Example request:
POST / |
consumers/group/instance1/offsets HTTP/1.1 Accept: application/vnd.kafka.v1+json |
Example response:
HTTP/1.1 200 OK Content-Type: application/vnd.kafka.v1+json [ { "topic": " |
test", "partition": 1, "committed": |
100 }, { "topic": " |
test", "partition": 2, "committed": |
200 }, { "topic": "test2", "partition": 1, "committed": 50 } ] |
GET /topics/:topic_name/partitions/:partition?offset=(int)
Description : Consume messages from one partition of the topic.
Parameters:
topic_name (String) - topic name
partition (int) - partition number
offset (int) - offset to fetch
Response:
JSON Object contains response objects
Status Codes:
404 Not Found
Error Code 40401 - topic Not Found
Error Code 40402 - partition Not Found
500 Internal Server Error
Error Code 50001 - Kafka Error
Example request:
GET /consume/test/partitions/1?offset=1 HTTP/1.1 Accept: application/vnd.kafka.binary.v1+json |
Example response:
HTTP/1.1 200 OK Content-Type: application/vnd.kafka.binary.v1+json [ { "key": "a2V5", "value": "dmFsdWU=", "partition": 1, "offset": 1, }, { "key": "a2V5", "value": "dmFsdWU=", "partition": 1, "offset": 2, } ] |
...