Managing Apicurio Registry content using the REST API
This chapter describes the Registry REST API and shows how to use it manage artifacts stored in the registry:
Registry REST API overview
Using the Registry REST API, client applications can manage the artifacts in Apicurio Registry. This API provides create, read, update, and delete operations for:
- Artifacts
-
Manage the schema and API design artifacts stored in the registry. This also includes browse or search for artifacts, for example, by name, ID, description, or label. You can also manage the lifecycle state of an artifact: enabled, disabled, or deprecated.
- Artifact versions
-
Manage the versions that are created when artifact content is updated. This also includes browse or search for versions, for example, by name, ID, description, or label. You can also manage the lifecycle state of a version: enabled, disabled, or deprecated.
- Artifact metadata
-
Manage details about artifacts such as when an artifact was created or modified, its current state, and so on. Users can edit some metadata, and some is read-only. For example, editable metadata includes artifact name, description, or label, but when the artifact was created and modified are read-only.
- Global rules
-
Configure rules to govern the content evolution of all artifacts to prevent invalid or incompatible content from being added to the registry. Global rules are applied only if an artifact does not have its own specific artifact rules configured.
- Artifact rules
-
Configure rules to govern the content evolution of a specific artifact to prevent invalid or incompatible content from being added to the registry. Artifact rules override any global rules configured.
The Registry REST API is compatible with the Confluent schema registry REST API, which includes support for Apache Avro, Google Protocol buffers, and JSON Schema artifact types. Applications using Confluent client libraries can use Apicurio Registry as a drop-in replacement instead.
-
For detailed information, see the Apicurio Registry REST API documentation.
-
The Registry REST API documentation is also available from the main endpoint of your Apicurio Registry deployment, for example, on
http://MY-REGISTRY-URL/api
.
Managing artifacts using Registry REST API commands
Client applications can use Registry REST API commands to manage artifacts in Apicurio Registry, for example, in a CI/CD pipeline deployed in production. The Registry REST API provides create, read, update, and delete operations for artifacts, versions, metadata, and rules stored in the registry. For detailed information, see the Apicurio Registry REST API documentation.
This section shows a simple curl-based example of using the Registry REST API to add and retrieve an Apache Avro schema artifact in the registry.
When adding artifacts in Apicurio Registry using the REST API, if you do not specify a unique artifact ID, Apicurio Registry generates one automatically as a UUID. |
-
Apicurio Registry must be installed and running in your environment.
-
Add an artifact in the registry using the
/artifacts
operation. The following examplecurl
command adds a simple artifact for a share price application:$ curl -X POST -H "Content-type: application/json; artifactType=AVRO" -H "X-Registry-ArtifactId: share-price" --data '{"type":"record","name":"price","namespace":"com.example","fields":[{"name":"symbol","type":"string"},{"name":"price","type":"string"}]}' http://MY-REGISTRY-HOST/api/artifacts
This example shows adding an Avro schema artifact with an artifact ID of
share-price
.MY-REGISTRY-HOST
is the host name on which Apicurio Registry is deployed. For example:http://localhost:8080/api/artifacts
. -
Verify that the response includes the expected JSON body to confirm that the artifact was added. For example:
{"createdOn":1578310374517,"modifiedOn":1578310374517,"id":"share-price","version":1,"type":"AVRO","globalId":8}
-
Retrieve the artifact from the registry using its artifact ID. For example, in this case the specified ID is
share-price
:$ curl http://MY-REGISTRY-URL/api/artifacts/share-price '{"type":"record","name":"price","namespace":"com.example","fields":[{"name":"symbol","type":"string"},{"name":"price","type":"string"}]}
-
For more REST API sample requests, see the Apicurio Registry REST API documentation.