IBM Cloud API Docs

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.

Endpoint URLs

The Schema Registry API endpoint is the kafka_http_url property in the service key for the service instance. To retrieve this property, use the following command:

ibmcloud resource service-key "${service_instance_key_name}" --output json | jq -r '.[]|.credentials.kafka_http_url'

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:

  • A schema with the specified schema ID already exists
  • A schema rule with the same type already exists for this schema.
  • The schema does not have a rule of the specified type.
  • 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.

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:

Methods

List schema IDs

Returns an array containing the schema IDs of all of the schemas that are stored in the registry.

GET /artifacts

Request

No Request Parameters

This method does not accept any request parameters.

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.

Example responses
  • {
      "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.

Examples:
{
  "type": "record",
  "name": "book",
  "fields": [
    {
      "name": "title",
      "type": "string"
    },
    {
      "name": "author",
      "type": "string"
    }
  ]
}

Response

Information about a schema version.

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.

Example responses
  • {
      "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}

Request

Path Parameters

  • The ID of a schema.

Response

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.

Example responses
  • {
      "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}

Request

Path Parameters

  • The ID of the schema to delete.

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.

Example responses
  • {
      "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 a schema

Updates a schema

PUT /artifacts/{id}

Request

Path Parameters

  • The ID of the schema to update.

The AVRO schema to update

Examples:
{
  "type": "record",
  "name": "book",
  "fields": [
    {
      "name": "title",
      "type": "string"
    },
    {
      "name": "author",
      "type": "string"
    }
  ]
}

Response

Information about a schema version.

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.

Example responses
  • {
      "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

Request

Path Parameters

  • The schema ID for which the list of versions will be returned.

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.

Example responses
  • {
      "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.

Examples:
{
  "type": "record",
  "name": "book",
  "fields": [
    {
      "name": "title",
      "type": "string"
    },
    {
      "name": "author",
      "type": "string"
    }
  ]
}

Response

Information about a schema version.

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.

Example responses
  • {
      "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

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.

Example responses
  • {
      "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.

Example responses
  • {
      "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.

Examples:
{
  "type": "COMPATIBILITY",
  "config": "BACKWARD"
}

Response

Rules define constraints on whether the schema registry will accept a new version of a schema.

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.

Example responses
  • {
      "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.

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.

Example responses
  • {
      "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.

Examples:
{
  "type": "COMPATIBILITY",
  "config": "BACKWARD"
}

Response

Rules define constraints on whether the schema registry will accept a new version of a schema.

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.

Example responses
  • {
      "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.

Example responses
  • {
      "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.

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.

Example responses
  • {
      "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.

Examples:
{
  "type": "COMPATIBILITY",
  "config": "BACKWARD"
}

Response

Rules define constraints on whether the schema registry will accept a new version of a schema.

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.

Example responses
  • {
      "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"
    }
id=curlclassName=tab-item-selected