> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AvroType

> AvroType — Kinetica TypeScript API

<div className="kinetica-typedoc">
  <div className="tsd-page-title" />

  <div className="section tsd-panel tsd-comment">
    <div className="tsd-comment tsd-typography">
      <p>An Avro type, compiled from its schema, that encodes values to Avro binary and decodes them back.</p>
      <p>Values map to JavaScript as JSON-style data: records and maps to plain objects, arrays to arrays, bytes and fixed to Uint8Array, enums to their symbol strings, and null to null. A union takes the value as-is and is written as its first branch that accepts it.</p>
    </div>

    <div className="tsd-comment tsd-typography">
      <div className="tsd-tag-example">
        <h4 className="tsd-anchor-link" id="example">Example</h4>

        <div>
          ```
          const type = AvroType.forSchema({
              type: 'record', name: 'point',
              fields: [{ name: 'x', type: 'double' }, { name: 'label', type: ['string', 'null'] }],
          });
          const bytes = type.encode({ x: 1.5, label: null });
          type.decode(bytes); // { x: 1.5, label: null }
          ```
        </div>
      </div>
    </div>
  </div>

  <div className="aside tsd-sources">
    <ul>
      <li>Defined in <a href="https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/avro.ts#L921">src/avro.ts:921</a></li>
    </ul>
  </div>

  <div className="section tsd-panel-group tsd-index-group">
    <div className="section tsd-panel tsd-index-panel">
      <div className="details tsd-index-content tsd-accordion" open="">
        <div className="summary tsd-accordion-summary tsd-index-summary">
          <h5 className="tsd-index-heading uppercase">Index</h5>
        </div>

        <div className="tsd-accordion-details">
          <div className="section tsd-index-section">
            <h3 className="tsd-index-heading tsd-anchor-link" id="properties">Properties</h3>
            <div className="tsd-index-list"><a href="#schema" className="tsd-index-link"><span>schema</span></a> </div>
          </div>

          <div className="section tsd-index-section">
            <h3 className="tsd-index-heading tsd-anchor-link" id="methods">Methods</h3>
            <div className="tsd-index-list"><a href="#decode" className="tsd-index-link"><span>decode</span></a> <a href="#encode" className="tsd-index-link"><span>encode</span></a> <a href="#forschema" className="tsd-index-link"><span>forSchema</span></a> </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div className="details tsd-panel-group tsd-member-group tsd-accordion" open="">
    <div className="summary tsd-accordion-summary" data-key="section-Properties">
      <h2 className="tsd-anchor-link" id="properties-1">Properties</h2>
    </div>

    <div className="section">
      <div className="section tsd-panel tsd-member">
        <h3 className="tsd-anchor-link" id="schema"><code className="tsd-tag">Readonly</code><span>schema</span></h3>
        <div className="tsd-signature"><span className="tsd-kind-property">schema</span><span className="tsd-signature-symbol">:</span> <a href="/content/api/typescript/types/AvroSchema" className="tsd-signature-type tsd-kind-type-alias">AvroSchema</a></div>

        <div className="tsd-comment tsd-typography">
          <p>The schema this type was compiled from</p>
        </div>

        <div className="aside tsd-sources">
          <ul>
            <li>Defined in <a href="https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/avro.ts#L923">src/avro.ts:923</a></li>
          </ul>
        </div>
      </div>
    </div>
  </div>

  <div className="details tsd-panel-group tsd-member-group tsd-accordion" open="">
    <div className="summary tsd-accordion-summary" data-key="section-Methods">
      <h2 className="tsd-anchor-link" id="methods-1">Methods</h2>
    </div>

    <div className="section">
      <div className="section tsd-panel tsd-member">
        <h3 className="tsd-anchor-link" id="decode"><span>decode</span></h3>

        <ul className="tsd-signatures">
          <li className="">
            <div className="tsd-signature tsd-anchor-link" id="decode-1"><span className="tsd-kind-call-signature">decode</span><span className="tsd-signature-symbol">(</span><span className="tsd-kind-parameter">data</span><span className="tsd-signature-symbol">:</span> <span className="tsd-signature-type">ArrayBuffer</span> <span className="tsd-signature-symbol">|</span> <span className="tsd-signature-type">Uint8Array</span><span className="tsd-signature-symbol">\<</span><span className="tsd-signature-type">ArrayBufferLike</span><span className="tsd-signature-symbol">></span><span className="tsd-signature-symbol">)</span><span className="tsd-signature-symbol">:</span> <span className="tsd-signature-type">any</span></div>

            <div className="tsd-description">
              <div className="tsd-comment tsd-typography">
                <p>Decodes one Avro binary value, which must take up the whole input.</p>
              </div>

              <div className="tsd-parameters">
                <h4 className="tsd-parameters-title">Parameters</h4>

                <ul className="tsd-parameter-list">
                  <li><span><span className="tsd-kind-parameter">data</span>: <span className="tsd-signature-type">ArrayBuffer</span> <span className="tsd-signature-symbol">|</span> <span className="tsd-signature-type">Uint8Array</span><span className="tsd-signature-symbol">\<</span><span className="tsd-signature-type">ArrayBufferLike</span><span className="tsd-signature-symbol">></span></span></li>
                </ul>
              </div>

              <h4 className="tsd-returns-title">Returns <span className="tsd-signature-type">any</span></h4>

              <div className="tsd-comment tsd-typography">
                <div className="tsd-tag-throws">
                  <h4 className="tsd-anchor-link" id="throws">Throws</h4>
                  <p>AvroError if the data is truncated, has bytes left over, or otherwise does not match the schema</p>
                </div>
              </div>

              <div className="aside tsd-sources">
                <ul>
                  <li>Defined in <a href="https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/avro.ts#L994">src/avro.ts:994</a></li>
                </ul>
              </div>
            </div>
          </li>
        </ul>
      </div>

      <div className="section tsd-panel tsd-member">
        <h3 className="tsd-anchor-link" id="encode"><span>encode</span></h3>

        <ul className="tsd-signatures">
          <li className="">
            <div className="tsd-signature tsd-anchor-link" id="encode-1"><span className="tsd-kind-call-signature">encode</span><span className="tsd-signature-symbol">(</span><span className="tsd-kind-parameter">value</span><span className="tsd-signature-symbol">:</span> <span className="tsd-signature-type">any</span><span className="tsd-signature-symbol">)</span><span className="tsd-signature-symbol">:</span> <span className="tsd-signature-type">Uint8Array</span></div>

            <div className="tsd-description">
              <div className="tsd-comment tsd-typography">
                <p>Encodes a value to Avro binary.</p>
              </div>

              <div className="tsd-parameters">
                <h4 className="tsd-parameters-title">Parameters</h4>

                <ul className="tsd-parameter-list">
                  <li><span><span className="tsd-kind-parameter">value</span>: <span className="tsd-signature-type">any</span></span></li>
                </ul>
              </div>

              <h4 className="tsd-returns-title">Returns <span className="tsd-signature-type">Uint8Array</span></h4>

              <div className="tsd-comment tsd-typography">
                <div className="tsd-tag-throws">
                  <h4 className="tsd-anchor-link" id="throws-1">Throws</h4>
                  <p>AvroError if the value does not match the schema; its <code>path</code> names the offending field</p>
                </div>
              </div>

              <div className="aside tsd-sources">
                <ul>
                  <li>Defined in <a href="https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/avro.ts#L974">src/avro.ts:974</a></li>
                </ul>
              </div>
            </div>
          </li>
        </ul>
      </div>

      <div className="section tsd-panel tsd-member">
        <h3 className="tsd-anchor-link" id="forschema"><code className="tsd-tag">Static</code><span>forSchema</span></h3>

        <ul className="tsd-signatures">
          <li className="">
            <div className="tsd-signature tsd-anchor-link" id="forschema-1"><span className="tsd-kind-call-signature">forSchema</span><span className="tsd-signature-symbol">(</span><span className="tsd-kind-parameter">schema</span><span className="tsd-signature-symbol">:</span> <a href="/content/api/typescript/types/AvroSchema" className="tsd-signature-type tsd-kind-type-alias">AvroSchema</a><span className="tsd-signature-symbol">)</span><span className="tsd-signature-symbol">:</span> <a href="" className="tsd-signature-type tsd-kind-class">AvroType</a></div>

            <div className="tsd-description">
              <div className="tsd-comment tsd-typography">
                <p>Compiles a schema, or returns the type already compiled for it.</p>
              </div>

              <div className="tsd-parameters">
                <h4 className="tsd-parameters-title">Parameters</h4>

                <ul className="tsd-parameter-list">
                  <li>
                    <span><span className="tsd-kind-parameter">schema</span>: <a href="/content/api/typescript/types/AvroSchema" className="tsd-signature-type tsd-kind-type-alias">AvroSchema</a></span>

                    <div className="tsd-comment tsd-typography">
                      <p>The schema as an object, as JSON text, or as the bare name of a primitive type such as <code>"long"</code></p>
                    </div>
                  </li>
                </ul>
              </div>

              <h4 className="tsd-returns-title">Returns <a href="" className="tsd-signature-type tsd-kind-class">AvroType</a></h4>

              <div className="tsd-comment tsd-typography">
                <div className="tsd-tag-throws">
                  <h4 className="tsd-anchor-link" id="throws-2">Throws</h4>
                  <p>AvroError if the schema is invalid</p>
                </div>
              </div>

              <div className="aside tsd-sources">
                <ul>
                  <li>Defined in <a href="https://github.com/kineticadb/kinetica-api-typescript/blob/master/src/avro.ts#L939">src/avro.ts:939</a></li>
                </ul>
              </div>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.