npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sitegpt/sdk

v0.2.0

Published

Official SiteGPT SDK for TypeScript and JavaScript — a typed, zero-dependency client for the SiteGPT API v2 (chatbots, knowledge, conversations, leads, messages, onboarding).

Downloads

316

Readme

@sitegpt/sdk

Official SiteGPT SDK for TypeScript and JavaScript — a typed, zero-dependency client for the SiteGPT API v2.

  • Typed end to end — types are generated from the live API's OpenAPI 3.1 document (all 120 operations), and every convenience method returns the operation's exact data payload type.
  • Zero dependencies — built on the global fetch (Node 18+, Bun, Deno, browsers, edge runtimes).
  • Envelope-aware — the API responds with { ok, data, meta }; the SDK returns data directly and throws a SiteGPTError (with the API's error code, message, and actionable hint) whenever ok is false.

Install

npm install @sitegpt/sdk

Quickstart

Create an API token in the SiteGPT dashboard (Settings → API tokens), then:

import { SiteGPT } from '@sitegpt/sdk'

const sitegpt = new SiteGPT({ apiToken: process.env.SITEGPT_API_TOKEN! })

// List your chatbots
const { chatbots } = await sitegpt.chatbots.list()

// Add knowledge to a chatbot
await sitegpt.knowledge.addLinks(chatbotId, {
  urls: ['https://example.com/docs/getting-started'],
})

// Send a chat message (starts a new conversation)
const reply = await sitegpt.messages.send(chatbotId, {
  message: 'What are your pricing plans?',
})

// Review conversations and captured leads
const conversations = await sitegpt.conversations.list(chatbotId, { limit: 20 })
const leads = await sitegpt.leads.list(chatbotId)

Agent onboarding bootstrap (no token required)

The onboarding bootstrap is a public endpoint — an AI agent can provision a SiteGPT workspace with no credentials at all, and the response carries the temporary workspace token to use for everything that follows:

import { SiteGPT } from '@sitegpt/sdk'

// No API token yet — the bootstrap endpoint is public:
const bootstrap = new SiteGPT()
const started = await bootstrap.onboarding.start({
  websiteUrl: 'https://example.com',
})

// The response includes a temporary workspace token:
const sitegpt = new SiteGPT({ apiToken: started.apiToken as string })
const chatbotId = started.workspace?.chatbotId as string
await sitegpt.knowledge.documentStats(chatbotId)

health() is public too; every other endpoint responds 401 until an apiToken is set.

Error handling

import { SiteGPT, SiteGPTError } from '@sitegpt/sdk'

try {
  await sitegpt.chatbots.get('nonexistent-id')
} catch (error) {
  if (error instanceof SiteGPTError) {
    console.error(error.status) // HTTP status, e.g. 404
    console.error(error.code) // machine-readable code, e.g. NOT_FOUND
    console.error(error.message) // human-readable message
    console.error(error.hint) // actionable next step, when the API provides one
    console.error(error.requestId) // for support and debugging
  }
}

Convenience namespaces

The highest-value API groups have first-class methods:

| Namespace | Methods | | --- | --- | | sitegpt.chatbots | list, get, create, update, delete, dashboard | | sitegpt.knowledge | listDocuments, getDocument, updateDocument, deleteDocument, deleteDocuments, documentStats, resyncDocuments, addLinks, addWebsite, addSitemap, addYoutube, setText, listSources, getSource, createSource, updateSource, revokeSource, ingestSource, listSyncJobs, getSyncJob | | sitegpt.conversations | list, get, create, update, delete, escalate, switchToAi | | sitegpt.leads | list, get, update, delete, runAction | | sitegpt.messages | send, sendToConversation, list, update | | sitegpt.onboarding | start, getWorkspace, claimWorkspace, deleteWorkspace |

Plus sitegpt.me() and sitegpt.health().

Destructive operations require confirmation

The API requires confirm=true on delete-family endpoints, and the SDK keeps that intent explicit instead of confirming on your behalf: chatbots.delete, knowledge.deleteDocument, knowledge.deleteDocuments, knowledge.revokeSource, conversations.delete, and leads.delete take a required { confirm: true } argument and throw a CONFIRMATION_REQUIRED SiteGPTError client-side (before any request) without it:

await sitegpt.conversations.delete(chatbotId, threadId, { confirm: true })
await sitegpt.chatbots.delete(chatbotId, { confirm: true })

Every other endpoint: request()

All 120 API v2 operations are reachable through the typed low-level request(path, options) — known paths autocomplete:

// Custom responses, personas, instructions, settings, members, tags, billing…
const personas = await sitegpt.request(`/api/v2/chatbots/${chatbotId}/personas`)

await sitegpt.request(`/api/v2/chatbots/${chatbotId}/settings`, {
  method: 'PATCH',
  body: { general: { title: 'Support Bot' } },
})

requestWithMeta() additionally returns the envelope meta — including meta.nextCursor for pagination:

const { data, meta } = await sitegpt.requestWithMeta(
  `/api/v2/chatbots/${chatbotId}/conversations`,
  { query: { limit: 50 } },
)
const nextPage = await sitegpt.conversations.list(chatbotId, {
  cursor: meta.nextCursor ?? undefined,
})

OpenAPI types

The raw generated types are exported for advanced use, and the OpenAPI document itself ships in the package as openapi.generated.json:

import type { components, operations, paths } from '@sitegpt/sdk'

type Chatbot = components['schemas']['Chatbot']
type ListLeadsData = import('@sitegpt/sdk').OperationData<'listLeads'>

Timeouts

Requests time out after 30 seconds by default. Override the default per client with timeoutMs, or per request with an AbortSignal (a provided signal replaces the timeout signal entirely):

const sitegpt = new SiteGPT({ apiToken, timeoutMs: 60_000 })
await sitegpt.request('/api/v2/me', { signal: AbortSignal.timeout(5_000) })

Custom base URL

baseUrl defaults to https://sitegpt.ai and only needs to change if SiteGPT gives you a different API origin:

const sitegpt = new SiteGPT({
  apiToken: process.env.SITEGPT_API_TOKEN!,
  baseUrl: 'https://sitegpt.ai',
})

Related

License

MIT © SiteGPT