---
title: JavaScript Schema Registry API for Data Transforms
latest-redpanda-tag: v25.2.1
latest-console-tag: v3.14.0
latest-operator-version: v25.2.6
# EOL = End-of-Life (support lifecycle status)
page-is-nearing-eol: "false"
page-is-past-eol: "true"
page-eol-date: July 31, 2026
latest-connect-version: 4.118.0
docname: data-transforms/js/js-sdk-sr
page-component-name: streaming
page-version: "25.2"
page-component-version: "25.2"
page-component-title: Streaming
page-relative-src-path: data-transforms/js/js-sdk-sr.adoc
page-edit-url: https://github.com/redpanda-data/docs/edit/v/25.2/modules/reference/pages/data-transforms/js/js-sdk-sr.adoc
description: Work with Schema Registry in data transforms using JavaScript.
page-git-created-date: "2024-07-31"
page-git-modified-date: "2025-04-08"
page-generated-content: none
support-status: past end-of-life
---

# JavaScript Schema Registry API for Data Transforms

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [streaming-full.txt](https://docs.redpanda.com/streaming-full.txt)

<!-- Source: https://docs.redpanda.com/streaming/25.2/reference/data-transforms/js/js-sdk-sr.md -->

This page contains the API reference for the Schema Registry client library of the data transforms JavaScript SDK.

## Functions

### newClient()

```
newClient (): <<SchemaRegistryClient, `SchemaRegistryClient`>>
```

Returns a client interface for interacting with Redpanda Schema Registry.

#### Returns

[`SchemaRegistryClient`](#SchemaRegistryClient)

#### Example

```js
import { newClient, SchemaFormat } from "@redpanda-data/sr";

var sr_client = newClient();
const schema = {
  type: "record",
  name: "Example",
  fields: [
    { "name": "a", "type": "long", "default": 0 },
    { "name": "b", "type": "string", "default": "" }
  ]
};

const subj_schema = sr_client.createSchema(
  "avro-value",
  {
    schema: JSON.stringify(schema),
    format: SchemaFormat.Avro,
    references: [],
  }
);
```

### decodeSchemaID()

```
decodeSchemaID  (`buf`): <<DecodeResult, `DecodeResult`>>
```

#### Parameters

-   `buf`: `string`, `ArrayBuffer`, or `Uint8Array`


#### Returns

[`DecodeResult`](#DecodeResult) in the same type as the given argument.

## Interfaces

### DecodeResult

The result of a [`decodeSchemaID`](#decodeSchemaID) function.

#### Properties

-   `id` (read only): The decoded schema ID

-   `rest` (read only): The remainder of the input buffer after stripping the encoded ID.


### Reference

#### Properties

-   `name`: `string`

-   `subject`: `string`

-   `version`: `number`


### Schema

#### Properties

-   `format` (read only): [`SchemaFormat`](#SchemaFormat)

-   `references` (read only): [`Reference`](#reference)

-   `schema` (read only): `string`


### SchemaRegistryClient

Client interface for interacting with Redpanda Schema Registry.

#### Methods

-   `createSchema(subject (string), schema)`: [`SubjectSchema`](#SubjectSchema)

-   `lookupLatestSchema(subject (string))`: [`SubjectSchema`](#SubjectSchema)

-   `lookupSchemaById(id (number))`: [`Schema`](#schema)

-   `lookupSchemaByVersion(subject (string), version (number))`: [`SubjectSchema`](#SubjectSchema)


### SubjectSchema

#### Properties

-   `id` (read only): `number`

-   `schema` (read only): [`Schema`](#schema)

-   `subject` (read only): `string`

-   `version` (read only): `number`


## Enumerations

### SchemaFormat

#### Enumeration members

-   Avro: `0`

-   Protobuf: `1`

-   JSON: `2`


## Suggested reading

[JavaScript API for Data Transforms](https://docs.redpanda.com/streaming/25.2/reference/data-transforms/js/js-sdk/)