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 API guide

Build a Peepvibes watch client with the APIs, or embed the owner-hosted read-only terminal in an approved third-party page. Public streams and chat history do not require sign-in.

  1. Install peepvibes-sdk (npm install ./peepvibes-sdk-0.1.0.tgz), with bundled JavaScript and TypeScript declarations for browser and Node.js clients.
  2. List public live streams and open a watch page using createPeepvibesClient() and the stream’s public ID.
  3. Explore JSON:API or GraphQL interactively, then use the SDK for your app.
  4. Connect the read-only live terminal and load recent chat messages.
  5. If your app supports sending chat, read authentication and access first. Create a personal key in Peepvibes settings; do not put a shared API key in JavaScript.

For a terminal without a second ALiS/Kitty renderer, use the hosted player embed. The SDK path above is for clients that need their own terminal implementation and API-driven UI.

Use the public stream’s publicId for share links, id for chat history, and the channel’s handle for channel lookup. Recordings are optional and available only if the source stream has a sealed, unexpired archive.

The CLI installer is separate: it installs peep for stream producers, not the watch SDK. Once an updated CLI release is published, run peep update (or peep upgrade) to install its verified platform binary. Installations predating that command must run the installer again once. An active broadcast keeps its existing process until the next session.

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.

Explore the APIs

Two interactive explorers document the public API. Browse without signing in; provide your own personal API key to try actions that require an account. An API key acts as its owner, so access to private streams and owner mutations is still enforced by the server.

JSON:API and OpenAPI

Open the JSON:API explorer to browse the generated OpenAPI schema and send requests from Swagger UI. The API is rooted at https://peepvibes.live/api/json; the schema itself is available at /api/json/open_api. Public channel and stream reads work anonymously. For follows and owned-resource updates, use the explorer’s Authorize button and enter the personal API key as a Bearer token. JSON:API requests use application/vnd.api+json for request and response bodies.

GraphQL

Open the GraphQL explorer for schema-aware queries and mutations at https://peepvibes.live/gql. It starts with a public live-stream query you can run without a key:

query {
  liveStreams {
    results {
      id
      publicId
      title
    }
  }
}

For private reads and mutations, enter {"Authorization":"Bearer <your-api-key>"} in the request headers editor. The GraphQL schema exposes only documented public channels, streams and follows; internal credentials and producer controls are not exposed. Query depth and complexity limits apply to explorer requests too.

Use the peepvibes-sdk TypeScript library to build an app instead of copying explorer requests by hand. The live terminal and replay guide covers the WebSocket and recording endpoints, which are not GraphQL fields.

Authentication and access

Public directory, public/unlisted share links, chat history, viewer terminal, and public replay do not require an account. Send chat, manage follows, or edit an owned channel/stream only with a credential belonging to that user.

Credentials

Send Authorization: Bearer <per-user API key or valid bearer token> with each authenticated API request. The API accepts JSON requests from https://grok.me, its subdomains, and explicitly configured preview origins. For cross-origin requests, include Content-Type: application/json; the browser preflights requests containing that header or Authorization. Never use cookies or Phoenix CSRF for this API; credentials: 'omit' is appropriate.

Sign in at Peepvibes account settings to create a personal, expiring API key. Copy it when it is issued: the secret is displayed only once, and you can revoke it from the same page. Each key acts as its owner and is subject to the same resource permissions as that user. For a browser client, have the user supply their own key; do not ship a shared key in JavaScript or assume an existing peepvibes.live session authenticates a grok.me webview. There is no public webview token-issuance or X sign-in flow yet.

The same key works across the JSON:API explorer, the GraphQL explorer, and the TypeScript RPC client. To send an authenticated request:

curl -H "Authorization: Bearer $PEEPVIBES_API_KEY" \
  -H 'Accept: application/vnd.api+json' \
  'https://peepvibes.live/api/json/follows'

RPC permissions

FunctionAnonymousCredentialed access
listChannels, getChannelByHandle, listLiveStreams, getWatchableStream, recentMessagesYes (directory only lists public streams; public IDs also resolve unlisted streams)Private metadata requires owner or explicit grant
sendMessageNoConfirmed user; bans, rate limits, slow mode, 500 characters / 2048 bytes and per-user clientId deduplication apply
listMyFollows, followChannel, unfollowChannelNoAuthenticated account subject to action policy
updateChannel, updateStreamNoChannel/stream owner

Producer tickets, leases, stream creation, pause/resume/end, access grants, moderation, reports and credential management are not exposed through RPC. The SDK does not contain X sign-in, voice/video, Zod or Valibot schemas.

Errors

RPC returns HTTP 200 with either { "success": true, "data": ... } or { "success": false, "errors": [{ "type": "...", "message": "..." }] }. An anonymous chat send reports invalid_changes / sign in to chat; private or nonexistent share IDs report not_found; unknown procedures report action_not_found. Rate limiting returns HTTP 429 and error.code: "rate_limited". A disallowed origin’s preflight is HTTP 403. Do not reveal private record information based on error details.

A bearer authorizes individual HTTP requests, not the browser viewer WebSocket: WebSocket constructors cannot attach an Authorization header. The cross-origin terminal viewer is anonymous public/unlisted viewing only; do not present private streams as playable even when their metadata is accessible with a bearer.

Live terminal, chat and replay

Use client.watch(publicId, streamId, handlers) from peepvibes-sdk after resolving a stream by public ID. It opens wss://peepvibes.live/ws/s/:publicId with subprotocol v1.alis, sends no terminal input, and returns {send, close}. Call close() when your player unmounts.

If you do not need a custom renderer, use the owner-hosted iframe player instead. The SDK transport alone does not render Kitty images or terminal cells.

Render the terminal

handlers.init(frame) is called at first join and after reconnect. Clear both terminal text and Kitty graphics state before feeding the snapshot bytes frame.termInit. Set the grid to frame.cols × frame.rows; the creator’s grid is authoritative. handlers.output(bytes) receives raw byte runs: feed them in order to a terminal emulator with a Kitty APC graphics scanner; do not decode graphics as visible text. handlers.resize(cols, rows) updates the creator’s grid. handlers.status reports connecting, live, reconnecting, ended or revoked; close code 4030 means access revoked. A privacy pause does not reveal hidden output.

One binary WebSocket message is one ALiS v1 frame. Magic is ALiS\x01; init 0x01 contains last ID, time, columns, rows (unsigned LEB128), a theme (format 0, 8 or 16; the latter formats contain format+2 RGB triples), then length-prefixed initial terminal bytes. Output 0x6f and resize 0x72 carry event ID, relative time and their payload. EOT is 0x04. Input 0x69, marker 0x6d and exit 0x78 are recognized but not rendered by viewers. The TypeScript module decodes these frames; do not try to send frames over the viewer socket.

On supported terminals, the current CLI queries the creator’s foreground, background, and ANSI palette before launching the child, so indexed colours in the initial snapshot match subsequent output. If the terminal does not answer all colour queries, the viewer falls back to its own palette.

Chat

client.chat.history(streamId, {limit: 50}) returns visible messages in chronological order. The watch() transport refreshes this bounded history every three seconds; ALiS does not push chat messages. Removals disappear from the next poll. To send, obtain the user’s individual credential (see authentication) and call client.chat.send(streamId, body, {clientId}) or watcher.send(body, clientId?); the client ID deduplicates retries. Channel slowModeSeconds tells your UI when to enable the next send, but server limits remain authoritative.

Replay

If terminal recording was enabled, call client.replay.discover(publicId) or request GET https://peepvibes.live/api/watch/:publicId/replay. A sealed, unexpired recording visible to that caller returns { "castUrl": "/api/watch/recordings/:id.cast" }; otherwise it returns 404. Pass its castUrl to client.replay.cast(castUrl) to receive an asciicast v3 body. Access is rechecked for each cast request, including after the source stream’s visibility changes. Do not use the LiveView replay page as an embeddable player.

Voice/video are not part of this public watch transport. No cross-origin signaling or media consent API is provided by the SDK.

Embedding a live terminal

Peepvibes provides a read-only terminal iframe at https://peepvibes.live/embed/s/<public_id>. Use it when another site needs to show the terminal without implementing ALiS frame decoding, Kitty graphics, late-join snapshots, reconnects, or fit-to-frame sizing. The host page still owns its own stream header, follow and chat controls, and X Player Card tags. The iframe is not a complete watch page or a replacement for the X card URL.

Embed on the X share page

The watch page’s Copy X link button points to https://x.peepvibes.live/s/<public_id>. That URL serves its own X card metadata and mobile page. If the share page adopts the hosted iframe, replace only its terminal implementation with the hosted player:

function LiveTerminal({ publicId }: { publicId: string }) {
  return (
    <iframe
      title="Live Peepvibes terminal"
      src={`https://peepvibes.live/embed/s/${encodeURIComponent(publicId)}`}
      loading="eager"
      referrerPolicy="no-referrer"
      className="block w-full border-0"
      style={{ height: "min(70dvh, 600px)", minHeight: 320 }}
    />
  );
}

Render that component only for a public or unlisted stream resolved by the share page. Do not put a personal API key, producer ticket, or private stream identifier in the iframe URL. The player itself checks access anonymously: a private, missing, or inaccessible stream shows a generic unavailable state.

The supplied phone screenshot has readable page controls but tiny terminal text, and X’s browser chrome overlaps the lower chat area. Keep the source terminal’s geometry intact: offer a link to the full watch page or a user font-size control rather than cropping rows to make the text look bigger. Leave bottom space in the host page for its chat input and X’s browser controls (padding-bottom: env(safe-area-inset-bottom) is a starting point, not a substitute for testing in X). The iframe does not size or fix the surrounding share page.

The owner verified x.peepvibes.live as an inline X embed. That does not establish that a nested iframe has been installed or works inside X’s in-app browser. Keep the share page’s header, chat, and Follow button outside the iframe, and validate them separately after any player replacement. X controls how its browser and card are presented; this route cannot guarantee clipboard permissions there.

What the frame does

  • The Phoenix LiveView serves a compact, viewport-height terminal plus a “Watch on peepvibes” link that opens the canonical watch page in a new tab. No chat, voice, video, sign-in form, or creator controls run in the frame.
  • TerminalPlayer uses Peepvibes’ bundled ALiS decoder and xterm/Kitty renderer. It opens the read-only /ws/s/<public_id> socket from the Peepvibes origin, consumes a full init snapshot on join/reconnect, and does not send terminal input. Do not maintain a second decoder on the host page.
  • The route deliberately queries with actor: nil even if a visitor is signed in to Peepvibes. It serves only public and unlisted streams. The viewer socket performs its own authorization and revocation checks.
  • Content-Security-Policy: frame-ancestors 'self' https://x.peepvibes.live https://peep.grok.me permits the X share host and the legacy Grok share host for links already posted. X-Frame-Options is removed only on the embed route. Ordinary pages remain SAMEORIGIN; other origins are not implicitly allowed. The iframe has no postMessage or JavaScript API.

The iframe URL is stable; its assets are deployed with the main application. The existing peepvibes-sdk offers typed data and transport APIs, not a standalone renderer or a React component. An iframe avoids shipping renderer versions and dependencies into each third-party client.

Verification before replacing the share page’s player

  1. Deploy the Peepvibes release containing /embed/s/:public_id. Confirm /embed/s/<live-public-id> displays the live terminal in a standalone browser and that the response permits https://x.peepvibes.live to frame it.
  2. Load the actual x.peepvibes.live/s/<public_id> page in a phone-sized browser and inside X’s in-app browser. Confirm the nested frame loads, renders the current terminal (including large init snapshots), and has no nested scrollbars or clipped bottom controls. The iframe must have an explicit height; height: 100% alone needs a height on every ancestor.
  3. Disconnect and restore the network, refresh during output, and check the player returns to a complete current screen, not a stale partial frame. Verify privacy pause, end, and access revocation through the frame.
  4. Open a private URL through the embed route as a signed-in owner and as an anonymous visitor. Both must show only the generic unavailable state.
  5. Validate the X Player Card separately. Check its preview URL and metadata, then post the share URL, open the inline card in X on a phone, and follow its link to the share page. Test chat and Follow on the host page separately with authenticated credentials; those actions are not supplied by the iframe.

Deployment status (2026-09-29): /embed/s/:public_id is live on peepvibes.live; the owner verified x.peepvibes.live as an inline X embed. The iframe has rendered a public stream in Chromium. The share page’s adoption of that iframe and its behavior inside X’s browser are not yet verified.