Introduction
IBM Event Streams also provides the following APIs:
IBM Event Streams for IBM Cloud® is a high-throughput message bus built with Apache Kafka. It is optimized for event ingestion into IBM Cloud and event stream distribution between your services and applications.
Apache Kafka can handle any data, but it does not validate the information in the messages. However, efficient handling of data often requires that the data includes specific information in a certain format. By using schemas, you can define the structure of the data in a message, ensuring that both producers and consumers use the correct structure.
The Event Streams Schema Registry REST API allows you to manage schema associated with an instance of Event Streams. More specifically, you can complete the following tasks:
- Create, read, and delete schemas
- Create, read, and delete individual versions of a schema
- Read and update the global compatibility rule for the registry
- Create, read, update, and delete compatibility rules that apply to individual schemas
The Schema Registry is enabled by default for the Event Streams Enterprise plan. It is not automatically enabled for the Satellite plan. For information about how to enable it for the Satellite plan, see Enable the schema registry API.
The Schema Registry is not available for other Event Streams plans.
For more information, see Event Streams Schema Registry.
You can download the OpenAPI specification compliant descriptors for this REST interface. Alternatively, click the three vertical dots next to the IBM Event Streams Schema Registry API title in the top left corner of this app, then click the Download OpenAPI definition link that appears.
Authentication
You can authenticate to the Schema Registry using an API key. This is supplied as the password portion of a HTTP basic authentication header. Set the username portion of this header to the word “token”
.
You can also grant a bearer token for a system ID or user and supply this as a credential. To do this, specify an HTTP header in the format: "Authorization: Bearer $TOKEN"
(where $TOKEN
is the bearer token). For example:
curl –H "Authorization: Bearer $TOKEN" ...
Error handling
This API uses standard HTTP response codes to indicate whether a method completed successfully. A 200
response indicates success. A 400
type response indicates a failure, and a 500
type response indicates an internal system error.
HTTP status code | Description | Recovery |
---|---|---|
200 |
OK | The request was successful. The response body is a JSON array containing the information you requested. |
204 |
OK | The schema version was successfully deleted. |
400 |
Bad request | The request was not valid. Consult the error information returned in the response body for details. |
403 |
Forbidden | The client is not authorized to perform this request. |
404 |
Not found | Either the registry does not contain a schema with the specified schema ID, or the schema identified by the schema ID does not contain a version corresponding to the specified version number, or the schema is not configured with the specified type of rule. |
409 |
Conflict | This code indicates one of the following conflicts:
|
Kafka SDKs
Event Streams is based on the open-source Apache Kafka, therefore all SDKs are provided for by the open-source community, covering the core runtimes listed. For the most up-to-date information about these libraries refer to the project homepages. For example:
You can find details of what is supported by Event Streams at: Support summary for all recommended clients.
For information about how to install and use the SDKs, see Using the Kafka Java client.
Event Streams samples
For information about running a sample Java application that demonstrates how to connect to Event Streams and how to send and receive messages using the Kafka Java API, see:
- IBM Event Streams Kafka Java console sample application (uses String serializer)
- IBM Event Streams Kafka Java console schema sample application (uses the Avro serializer)
Methods
List schema IDs
Returns an array containing the schema IDs of all of the schemas that are stored in the registry.
GET /artifacts
Response
Status Code
The list schema IDs request was successful. The response body is a JSON array containing a list of schema IDs.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Create a new schema
Create a new schema and populate it with an initial schema version containing the AVRO document in the request body.
POST /artifacts
Request
Custom Headers
The name to assign to the new schema. This must be unique. If this value is not specified then a UUID is used.
The AVRO schema to use as the first version of this new schema.
{
"type": "record",
"name": "book",
"fields": [
{
"name": "title",
"type": "string"
},
{
"name": "author",
"type": "string"
}
]
}
The AVRO schema
Response
Information about a schema version.
Creation timestamp of the schema in UNIX epoc format.
Globally unique ID assigned to the initial version of the schema.
The ID of the schema. This is either taken from the
X-Registry-ArtifactId
header when the request is made to create the schema or is an automatically assigned UUID value.Last modification timestamp of the schema in UNIX epoc format.
Type of the schema. Always the string
AVRO
.Version number assigned to this version of the schema.
Status Code
The schema was successfully created. Information about the newly created schema is included in the response body.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
A schema with the specified schema ID already exists.
{ "id": "my-schemada", "type": "AVRO", "version": 1, "createdOn": 1579267788258, "modifiedOn": 1579267788258, "globalId": 75 }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Get the latest version of a schema
Retrieves the lastest version of the specified schema.
GET /artifacts/{id}
Response
The AVRO schema
Status Code
The latest version of the schema was successfully retrieved. This schema version is included in the response body.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
The registry does not contain a schema with the specified schema ID.
{ "type": "record", "name": "book", "fields": [ { "name": "title", "type": "string" }, { "name": "author", "type": "string" } ] }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Delete a schema
Deletes a schema and all of its versions from the schema registry.
DELETE /artifacts/{id}
Response
Status Code
The schema was successfully deleted from the registry.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
The registry does not contain a schema with the specified schema ID.
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Request
Path Parameters
The ID of the schema to update.
The AVRO schema to update
{
"type": "record",
"name": "book",
"fields": [
{
"name": "title",
"type": "string"
},
{
"name": "author",
"type": "string"
}
]
}
The AVRO schema
Response
Information about a schema version.
Creation timestamp of the schema in UNIX epoc format.
Globally unique ID assigned to the initial version of the schema.
The ID of the schema. This is either taken from the
X-Registry-ArtifactId
header when the request is made to create the schema or is an automatically assigned UUID value.Last modification timestamp of the schema in UNIX epoc format.
Type of the schema. Always the string
AVRO
.Version number assigned to this version of the schema.
Status Code
The schema was successfully updated
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
The registry does not contain a schema with the specified schema ID.
{ "id": "my-schemada", "type": "AVRO", "version": 1, "createdOn": 1579267788258, "modifiedOn": 1579267788258, "globalId": 75 }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
List the versions of a schema
Returns an array containing the version numbers of all of the versions of the specified schema.
GET /artifacts/{id}/versions
Response
Schema version number
Status Code
The request to list the versions of a schema was successful. The body of the response contains an array of schema version numbers.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
The registry does not contain a schema with the specified schema ID.
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Create a new schema version
Creates a new version of a schema using the AVRO schema supplied in the request body.
POST /artifacts/{id}/versions
Request
Path Parameters
A schema ID. This identifies the schema for which a new version will be created.
The AVRO schema to use for the new schema version.
{
"type": "record",
"name": "book",
"fields": [
{
"name": "title",
"type": "string"
},
{
"name": "author",
"type": "string"
}
]
}
The AVRO schema
Response
Information about a schema version.
Creation timestamp of the schema in UNIX epoc format.
Globally unique ID assigned to the initial version of the schema.
The ID of the schema. This is either taken from the
X-Registry-ArtifactId
header when the request is made to create the schema or is an automatically assigned UUID value.Last modification timestamp of the schema in UNIX epoc format.
Type of the schema. Always the string
AVRO
.Version number assigned to this version of the schema.
Status Code
The new schema version was successfully created. Information about the newly created schema is returned in the response body.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
The registry does not contain a schema with the specified schema ID.
Either the schema already has the maximum number of permitted versions, or creating a new schema version would fail the required compatibility checks based on existing versions of the schema. Consult the error information returned in the response body for details.
{ "id": "my-schemada", "type": "AVRO", "version": 1, "createdOn": 1579267788258, "modifiedOn": 1579267788258, "globalId": 75 }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Get a version of the schema
Retrieve a particular version of the schema.
GET /artifacts/{id}/versions/{version}
Request
Path Parameters
The schema ID identifying which schema to return a version from.
The version number that identifies the particular schema version to return.
Response
The AVRO schema
Status Code
The AVRO schema corresponding to the requested schema version.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
Either the registry does not contain a schema with the specified schema ID, or the schema identified by the schema ID does not contain a version corresponding to the specified version number.
{ "type": "record", "name": "book", "fields": [ { "name": "title", "type": "string" }, { "name": "author", "type": "string" } ] }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Delete a version of the schema
Delete a version of the schema. If this was the only version of the schema then the whole schema will be deleted.
DELETE /artifacts/{id}/versions/{version}
Request
Path Parameters
A schema ID that identifies the schema to delete a version from.
The schema version number to delete.
Response
Status Code
The schema version was successfully deleted.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
Either the registry does not contain a schema with the specified schema ID, or the schema identified by the schema ID does not contain a version corresponding to the specified version number.
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Create a schema rule
Create a new rule that controls compatibility checks for a particular schema. Schema rules override the registries global compatibility rule setting.
POST /artifacts/{id}/rules
Request
Path Parameters
The ID of the schema that the rule is to be associated with.
A JSON object representing the schema rule to create.
{
"type": "COMPATIBILITY",
"config": "BACKWARD"
}
The type of the rule. Currently only one type is supported (
COMPATIBILITY
).Allowable values: [
COMPATIBILITY
]The configuration value for the rule. Which values are valid depends on the value of this object's
type
property.Allowable values: [
BACKWARD
,BACKWARD_TRANSITIVE
,FORWARD
,FORWARD_TRANSITIVE
,FULL
,FULL_TRANSITIVE
,NONE
]
Response
Rules define constraints on whether the schema registry will accept a new version of a schema.
The type of the rule. Currently only one type is supported (
COMPATIBILITY
).Possible values: [
COMPATIBILITY
]The configuration value for the rule. Which values are valid depends on the value of this object's
type
property.Possible values: [
BACKWARD
,BACKWARD_TRANSITIVE
,FORWARD
,FORWARD_TRANSITIVE
,FULL
,FULL_TRANSITIVE
,NONE
]
Status Code
The schema rule was created successfully. The value of the schema rule is returned in the body of the response.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
The registry does not contain a schema with the specified schema ID.
A schema rule with the same type already exists for this schema. Use the REST request that specifies the
PUT
verb to a path of/artifacts/{id}/rules/{rule}
to update the rule.
{ "type": "COMPATIBILITY", "config": "BACKWARD" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Get a schema rule configuration
Retrieves the current configuration for a schema rule. If a schema rule exists then it overrides the corresponding global rule that would otherwise be applied.
GET /artifacts/{id}/rules/{rule}
Request
Path Parameters
The ID of the schema to retrieve the rule for.
The type of rule to retrieve. Currently only the value that can be specified is
COMPATIBILITY
.Allowable values: [
COMPATIBILITY
]
Response
Rules define constraints on whether the schema registry will accept a new version of a schema.
The type of the rule. Currently only one type is supported (
COMPATIBILITY
).Possible values: [
COMPATIBILITY
]The configuration value for the rule. Which values are valid depends on the value of this object's
type
property.Possible values: [
BACKWARD
,BACKWARD_TRANSITIVE
,FORWARD
,FORWARD_TRANSITIVE
,FULL
,FULL_TRANSITIVE
,NONE
]
Status Code
The schema rule was successfully retrieved. The value of the schema rule is returned in the body of the response.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
Either the registry does not contain a schema with the specified schema ID, or the schema is not configured with the specified type of rule.
{ "type": "COMPATIBILITY", "config": "BACKWARD" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Update the configuration of a schema rule.
Updates the configuration of an existing schema rule. The updated rule will be applied to the specified schema, overriding the value set for the corresponding global rule.
PUT /artifacts/{id}/rules/{rule}
Request
Path Parameters
The ID of the schema for which to update the rule configuration.
The type of rule to update. Currently only the value that can be specified is
COMPATIBILITY
.Allowable values: [
COMPATIBILITY
]
A JSON object representing the updated values to use for the schema rule.
{
"type": "COMPATIBILITY",
"config": "BACKWARD"
}
The type of the rule. Currently only one type is supported (
COMPATIBILITY
).Allowable values: [
COMPATIBILITY
]The configuration value for the rule. Which values are valid depends on the value of this object's
type
property.Allowable values: [
BACKWARD
,BACKWARD_TRANSITIVE
,FORWARD
,FORWARD_TRANSITIVE
,FULL
,FULL_TRANSITIVE
,NONE
]
Response
Rules define constraints on whether the schema registry will accept a new version of a schema.
The type of the rule. Currently only one type is supported (
COMPATIBILITY
).Possible values: [
COMPATIBILITY
]The configuration value for the rule. Which values are valid depends on the value of this object's
type
property.Possible values: [
BACKWARD
,BACKWARD_TRANSITIVE
,FORWARD
,FORWARD_TRANSITIVE
,FULL
,FULL_TRANSITIVE
,NONE
]
Status Code
The schema rule was successfully retrieved. The value of the schema rule is returned in the body of the response.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
This schema does not have a rule of the specified type. Use the REST request that specifies the
POST
verb to a path of/artifacts/{id}/rules
to create a schema rule.
{ "type": "COMPATIBILITY", "config": "BACKWARD" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Delete a schema rule
Delete a rule that controls compatibility checks for a particular schema. After this operation completes the schema will be subject to compatibility checking defined by the global compatibility rule setting for the registry.
DELETE /artifacts/{id}/rules/{rule}
Request
Path Parameters
The ID of the schema that the rule is to be deleted from.
The type of rule to delete. Currently only the value that can be specified is
COMPATIBILITY
.Allowable values: [
COMPATIBILITY
]
Response
Status Code
The schema rule was successfully deleted.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
Either the registry does not contain a schema with the specified schema ID, or the schema is not configured with the specified type of rule.
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Retrieve the configuration for a global rule.
Retrieves the configuration for the specified global rule. The value of the global rule is used as the default when a schema does not have a corresponding schema compatibility rule defined.
GET /rules/{rule}
Request
Path Parameters
The type of the global rule to retrieve. Currently only
COMPATIBILITY
is supported.Allowable values: [
COMPATIBILITY
]
Response
Rules define constraints on whether the schema registry will accept a new version of a schema.
The type of the rule. Currently only one type is supported (
COMPATIBILITY
).Possible values: [
COMPATIBILITY
]The configuration value for the rule. Which values are valid depends on the value of this object's
type
property.Possible values: [
BACKWARD
,BACKWARD_TRANSITIVE
,FORWARD
,FORWARD_TRANSITIVE
,FULL
,FULL_TRANSITIVE
,NONE
]
Status Code
The global rule was successfully retrieved. The value of the global rule is returned in the body of the response.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
{ "type": "COMPATIBILITY", "config": "BACKWARD" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
Update the configuration for a global rule
Update the configuration for the specified global rule. The value of the global rule is used as the default when a schema does not have a corresponding schema compatibility rule defined.
PUT /rules/{rule}
Request
Path Parameters
The type of the global rule to update. Currently only
COMPATIBILITY
is supported.Allowable values: [
COMPATIBILITY
]
A JSON object representing the schema rule to update.
{
"type": "COMPATIBILITY",
"config": "BACKWARD"
}
The type of the rule. Currently only one type is supported (
COMPATIBILITY
).Allowable values: [
COMPATIBILITY
]The configuration value for the rule. Which values are valid depends on the value of this object's
type
property.Allowable values: [
BACKWARD
,BACKWARD_TRANSITIVE
,FORWARD
,FORWARD_TRANSITIVE
,FULL
,FULL_TRANSITIVE
,NONE
]
Response
Rules define constraints on whether the schema registry will accept a new version of a schema.
The type of the rule. Currently only one type is supported (
COMPATIBILITY
).Possible values: [
COMPATIBILITY
]The configuration value for the rule. Which values are valid depends on the value of this object's
type
property.Possible values: [
BACKWARD
,BACKWARD_TRANSITIVE
,FORWARD
,FORWARD_TRANSITIVE
,FULL
,FULL_TRANSITIVE
,NONE
]
Status Code
The global rule was successfully updated. The new value for the global rule is returned in the body of the response.
The request was not valid. Consult the error information returned in the response body for details.
The client is not authorized to perform this request.
{ "type": "COMPATIBILITY", "config": "BACKWARD" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }
{ "error_code": 404, "message": "No schema with ID 1234 was found in the registry" }