https://github.com/axlj45/schema-registry-client
Schema registry client for Confluent's Avro Schema Registry
https://github.com/axlj45/schema-registry-client
avro node node-js node-rdkafka schema-registry-client
Last synced: 6 months ago
JSON representation
Schema registry client for Confluent's Avro Schema Registry
- Host: GitHub
- URL: https://github.com/axlj45/schema-registry-client
- Owner: axlj45
- License: mit
- Created: 2018-12-10T03:42:16.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2025-10-27T21:34:50.000Z (8 months ago)
- Last Synced: 2025-11-27T10:26:35.247Z (7 months ago)
- Topics: avro, node, node-js, node-rdkafka, schema-registry-client
- Language: TypeScript
- Homepage:
- Size: 1.17 MB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# schema-registry-client
Schema registry client for Confluent's Avro Schema Registry.
[](https://github.com/axlj45/schema-registry-client/actions/workflows/build.yml)
[](https://codecov.io/gh/axlj45/schema-registry-client)
## Usage
```bash
npm install --save schema-registry-client
```
### Create Schema
```ts
import { SchemaRegistryClient } from './SchemaRegistryClient';
const schemaRegistry = SchemaRegistryClient.create('http://localhost:8081');
interface IData {
first: string;
last: string;
age: number;
}
const schema = {
"name": "SerializationTest",
"namespace": "com.example",
"type": "record",
"fields": [
{ "name": "first", "type": ["null", "string"] },
{ "name": "last", "type": "string" },
{ "name": "age", "type": ["null", "int"] },
]
};
schemaRegistry
.createSchema('subjectName', schema)
.then((schemaInfo)=> { console.log(`Created schema: ${schemaInfo.subject} with id: ${schemaInfo.id}`) })
```
### Serialize JSON
```ts
import { SchemaRegistryClient } from './SchemaRegistryClient';
const schemaRegistry = SchemaRegistryClient.create('http://localhost:8081');
interface IData {
first: string;
last: string;
age: number;
}
const data: IData = {
'age': 60,
'first': 'firstName',
'last': 'lastName',
}
schemaRegistry
.encodeBySubject(data, 'subjectName')
.then(schemaRegistryAvroBuffer => console.log(schemaRegistryAvroBuffer))
```
### Deserialize JSON
```ts
import { SchemaRegistryClient } from './SchemaRegistryClient';
const schemaRegistry = SchemaRegistryClient.create('http://localhost:8081');
interface IData {
first: string;
last: string;
age: number;
}
const buffer = /* consume message buffer from kafka */
schemaRegistry
.decode(buffer)
.then(data => {
console.log(`First Name: ${data.first}
Last Name: ${data.last}
Age: ${data.age}`)
})
```
## Future Development
* Support schema registry multiserver configuration