---
title: "The Kafka Connect API"
url: "https://vanducng.dev/2020/06/23/The-Kafka-Connect-API/"
date: "2020-06-23"
categories: ["Data"]
tags: ["api","kafka"]
---

# The Kafka Connect API

Apart from core APIs which requires external systems to install Kafka client for the integration, Kafka also supports `Kafka Connect API` with REST API for the more flexibility in communicating with different systems. This note is to collect list of basic APIs on frequent useage.

## Viewing Connectors
```bash
curl http://localhost:8083/connector-plugins | python -m json.tool
```
* The `| python -m json.tool` above simply takes the output of the curl command and prints the JSON nicely. You can omit this if you'd like!

## Create a Connector
```bash
curl -X POST -H 'Content-Type: application/json' -d '{
    "name": "first-connector",
    "config": {
        "connector.class": "FileStreamSource",
        "tasks.max": 1,
        "file": "/var/log/journal/confluent-kafka-connect.service.log",
        "topic": "kafka-connect-logs"
    }
  }' \
  http://localhost:8083/connectors
```

## List connectors
```bash
curl http://localhost:8083/connectors | python -m json.tool
```

## Detailing connectors
```bash
curl http://localhost:8083/connectors/first-connector | python -m json.tool
```

## Pausing connectors
Sometimes its desirable to pause or restart connectors:

### To pause
```bash
curl -X PUT http://localhost:8083/connectors/first-connector/pause
```

### To restart
```bash
curl -X POST http://localhost:8083/connectors/first-connector/restart
```

## Deleting connectors
```bash
curl -X DELETE http://localhost:8083/connectors/first-connector
```
