Skip to content

API Details ​

Complete reference for server-side Kooboo KScript (k.*), covering authentication, content, databases, site resources, commerce, and utilities.

Execution ContextPrerequisitesTypical 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.* .md catalog)
  • Raw Markdown: Append .md to 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 ​

DocDescription
API Getting StartedKScript basics and the shape of the global k object
KScript Language and RuntimeWhere KScript runs, script types, globals, imports, errors, and limits
Authentication and AuthorizationLogin, sessions, cookies, and access control

Scenario Quick Selector ​

ScenarioRecommended APIKey Notes
Build REST / webhook endpointsk.api · k.request · k.responseReturn JS objects directly for JSON; always return after setting statusCode
Structured CMS content & snippetsk.content · k.site.htmlBlocksQuery/write content folders & items; use htmlBlocks for localized snippets
Zero-setup NoSQL tablesk.DB.indexedDbFlexible collections with where / orderBy (uppercase operators like EQ)
Relational SQL & external DBsk.DB.sqlite · k.DBSQLite supports @name bindings; MySQL/SQLServer require admin DB setup
Small config & append-only logsk.DB.keyValue · k.DB.sequenceDbkeyValue caps values at 4096 bytes; sequenceDb fits integer-keyed logs
Pages, components & scheduled jobsk.siteManage pages, layouts, views, codes, menus, routes, and jobs
Disk I/O vs CMS File Libraryk.file · k.site.filesUse k.file for site disk files; k.site.files for versioned CMS URLs
Platform auth, sessions & cookiesk.account · k.session · k.cookieConsole/org auth via k.account; HTTP session & cookie stores separate
Storefront ecommerce & paymentsk.commerce · k.paymentProducts, cart, orders, customers, and Stripe/PayPal/Alipay/WeChat
Outbound HTTP, mail & OpenAPIk.net · k.mail · k.openApiCall HTTP endpoints with k.net.httpClient or invoke imported OpenAPI specs
Analytics, privacy & edit historyk.analytics · k.privacy · k.historyTraffic/error metrics, Cookie consent config, diffs, and version rollback
Cryptography, helpers & utilitiesk.security · k.utilsAES/RSA/JWT, strings/dates/XML, Puppeteer, screenshots, Office & Sitemap

KScript APIs (A–Z) ​

ModuleDocDescription
k.accountaccount/Platform login, current user, organization, and OAuth
k.analyticsanalytics/Site visitor, resource, and error analytics, plus custom goal tracking
k.apiapi/API route helpers
k.cachecache/Site-level in-memory cache
k.commercecommerce/Commerce APIs including product, cart, and order pages
k.contentcontent/Content types and content items
k.cookiecookie/Cookies
k.DBdatabase/, indexed-db/, key-value/, sequence-db/, sqlite/Database access, IndexedDB tables, key-value storage, sequence DB, and SQLite
k.filefile/Files in the site directory
k.googlegoogle/PageSpeed/Lighthouse and Firebase
k.historyhistory/Site edit history, version comparison, and rollback
k.labellabel/Multilingual k.t and k.label
k.loggerlogger/Code logs
k.mailmail/Sending mail, IMAP, SES, and parsing
k.mediamedia/Media library files and folders
k.modulemodule/Script modules, config, tasks, and packaging
k.netnet/HTTP, WebSocket, DNS, IP, Ping, SSH, SFTP, and Telnet
k.openApiopenapi/External OpenAPI definitions, auth, and calls
k.pagepage/Current page title and meta
k.paramConfigparam-config/Structured JSON parameter config
k.paymentpayment/Payment integrations
k.privacyprivacy/Cookie consent configuration and third-party script inspection
k.requestrequest/HTTP request data
k.responseresponse/HTTP response handling
k.securitysecurity/Encryption and hashing
k.sessionsession/Session state
k.sitesite/Pages, layouts, views, scripts, styles, codes, menus, files, images, HTML blocks, form values, routes, jobs, and site context
k.statestate/Per-request view state
k.utilsutils/Utility modules
SPA multilingualspa-multilingual//_spa/lang/{lang} dictionaries

k.site Sub-Resources ​

MemberDocDescription
k.site.pagespage.mdSite pages, routes, and change logs
k.site.layoutslayout.mdLayout templates and placeholders
k.site.viewsview.mdReusable view fragments
k.site.scriptsjs.mdStandalone JavaScript assets
k.site.stylescss.mdStandalone CSS stylesheet assets
k.site.codescode.mdAPI, CodeBlock, and other Code resources
k.site.menusmenu.mdFrontend navigation menus and sub-menu trees
k.site.filesfile.mdCMS file repository items (versioned routable files)
k.site.imagesimage.mdSite image assets and media uploads
k.site.htmlBlockshtml-block.mdMultilingual HTML fragments
k.site.formValuesform-value.mdForm submission records
k.site.routesroute.mdSite route queries, path updates, and aliases
k.site.job / k.site.runJob / k.site.getJobjob.mdScheduled job CRUD, manual triggering, and status queries
k.site.info / webSite / settings / multilingual / search / version / diskSpace / helpercontext.mdSite 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

ScenarioNext doc
You need to prepare content models or site settings firstAdmin CMS
You need Page / Layout / View rendering rules firstTemplate Engine