Schema Registry APIs and CURL Commands
2 min readMay 16, 2023
When we start the schema registry, by default it provides us with the open REST APIs using which we can work on the data, schema definition, version manipulation operations etc.
Below are few important and required schema registry manipulation curl commands, but not all of them are given in this document. For more you can refer the schema registry documentation given here.
curl -X GET http://localhost:9095/schemas/types | jq .
Output:
#[
# "JSON",
# "PROTOBUF",
# "AVRO"
#]
Lists all of the schema type
curl http://localhost:9095/subjects | jq .
Output:
#[
# "Kafka-key", --> schema Id 2
# "kafka-value", --> schema Id 1
#]
Lists all of the avaiable subjects in the local cache
curl http://localhost:9095/schemas/ids/5 | jq .
Output:
#{
# "schema": "{\"type\":\"record\",\"name\":\"USER\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"age\",\"type\":\"int\"},{\"name\":\"timestamp\",\"type\":\"long\"}]}"
#}
This command helps you to find particular schema based on the given id
curl -v -X GET "http://localhost:9095/subjects/<TOPIC_NAME>-value/versions/<VERSION>" | jq .
Output:
You will get the particular schema belonging to the subject based on the version we specified.
curl -v -X GET "http://localhost:9095/subjects/<TOPIC_NAME>-value/versions/latest" | jq .
Output:
You will get the latest version of the schema present under the mentioned subject
curl -v -X DELETE "http://localhost:9095/subjects/<TOPIC_NAME>-value/versions/<VERSION>" | jq .
Output:
You will be able to delete the schema definition based on the particular version from the mentioned subject
These are few of the important commands which we can use to proceed with any of the basic schema registry and AVRO producer and consumers.