Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
    • Deploying the Apache Kafka® web interface
    • Migrating a database from a third-party Apache Kafka® cluster to Managed Service for Apache Kafka®
    • Moving data between Managed Service for Apache Kafka® clusters using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Debezium
    • Delivering data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Debezium
    • Delivering data from Managed Service for YDB to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for ClickHouse® using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for Greenplum® using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for MongoDB using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for MySQL® using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for OpenSearch using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for PostgreSQL using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Managed Service for YDB using Data Transfer
    • Delivering data from Managed Service for Apache Kafka® to Data Streams using Data Transfer
    • Delivering data from Data Streams to Managed Service for YDB using Data Transfer
    • Delivering data from Data Streams to Managed Service for Apache Kafka® using Data Transfer
    • YDB change data capture and delivery to YDS
    • Configuring Kafka Connect to work with a Managed Service for Apache Kafka® cluster
      • Managing data schemas in Managed Service for Apache Kafka®
      • Using Managed Schema Registry with Managed Service for Apache Kafka®
      • Using Managed Schema Registry with Managed Service for Apache Kafka® via the REST API
      • Using Confluent Schema Registry with Managed Service for Apache Kafka®
    • Automating Query tasks with Managed Service for Apache Airflow™
    • Sending requests to the Yandex Cloud API via the Yandex Cloud Python SDK
    • Configuring an SMTP server to send e-mail notifications
    • Adding data to a ClickHouse® DB
    • Migrating data to Managed Service for ClickHouse® using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for ClickHouse® using Data Transfer
    • Asynchronously replicating data from PostgreSQL to ClickHouse®
    • Exchanging data between Managed Service for ClickHouse® and Yandex Data Processing
    • Configuring Managed Service for ClickHouse® for Graphite
    • Fetching data from Managed Service for Apache Kafka® to Managed Service for ClickHouse®
    • Fetching data from Managed Service for Apache Kafka® to ksqlDB
    • Fetching data from RabbitMQ to Managed Service for ClickHouse®
    • Saving a Data Streams data stream in Managed Service for ClickHouse®
    • Asynchronous replication of data from Yandex Metrica to ClickHouse® using Data Transfer
    • Using hybrid storage in Managed Service for ClickHouse®
    • Sharding Managed Service for ClickHouse® tables
    • Data resharding in a Managed Service for ClickHouse® cluster
    • Loading data from Yandex Direct to a data mart enabled by Managed Service for ClickHouse® using Cloud Functions, Object Storage, and Data Transfer
    • Loading data from Object Storage to Managed Service for ClickHouse® using Data Transfer
    • Migrating data with change of storage from Managed Service for OpenSearch to Managed Service for ClickHouse® using Data Transfer
    • Loading data from Managed Service for YDB to Managed Service for ClickHouse® using Data Transfer
    • Migrating databases from Google BigQuery to Managed Service for ClickHouse®
    • Configuring Cloud DNS to access a Managed Service for ClickHouse® cluster from other cloud networks
    • Migrating a Yandex Data Processing HDFS cluster to a different availability zone
    • Importing data from Managed Service for MySQL® to Yandex Data Processing using Sqoop
    • Importing data from Managed Service for PostgreSQL to Yandex Data Processing using Sqoop
    • Mounting Object Storage buckets to the file system of Yandex Data Processing hosts
    • Working with Apache Kafka® topics using Yandex Data Processing
    • Automating operations with Yandex Data Processing using Managed Service for Apache Airflow™
    • Shared use of Yandex Data Processing tables through Metastore
    • Transferring metadata between Yandex Data Processing clusters using Metastore
    • Importing data from Object Storage, processing and exporting to Managed Service for ClickHouse®
    • Migrating to Managed Service for Elasticsearch using snapshots
    • Migrating collections from a third-party MongoDB cluster to Managed Service for MongoDB
    • Migrating data to Managed Service for MongoDB
    • Migrating Managed Service for MongoDB cluster from 4.4 to 6.0
    • Sharding MongoDB collections
    • MongoDB performance analysis and tuning
    • Migrating a database from a third-party MySQL® cluster to a Managed Service for MySQL® cluster
    • Managed Service for MySQL® performance analysis and tuning
    • Syncing data from a third-party MySQL® cluster to Managed Service for MySQL® using Data Transfer
    • Migrating a database from Managed Service for MySQL® to a third-party MySQL® cluster
    • Migrating a database from Managed Service for MySQL® to Object Storage using Data Transfer
    • Migrating data from Object Storage to Managed Service for MySQL® using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Debezium
    • Migrating a database from Managed Service for MySQL® to Managed Service for YDB using Data Transfer
    • MySQL® change data capture and delivery to YDS
    • Migrating data from Managed Service for MySQL® to Managed Service for PostgreSQL using Data Transfer
    • Migrating data from AWS RDS for PostgreSQL to Managed Service for PostgreSQL using Data Transfer
    • Migrating data from Managed Service for MySQL® to Managed Service for Greenplum® using Data Transfer
    • Configuring an index policy in Managed Service for OpenSearch
    • Migrating data from Elasticsearch to Managed Service for OpenSearch
    • Migrating data from a third-party OpenSearch cluster to Managed Service for OpenSearch using Data Transfer
    • Loading data from Managed Service for OpenSearch to Object Storage using Data Transfer
    • Migrating data from Managed Service for OpenSearch to Managed Service for YDB using Data Transfer
    • Copying data from Managed Service for OpenSearch to Managed Service for Greenplum® using Yandex Data Transfer
    • Migrating data from Managed Service for PostgreSQL to Managed Service for OpenSearch using Data Transfer
    • Authenticating a Managed Service for OpenSearch cluster in OpenSearch Dashboards using Keycloak
    • Using the yandex-lemmer plugin in Managed Service for OpenSearch
    • Creating a PostgreSQL cluster for 1C:Enterprise
    • Searching for the Managed Service for PostgreSQL cluster performance issues
    • Managed Service for PostgreSQL performance analysis and tuning
    • Logical replication PostgreSQL
    • Migrating a database from a third-party PostgreSQL cluster to Managed Service for PostgreSQL
    • Migrating a database from Managed Service for PostgreSQL
    • Delivering data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Data Transfer
    • Delivering data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Debezium
    • Delivering data from Managed Service for PostgreSQL to Managed Service for YDB using Data Transfer
    • Migrating a database from Managed Service for PostgreSQL to Object Storage
    • Migrating data from Object Storage to Managed Service for PostgreSQL using Data Transfer
    • PostgreSQL change data capture and delivery to YDS
    • Migrating data from Managed Service for PostgreSQL to Managed Service for MySQL® using Data Transfer
    • Migrating data from Managed Service for PostgreSQL to Managed Service for OpenSearch using Data Transfer
    • Troubleshooting string sorting issues in PostgreSQL after upgrading glibc
    • Migrating a database from Greenplum® to ClickHouse®
    • Migrating a database from Greenplum® to PostgreSQL
    • Exporting Greenplum® data to a cold storage in Object Storage
    • Loading data from Object Storage to Managed Service for Greenplum® using Data Transfer
    • Copying data from Managed Service for OpenSearch to Managed Service for Greenplum® using Yandex Data Transfer
    • Creating an external table from a Object Storage bucket table using a configuration file
    • Migrating a database from a third-party Valkey™ cluster to Yandex Managed Service for Valkey™
    • Using a Yandex Managed Service for Valkey™ cluster as a PHP session storage
    • Loading data from Object Storage to Managed Service for YDB using Data Transfer
    • Loading data from Managed Service for YDB to Object Storage using Data Transfer
    • Processing Audit Trails events
    • Processing Cloud Logging logs
    • Processing CDC Debezium streams
    • Analyzing data with Jupyter
    • Processing files with usage details in Yandex Cloud Billing
    • Entering data into storage systems
    • Smart log processing
    • Transferring data within microservice architectures
    • Migrating data to Object Storage using Data Transfer
    • Migrating data from a third-party Greenplum® or PostgreSQL cluster to Managed Service for Greenplum® using Data Transfer
    • Migrating Managed Service for MongoDB clusters
    • Migrating MySQL® clusters
    • Migrating to a third-party MySQL® cluster
    • Migrating PostgreSQL clusters
    • Creating a schema registry to deliver data in Debezium CDC format from Apache Kafka®

In this article:

  • Required paid resources
  • Getting started
  • Prepare the infrastructure
  • Install utilities
  • Create data format schemas
  • Send messages to a topic
  • Get messages from a topic
  • Delete the resources you created
  1. Building a data platform
  2. Using data format schemas with Managed Service for Apache Kafka®
  3. Using Managed Schema Registry with Managed Service for Apache Kafka® via the REST API

Using Managed Schema Registry with Yandex Managed Service for Apache Kafka® through the REST API

Written by
Yandex Cloud
Updated at April 25, 2025
  • Required paid resources
  • Getting started
    • Prepare the infrastructure
    • Install utilities
  • Create data format schemas
  • Send messages to a topic
  • Get messages from a topic
  • Delete the resources you created

In Managed Service for Apache Kafka® clusters, you can work with Managed Schema Registry either using Apache Kafka® clients for various programming languages or the REST API.

Managed Service for Apache Kafka® also provides the REST API for Apache Kafka®. Among other things, this API allows you to send and receive messages without using third-party producers and consumers. These features will also be demonstrated in this tutorial.

To get to know the REST API for Managed Schema Registry and Apache Kafka®:

  1. Create data format schemas.
  2. Send messages to a topic.
  3. Get messages from a topic.
  4. Delete the resources you created.

Required paid resourcesRequired paid resources

The support cost includes:

  • Managed Service for Apache Kafka® cluster fee: Using computing resources allocated to hosts (including ZooKeeper hosts) and disk space (see Apache Kafka® pricing).
  • Fee for using public IP addresses (see Virtual Private Cloud pricing).

Getting startedGetting started

Prepare the infrastructurePrepare the infrastructure

Manually
  1. Create a Managed Service for Apache Kafka® cluster with any suitable configuration.

    When creating a cluster, enable the following options:

    • Schema registry.

      The cluster will deploy a Managed Schema Registry schema registry, and the REST API for Managed Schema Registry will become available.

    • Kafka Rest API.

      The REST API for Apache Kafka® will become available in the cluster.

    • Public access.

      Broker hosts will become available from the internet.

  2. Create a topic named messages for exchanging messages between the producer and the consumer.

  3. Create a user named user1 and grant them permissions for the messages topic:

    • ACCESS_ROLE_CONSUMER
    • ACCESS_ROLE_PRODUCER

    This user will be able to send and receive messages within the topic, as well as perform any operations on subjects in Managed Schema Registry that are associated with the topic.

  4. Complete all pre-configuration steps to connect to the cluster.

Install utilitiesInstall utilities

  1. Install cURL:

    sudo apt install curl -y
    

    It will be used to make requests to the API.

    For convenience, this tutorial will use the --user cURL option when making requests to the API. If this option is used, cURL will automatically add to the request the Authorization HTTP header with the value required for authorization.

    Tip

    You can build the Authorization header yourself, e.g., if not using cURL.

  2. Install the jq utility:

    sudo apt install jq -y
    

    You can use it to convert schema descriptions to the required format.

    When using the REST API for Managed Schema Registry, you need to provide schema descriptions as an escaped character string, e.g.:

    "schema": "{\"type\": \"record\", \"name\": \"Obj\", \"fields\":[...]}"
    

    For convenience, in this tutorial, schemas are presented as JSON documents with indentations and line breaks; and when making requests to the API, schemas are converted to the required format using jq.

    Tip

    After you request the REST API using cURL, you get the server response as a single JSON string.

    You can additionally process the output of the commands featured in this tutorial with the help of jq to make the server's response more readable.

Create data format schemasCreate data format schemas

Note

This tutorial uses the Avro type schemas.

You can use other types of schemas supported in Managed Schema Registry.

Let's assume an Apache Kafka® message in the messages topic must consist of a key and a value in the following format:

Key

Value

{
  "id": <int>,
  "sid": "<string>"
}
{
  "name": "<string>",
  "city": "<string>",
  "age": <int>
}

Create the relevant data format schemas:

  1. Create a file named schema-key.json containing the data format schema for the Apache Kafka® message key.

    schema-key.json
    {
      "type": "record",
      "name": "my_key",
      "fields": [
        {
          "name": "id",
          "type": "int"
        },
        {
          "name": "sid",
          "type": "string"
        }
      ]
    }
    
  2. Create a data format schema for the Apache Kafka® message key.

    The subject name for the schema must consist of the name of the topic the schema will be used in (messages) and the -key suffix.

    Use the POST /subjects/(subject)/versions REST API method for Managed Schema Registry and send the following request:

    jq \
        -n --slurpfile data schema-key.json \
        '{
           "schemaType": "AVRO",
           "schema": "\($data)"
        }' \
    | curl \
          --request POST \
          --url 'https://<broker_host_FQDN>:443/subjects/messages-key/versions' \
          --user user1:<user_password> \
          --header 'Content-Type: application/vnd.schemaregistry.v1+json' \
          --data "@-"
    

    The response to the request will return the new schema ID, e.g., {"id":1}.

  3. Create a schema-value.json file containing the data format schema for the Apache Kafka® message value.

    schema-value.json
    {
      "type": "record",
      "name": "my_value",
      "fields": [
        {
          "name": "name",
          "type": "string"
        },
        {
          "name": "city",
          "type": "string"
        },
        {
          "name": "age",
          "type": "int"
        }
      ]
    }
    
  4. Create a data format schema for the Apache Kafka® message value.

    The subject name for the schema must consist of the name of the topic the schema will be used in (messages) and the -value suffix.

    Use the POST /subjects/(subject)/versions REST API method for Managed Schema Registry and send the following request:

    jq \
        -n --slurpfile data schema-value.json \
        '{
           "schemaType": "AVRO",
           "schema": "\($data)"
        }' \
    | curl \
          --request POST \
          --url 'https://<broker_host_FQDN>:443/subjects/messages-value/versions' \
          --user user1:<user_password> \
          --header 'Content-Type: application/vnd.schemaregistry.v1+json' \
          --data "@-"
    

    The response to the request will return the new schema ID, e.g., {"id":2}.

Send messages to a topicSend messages to a topic

  1. Get the data format schema IDs for the key and the value.

    Use the GET /schemas REST API method for Managed Schema Registry and send the following request:

    curl \
        --request GET \
        --url 'https://<broker_host_FQDN>:443/schemas' \
        --user user1:<user_password> \
        --header 'Accept: application/vnd.schemaregistry.v1+json'
    

    The response to the request contains data format schema IDs (id). These IDs will be used later.

    Sample response

    For brevity, the data format schema named schema in the form of JSON strings is not provided.

    [
      {
        "id": 1,
        "schema": "<data_format_schema>",
        "schemaType": "AVRO",
        "subject": "messages-key",
        "version": 1
      },
      {
        "id": 2,
        "schema": "<data_format_schema>",
        "schemaType": "AVRO",
        "subject": "messages-value",
        "version": 1
      }
    ]
    
  2. Create a file named message-list.json containing two messages. For each message, the key and the value are specified according to the data format schemas created earlier.

    message-list.json
    [
      {
        "key": {
          "id": 1111,
          "sid": "AAAAA-BBBBB-CCCCC"
        },
        "value": {
          "name": "Anna",
          "city": "Moscow",
          "age": 44
        }
      },
      {
        "key": {
          "id": 2222,
          "sid": "DDDDD-EEEEE-FFFFF"
        },
        "value": {
          "name": "Alex",
          "city": "London",
          "age": 32
        }
      }
    ]
    
  3. Send messages to the messages topic.

    Use the POST /topics/(topic) REST API method for Apache Kafka® and send the following request:

    jq \
        -n --slurpfile data message-list.json \
        '{
          "key_schema_id": <messages-key_schema_ID>,
          "value_schema_id": <messages-value_schema_ID>,
          "records": $data.[]
        }' \
    | curl \
          --request POST \
          --url 'https://<broker_host_FQDN>:443/topics/messages' \
          --user user1:<user_password> \
          --header 'Content-Type: application/vnd.kafka.avro.v2+json' \
          --header 'Accept: application/vnd.kafka.v2+json' \
          --data "@-"
    

    The schema ID values ​​were obtained earlier by requesting the GET /schemas endpoint.

    Example of response to query
    {
      "key_schema_id": 1,
      "offsets": [
        {
          "offset": 0,
          "partition": 0
        },
        {
          "offset": 0,
          "partition": 1
        }
      ],
      "value_schema_id": 2
    }
    

Get messages from a topicGet messages from a topic

  1. Create a consumer named my-consumer in the consumer group named my-group.

    Use the POST /consumers/(group) REST API method for Apache Kafka® and send the following request:

    curl \
        --request POST \
        --url 'https://<broker_host_FQDN>:443/consumers/my-group' \
        --user user1:<user_password> \
        --header 'Content-Type: application/vnd.kafka.v2+json' \
        --header 'Accept: application/vnd.kafka.v2+json' \
        --data '{
                  "name": "my-consumer",
                  "format": "avro",
                  "auto.offset.reset": "earliest"
                }'
    
    Example of response to query
    {
      "base_uri": "https://<broker_host_FQDN>:443/consumers/my-group/instances/my-consumer",
      "instance_id": "my-consumer"
    }
    
  2. Subscribe to the messages topic for the consumer named my-consumer from the consumer group named my-group.

    Use the POST /consumers/(group)/instances/(instance)/subscription REST API method for Apache Kafka® and send the following request:

    curl \
        --request POST \
        --url 'https://<broker_host_FQDN>:443/consumers/my-group/instances/my-consumer/subscription' \
        --user user1:<user_password> \
        --header 'Content-Type: application/vnd.kafka.v2+json' \
        --header 'Accept: application/vnd.kafka.v2+json' \
        --data '{"topics": ["messages"]}'
    

    The API server does not return a response to this request, only an HTTP status.

  3. Get all messages from the messages topic for the consumer named my-consumer from the consumer group named my-group.

    Use the GET /consumers/(group)/instances/(instance)/records REST API method for Apache Kafka® and send the following request:

    curl \
        --request GET \
        --url 'https://<broker_host_FQDN>:443/consumers/my-group/instances/my-consumer/records' \
        --user user1:<user_password> \
        --header 'Accept: application/vnd.kafka.avro.v2+json'
    

    If the response to the request contains messages that were sent earlier, this means the producer and consumer are successfully interpreting the messages in accordance with the specified data format schemas.

    Example of response to query
    [
      {
        "key": {
          "id": 2222,
          "sid": "DDDDD-EEEEE-FFFFF"
        },
        "offset": 0,
        "partition": 1,
        "timestamp": 1726031054186,
        "topic": "messages",
        "value": {
          "age": 32,
          "city": "London",
          "name": "Alex"
        }
      },
      {
        "key": {
          "id": 1111,
          "sid": "AAAAA-BBBBB-CCCCC"
        },
        "offset": 0,
        "partition": 0,
        "timestamp": 1726031054186,
        "topic": "messages",
        "value": {
          "age": 44,
          "city": "Moscow",
          "name": "Anna"
        }
      }
    ]
    

Delete the resources you createdDelete the resources you created

Delete the resources you no longer need to avoid paying for them:

  • Delete the Managed Service for Apache Kafka® cluster.
  • If you reserved public static IP addresses, release and delete them.

Was the article helpful?

Previous
Using Managed Schema Registry with Managed Service for Apache Kafka®
Next
Using Confluent Schema Registry with Managed Service for Apache Kafka®
© 2025 Direct Cursus Technology L.L.C.