Skip to main content

latest

Formata client-facing SDK, enabling users of Formata to easily call into their APIs.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a day ago (0.3.1)

Formata Client SDK

Connect and orchestrate applications with Formata. This SDK is only one way of interacting with your endpoints and services on the Formata Lattice, but is a very efficient way to do so.

It is recommended to keep one FormataClient instance, housing your WebSocket connection to Formata. It is designed to be held for long periods of time, ensuring reconnects when needed, etc...

Example

import { FormataClient, TokenAuth } from "@formata/client-sdk";

// Creates a WebSocket connection to Formata.
const client = new FormataClient();

// Creates and calls an authenticated request to Formata. Multiple ways to authenticate exist if needed.
// The 'connect' tab in the Formata web application (https://app.formata.io) outlines the 'space', 'version', 'api', and 'endpoint' to use.
// The 'wait' method is shorthand for 'send', then 'wait' on the resulting session for a final response.
// If you don't expect or plan to use a response, call 'send' instead.
const auth = new TokenAuth('my_Formata_api_key');
const resp = await client.request('space', 'version', 'api', 'endpoint').auth(auth).json({ name: 'Bob' }).wait();

// Close the connection explicitly. If you send another message, the connection will be re-opened.
// Most likely will not need to use this in your use of the SDK.
client.close();

Add Package

deno add jsr:@formata/client-sdk

Import symbol

import * as _formata_client_sdk from "@formata/client-sdk";

---- OR ----

Import directly with a jsr specifier

import * as _formata_client_sdk from "jsr:@formata/client-sdk";

Add Package

npx jsr add @formata/client-sdk

Import symbol

import * as _formata_client_sdk from "@formata/client-sdk";

Add Package

yarn dlx jsr add @formata/client-sdk

Import symbol

import * as _formata_client_sdk from "@formata/client-sdk";

Add Package

pnpm dlx jsr add @formata/client-sdk

Import symbol

import * as _formata_client_sdk from "@formata/client-sdk";

Add Package

bunx jsr add @formata/client-sdk

Import symbol

import * as _formata_client_sdk from "@formata/client-sdk";