Quickstart examples#

Schema Hub#

To register the first version of a schema under the subject “test” using Avro schema:

$ curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
  --data '{"schema": "{\"type\": \"record\", \"name\": \"Obj\", \"fields\":[{\"name\": \"age\", \"type\": \"int\"}]}"}' \

To register a version of a schema using JSON Schema, one needs to use schemaType property:

$ curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
  --data '{"schemaType": "JSON", "schema": "{\"type\": \"object\",\"properties\":{\"age\":{\"type\": \"number\"}},\"additionalProperties\":true}"}' \

To list all subjects (including the one created just above):


To list all the versions of a given schema (including the one just created above):

$ curl -X GET $KARAPACE_REGISTRY_URI/subjects/test-key/versions

To fetch back the schema whose global id is 1 (i.e. the one registered above):

$ curl -X GET $KARAPACE_REGISTRY_URI/schemas/ids/1

To get the specific version 1 of the schema just registered run:

$ curl -X GET $KARAPACE_REGISTRY_URI/subjects/test-key/versions/1

To get the latest version of the schema under subject test-key run:

$ curl -X GET $KARAPACE_REGISTRY_URI/subjects/test-key/versions/latest

In order to delete version 10 of the schema registered under subject “test-key” (if it exists):

$ curl -X DELETE $KARAPACE_REGISTRY_URI/subjects/test-key/versions/10

To Delete all versions of the schema registered under subject “test-key”:

$ curl -X DELETE $KARAPACE_REGISTRY_URI/subjects/test-key

Test the compatibility of a schema with the latest schema under subject “test-key”:

$ curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \
  --data '{"schema": "{\"type\": \"int\"}"}' \

Get current global backwards compatibility setting value:


Change compatibility requirements for all subjects where it’s not specifically defined otherwise:

$ curl -X PUT -H "Content-Type: application/vnd.schemaregistry.v1+json" \
  --data '{"compatibility": "NONE"}' $KARAPACE_REGISTRY_URI/config

Change compatibility requirement to FULL for the test-key subject:

$ curl -X PUT -H "Content-Type: application/vnd.schemaregistry.v1+json" \
  --data '{"compatibility": "FULL"}' $KARAPACE_REGISTRY_URI/config/test-key


List topics:

$ curl "$KARAPACE_REST_URI/topics"

Get info for one particular topic:

$ curl "$KARAPACE_REST_URI/topics/my_topic"

Produce a message backed up by schema registry:

$ curl -H "Content-Type: application/vnd.kafka.avro.v2+json" -X POST -d \
  '{"value_schema": "{\"namespace\": \"example.avro\", \"type\": \"record\", \"name\": \"simple\", \"fields\": \
  [{\"name\": \"name\", \"type\": \"string\"}]}", "records": [{"value": {"name": "name0"}}]}' $KARAPACE_REST_URI/topics/my_topic

Create a consumer:

$ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" -H "Accept: application/vnd.kafka.v2+json" \
  --data '{"name": "my_consumer", "format": "avro", "auto.offset.reset": "earliest"}' \

Subscribe to the topic we previously published to:

$ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data '{"topics":["my_topic"]}' \

Consume previously published message:

$ curl -X GET -H "Accept: application/vnd.kafka.avro.v2+json" \

Commit offsets for a particular topic partition:

$ curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data '{}' \

Delete consumer:

$ curl -X DELETE -H "Accept: application/vnd.kafka.v2+json" \