Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Peepvibes TypeScript SDK

Install the peepvibes-sdk package with npm install ./peepvibes-sdk-0.1.0.tgz. The package contains bundled ESM and CommonJS builds with TypeScript declarations; it can be published to npm later without changing consumer imports. You can also build it from source. It is not published to npm yet.

import { createPeepvibesClient, PeepvibesApiError } from 'peepvibes-sdk';

const client = createPeepvibesClient();
const page = await client.streams.listLive({ limit: 20 });

for (const item of page.results) {
  const stream = await client.streams.get(item.publicId);
  const channel = await client.channels.getByHandle('HANDLE');
  const messages = await client.chat.history(stream.id, { limit: 50 });
  console.log(channel.title, stream.title, messages);
}

// Use a keyset cursor to fetch the next directory page.
if (page.nextPage) {
  const next = await client.streams.listLive({ after: page.nextPage });
  console.log(next.results);
}

Public reads work anonymously. createPeepvibesClient({ baseUrl, apiKey, fetch }) accepts a different HTTPS Peepvibes origin, an individual API key, and an optional custom fetch. The library never sends browser cookies. Methods return typed values and throw PeepvibesApiError with an issues array of field and permission errors. Pass { signal } to cancel an HTTP request. The channels, streams, chat, and follows properties expose the corresponding public and authenticated operations with editor-visible JSDoc. See the package README for every method.

To send chat, follow a channel or update your channel/stream, create a personal key in account settings and pass it as apiKey. Never embed a shared key in shipped JavaScript:

const me = createPeepvibesClient({ apiKey: personalKey });
try {
  const follow = await me.follows.add(channelId);
  await me.chat.send(streamId, 'Hello from my account');
  await me.follows.remove(follow.id);
} catch (error) {
  if (error instanceof PeepvibesApiError) {
    console.error(error.issues);
  } else {
    throw error;
  }
}

Equivalent HTTP examples for clients not using TypeScript:

curl -H 'Accept: application/vnd.api+json' \
  'https://peepvibes.live/api/json/streams/live'
curl -H 'Accept: application/vnd.api+json' \
  'https://peepvibes.live/api/json/channels/by-handle/HANDLE'
curl -H 'Accept: application/vnd.api+json' \
  'https://peepvibes.live/api/json/streams/watch/PUBLIC_ID'

Next: watch the live terminal, chat and replay, manage authentication, or try the interactive API explorers. A bearer authorizes HTTP actions, not the viewer WebSocket. Public and unlisted share IDs are playable; private streams are not.