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 kc command line tool provides commands for getting information about the Kafka Connect cluster and its connectors, creating new connectors, updating existing connectors, deleting connectors, etc.

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

Install

pip install kafka-connect-py

Command Line Usage

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

$ kc get-cluster

Retrieve the details of a single connector.

$ kc get-connector <connector>

Retrieve a list of active connectors. The `--expand' option can be used to retrieve additional information about the connectors, such as their status or metadata.

$ kc get-connectors [--expand=status|info]

Create a new connector using the configuration specified in the given file. If the connector already exists or a rebalance is in process, Wil return a status code of 409.

$ kc create-connector <config_file>

Update the configuration for an existing connector. If a rebalance is in process, Wil return a status code of 409.

$ kc update-connector <connector> <config_file>

Retrieve the configuration of a connector.

$ kc get-connector <connector>

Retrieve the config of a connector.

$ kc get-connector-config <connector>

Retrieve the status of a connector.

$ kc get-connector-status <connector>

Retrieve the tasks of a connector. The `--include-tasks' option can be used to include task information in the response.

$ kc get-connector-tasks <connector> [--include-tasks]

Pause a connector.

$ kc pause-connector <connector>

Resume a connector that was previously paused.

$ kc resume-connector <connector>

Delete a connector.

$ kc delete-connector <connector>

Validate the configuration specified in the given file. If the configuration is valid, Wil return a status code of 200.

$ kc validate-connector-config <config_file>

Retrieve metadata about the specified connector plugin.

$ kc get-connector-plugin <connector>

Retrieve metadata about all available connector plugins.

$ kc get-connector-plugins

Python

# Import the class
from kafka_connect import KafkaConnect

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

# Get the version and other details of the Kafka Connect cluster
cluster = client.get_cluster()
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.2.3

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.2.3
File Size Uploaded Provenance Actions
kafka_connect_py-0.2.3.tar.gz 6.4 kB Without provenance Details for kafka_connect_py-0.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 12.6 kB

Release files / kafka_connect_py-0.2.3.tar.gz

Download URL kafka_connect_py-0.2.3.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c3f7dd241b20d0c4eb01a6b2a85cfd4610b8bbdb9eaea66c7599117104410af0
BLAKE2b-256 checksum
How to use checksums
b1f91a2b6e966881d1c30195339f3e5602f4f3948e19365a6863df439039df8c
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.2.3-py3-none-any.whl

Download URL kafka_connect_py-0.2.3-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7eb4ed6ee392d4254a9312e266e4f4d6fed380e1d34a97f5f88a9c5e00c25e81
BLAKE2b-256 checksum
How to use checksums
5d79a0fa5400248098430d8d6a8b326135da9ab4bc1319ecfa627c2a20d338c5
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.2.3

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.2.3 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