Skip to main content

Kafka Connect Python

The Kafka Connect REST API allows you to manage connectors that move data between Apache Kafka and other systems.

The Kafka Connect command line tool, also known as kc or kafka-connect, allows users to manage their Kafka Connect cluster and connectors. With this tool, users can retrieve information about the cluster and connectors, create new connectors, update existing connectors, delete connectors, and perform other actions.

This project aims to supported all features of the Kafka Connect REST API.

Install

pip install kafka-connect-py

Command Line Usage

Get the version and other details of the Kafka Connect cluster.

kc info
Get a list of all connectors
kc list [--expand=status|info] [--connector-pattern=regex]
Get the details of a single connector
kc get <connector>
Get the details of all connectors
kc get --all-connectors [--connector-pattern=regex]
Get the status of all connectors
kc status --all-connectors [--connector-pattern=regex]
Get the config of a connector
kc config <connector>
Get the config of all connectors
kc config --all-connectors [--connector-pattern=regex]
Create a new connector with a JSON file
kc create --config-file <config-file>
Create a new connector with inline JSON data
kc create --config-data <config-data>
Update the configuration for an existing connector with a JSON file
kc update <connector> --config-file <config_file>
Update the configuration for an existing connector with inline JSON data
kc create <connector> --config-data <config-data>
Restart a connector
kc restart <connector> [--include-tasks] [--only-failed]
Restart all connectors
kc restart --all-connectors [--connector-pattern=regex] [--include-tasks] [--only-failed]
Pause a connector
kc pause <connector>
Pause all connectors
kc pause --all-connectors [--connector-pattern=regex]
Resume a connector
kc resume <connector>
Resume all connectors
kc resume --all-connectors [--connector-pattern=regex]
Delete a connector
kc delete <connector>
Delete all connectors
kc delete --all-connectors [--connector-pattern=regex]

Python

# Import the class
from kafka_connect import KafkaConnect

# Instantiate the client
client = KafkaConnect(url="http://localhost:8083")

# Get the version and other details of the Kafka Connect cluster
cluster = client.get_info()
print(cluster)

# Get a list of active connectors
connectors = client.get_connectors()
print(connectors)

# Create a new connector
config = {
    "name": "my-connector",
    "config": {
        "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
        "tasks.max": "1",
        "connection.url": "jdbc:postgresql://localhost:5432/mydatabase",
        "connection.user": "myuser",
        "connection.password": "mypassword",
        "table.whitelist": "mytable",
        "mode": "timestamp+incrementing",
        "timestamp.column.name": "modified_at",
        "validate.non.null": "false",
        "incrementing.column.name": "id",
        "topic.prefix": "my-connector-",
    },
}
response = client.create_connector(config)
print(response)

# Update an existing connector
new_config = {
    "config": {
        "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
        "tasks.max": "1",
        "connection.url": "jdbc:postgresql://localhost:5432/mydatabase",
        "connection.user": "myuser",
        "connection.password": "mypassword",
        "table.whitelist": "mytable",
        "mode": "timestamp+incrementing",
        "timestamp.column.name": "modified_at",
        "validate.non.null": "false",
        "incrementing.column.name": "id",
        "topic.prefix": "my-connector-",
    },
}
response = client.update_connector("my-connector", new_config)
print(response)

# Restart a connector
response = client.restart_connector("my-connector")
print(response)

# Delete a connector
response = client.delete_connector("my-connector")
print(response)

Tests

python3 -m unittest tests/test_kafka_connect.py -v

Metadata

Release files for kafka-connect-py 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kafka-connect-py 0.8.0
File Size Uploaded Provenance Actions
kafka_connect_py-0.8.0.tar.gz 8.9 kB Without provenance Details for kafka_connect_py-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kafka-connect-py 0.8.0
File Interpreter ABI Platform Actions
kafka_connect_py-0.8.0-py3-none-any.whl Python 3 none any Details for kafka_connect_py-0.8.0-py3-none-any.whl

Total release size: 17.5 kB

Release files / kafka_connect_py-0.8.0.tar.gz

Download URL kafka_connect_py-0.8.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e8eff8e44abfee375b55eff708e21072a275b0c489ac2846fbbc6703feb8b3ca
BLAKE2b-256 checksum
How to use checksums
b8a660b3c7baa22ea195b9855d51a523cef2b6403736b61d81bb05ce936031ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.11.0 Darwin/20.6.0

Release files / kafka_connect_py-0.8.0-py3-none-any.whl

Download URL kafka_connect_py-0.8.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c11e7b700346dd292f4680a70b13fd7408385e9abc0c95ffaf107aea18e4e6b4
BLAKE2b-256 checksum
How to use checksums
0f8ea7c09d2de0b921791028382182fd9bf3f8b97cc28eb410093bd7e609f579
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.11.0 Darwin/20.6.0

Security for kafka-connect-py 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page