API Details
Complete reference for server-side Kooboo KScript (
k.*), covering authentication, content, databases, site resources, commerce, and utilities.
| Execution Context | Prerequisites | Typical Use |
|---|---|---|
Server-side Api / CodeBlock / <script env="server"> | Supports JavaScript & TypeScript syntax (transpiled and run synchronously on Jint; not Node or Browser) | Pick APIs by scenario or browse A–Z modules |
AI / LLM Index & Raw Markdown Endpoints
- Full Site Index: /llms.txt
- KScript AI Cheat Sheet: /llms-kscript.txt (Jint runtime rules, key Kooboo gotchas, and complete
k.*.mdcatalog) - Raw Markdown: Append
.mdto any published documentation route to fetch raw Markdown directly (for example,/api/request/index.md).
Quick Start
js
// Api script example: read query parameters and return JSON directly
k.api.get(() => {
const id = k.request.queryString.get("id")
if (!id) {
k.response.statusCode(400)
return { ok: false, error: "missing id" }
}
return { ok: true, id: id }
})Getting Started
| Doc | Description |
|---|---|
| API Getting Started | KScript basics and the shape of the global k object |
| KScript Language and Runtime | Where KScript runs, script types, globals, imports, errors, and limits |
| Authentication and Authorization | Login, sessions, cookies, and access control |
Scenario Quick Selector
| Scenario | Recommended API | Key Notes |
|---|---|---|
| Build REST / webhook endpoints | k.api · k.request · k.response | Return JS objects directly for JSON; always return after setting statusCode |
| Structured CMS content & snippets | k.content · k.site.htmlBlocks | Query/write content folders & items; use htmlBlocks for localized snippets |
| Zero-setup NoSQL tables | k.DB.indexedDb | Flexible collections with where / orderBy (uppercase operators like EQ) |
| Relational SQL & external DBs | k.DB.sqlite · k.DB | SQLite supports @name bindings; MySQL/SQLServer require admin DB setup |
| Small config & append-only logs | k.DB.keyValue · k.DB.sequenceDb | keyValue caps values at 4096 bytes; sequenceDb fits integer-keyed logs |
| Pages, components & scheduled jobs | k.site | Manage pages, layouts, views, codes, menus, routes, and jobs |
| Disk I/O vs CMS File Library | k.file · k.site.files | Use k.file for site disk files; k.site.files for versioned CMS URLs |
| Platform auth, sessions & cookies | k.account · k.session · k.cookie | Console/org auth via k.account; HTTP session & cookie stores separate |
| Storefront ecommerce & payments | k.commerce · k.payment | Products, cart, orders, customers, and Stripe/PayPal/Alipay/WeChat |
| Outbound HTTP, mail & OpenAPI | k.net · k.mail · k.openApi | Call HTTP endpoints with k.net.httpClient or invoke imported OpenAPI specs |
| Analytics, privacy & edit history | k.analytics · k.privacy · k.history | Traffic/error metrics, Cookie consent config, diffs, and version rollback |
| Cryptography, helpers & utilities | k.security · k.utils | AES/RSA/JWT, strings/dates/XML, Puppeteer, screenshots, Office & Sitemap |
KScript APIs (A–Z)
| Module | Doc | Description |
|---|---|---|
k.account | account/ | Platform login, current user, organization, and OAuth |
k.analytics | analytics/ | Site visitor, resource, and error analytics, plus custom goal tracking |
k.api | api/ | API route helpers |
k.cache | cache/ | Site-level in-memory cache |
k.commerce | commerce/ | Commerce APIs including product, cart, and order pages |
k.content | content/ | Content types and content items |
k.cookie | cookie/ | Cookies |
k.DB | database/, indexed-db/, key-value/, sequence-db/, sqlite/ | Database access, IndexedDB tables, key-value storage, sequence DB, and SQLite |
k.file | file/ | Files in the site directory |
k.google | google/ | PageSpeed/Lighthouse and Firebase |
k.history | history/ | Site edit history, version comparison, and rollback |
k.label | label/ | Multilingual k.t and k.label |
k.logger | logger/ | Code logs |
k.mail | mail/ | Sending mail, IMAP, SES, and parsing |
k.media | media/ | Media library files and folders |
k.module | module/ | Script modules, config, tasks, and packaging |
k.net | net/ | HTTP, WebSocket, DNS, IP, Ping, SSH, SFTP, and Telnet |
k.openApi | openapi/ | External OpenAPI definitions, auth, and calls |
k.page | page/ | Current page title and meta |
k.paramConfig | param-config/ | Structured JSON parameter config |
k.payment | payment/ | Payment integrations |
k.privacy | privacy/ | Cookie consent configuration and third-party script inspection |
k.request | request/ | HTTP request data |
k.response | response/ | HTTP response handling |
k.security | security/ | Encryption and hashing |
k.session | session/ | Session state |
k.site | site/ | Pages, layouts, views, scripts, styles, codes, menus, files, images, HTML blocks, form values, routes, jobs, and site context |
k.state | state/ | Per-request view state |
k.utils | utils/ | Utility modules |
| SPA multilingual | spa-multilingual/ | /_spa/lang/{lang} dictionaries |
k.site Sub-Resources
| Member | Doc | Description |
|---|---|---|
k.site.pages | page.md | Site pages, routes, and change logs |
k.site.layouts | layout.md | Layout templates and placeholders |
k.site.views | view.md | Reusable view fragments |
k.site.scripts | js.md | Standalone JavaScript assets |
k.site.styles | css.md | Standalone CSS stylesheet assets |
k.site.codes | code.md | API, CodeBlock, and other Code resources |
k.site.menus | menu.md | Frontend navigation menus and sub-menu trees |
k.site.files | file.md | CMS file repository items (versioned routable files) |
k.site.images | image.md | Site image assets and media uploads |
k.site.htmlBlocks | html-block.md | Multilingual HTML fragments |
k.site.formValues | form-value.md | Form submission records |
k.site.routes | route.md | Site route queries, path updates, and aliases |
k.site.job / k.site.runJob / k.site.getJob | job.md | Scheduled job CRUD, manual triggering, and status queries |
k.site.info / webSite / settings / multilingual / search / version / diskSpace / helper | context.md | Site metadata, configuration, multilingual URLs, full-text search, asset cache versions, disk space metrics, and helper URLs |
In addition, see k.label for k.site.labels and k.history for k.site.editLog.
k.file Subpages
Subpages: folder, resumable, data structures
Related Sections
| Scenario | Next doc |
|---|---|
| You need to prepare content models or site settings first | Admin CMS |
| You need Page / Layout / View rendering rules first | Template Engine |