@virke/sdk
v1.1.0
Published
TypeScript SDK for the Virke platform
Readme
@virke/sdk
TypeScript SDK for the Virke platform. Manage projects, deployments, databases, KV stores, and object storage from any TypeScript/JavaScript runtime.
Install
bun add @virke/sdkQuick Start
import { VirkeClient } from "@virke/sdk";
const client = new VirkeClient({
baseUrl: "https://api.virke.dev",
token: "your-session-token",
// or: apiKey: "vk_..."
});
// List projects
const { data } = await client.listProjects();
console.log(data.projects);
// Deploy a static site
await client.deploy("my-site", [
{ path: "index.html", content: "<h1>Hello</h1>" },
]);
// Query a database
const result = await client.dbQuery("my-db", "SELECT * FROM users WHERE id = ?", [1]);
console.log(result.data.rows);Authentication
The SDK supports three auth modes:
// Session token (from `virke login`)
new VirkeClient({ baseUrl: "https://api.virke.dev", token: "session-token" });
// API key (for CI/CD and scripts)
new VirkeClient({ baseUrl: "https://api.virke.dev", apiKey: "vk_..." });
// Cookie-based (for browser/dashboard use)
new VirkeClient({ baseUrl: "https://api.virke.dev", useCookies: true });API Reference
Projects
| Method | Description |
|--------|-------------|
| listProjects() | List all projects |
| createProject({ name, slug?, project_type? }) | Create a new project |
| getProject(slug) | Get project details |
| updateProject(slug, { name?, description? }) | Update project |
| deleteProject(slug) | Delete a project |
Deployments
| Method | Description |
|--------|-------------|
| deploy(slug, files) | Deploy static files |
| deployRun(slug, wasmBase64) | Deploy a Wasm binary to Virke Run |
| deployShared(slug, script) | Deploy JS to shared run (free tier) |
| listDeployments(slug) | List deploy history |
| rollback(slug, deployId?) | Roll back to a previous deploy |
| createPreview(slug, files) | Create a preview deployment |
Canary Deployments
| Method | Description |
|--------|-------------|
| startCanary(slug, deployId, weight) | Start canary for static sites |
| adjustCanary(slug, weight) | Adjust canary traffic weight |
| promoteCanary(slug) | Promote canary to production |
| abortCanary(slug) | Abort canary, revert to stable |
| startRunCanary(slug, version, weight) | Start canary for Virke Run |
| getCanaryStatus(slug) | Check canary status |
Databases (Virke DB)
| Method | Description |
|--------|-------------|
| createDatabase(slug, name, options?) | Create a database |
| listDatabases(slug) | List databases |
| dbQuery(dbName, sql, params?) | Execute a SQL query |
| dbBatch(dbName, statements) | Execute multiple statements |
| dbTransaction(dbName, statements) | Execute in a transaction |
| dbFlush(dbName) | Flush pending async writes |
| dbSyncStatus(dbName) | Check sync status |
| promoteDatabase(slug, name, options) | Promote to a higher tier |
Key-Value Store (Virke KV)
| Method | Description |
|--------|-------------|
| createKvNamespace(slug, name) | Create a namespace |
| kvGet(namespace, key) | Get a value |
| kvSet(namespace, key, value, options?) | Set a value (with optional TTL) |
| kvDelete(namespace, key) | Delete a key |
| kvList(namespace, options?) | List keys |
Object Storage (Virke OS3)
| Method | Description |
|--------|-------------|
| createOs3Bucket(slug, name, options?) | Create a bucket |
| os3Get(bucket, key) | Get an object |
| os3Put(bucket, key, content, contentType?) | Put an object |
| os3Delete(bucket, key) | Delete an object |
| os3List(bucket, options?) | List objects |
Domains & Environment
| Method | Description |
|--------|-------------|
| addDomain(slug, hostname) | Add a custom domain |
| listDomains(slug) | List domains |
| checkDomainStatus(slug, hostname) | Check DNS/SSL status |
| setEnvVars(slug, vars) | Set environment variables |
| listEnvVars(slug) | List environment variables |
Organizations
| Method | Description |
|--------|-------------|
| listOrgs() | List organizations |
| createOrg(name, slug?) | Create an organization |
| inviteOrgMember(slug, email, role?) | Invite a member |
| listOrgMembers(slug) | List members |
Response Format
All methods return ApiResult<T>:
type ApiResult<T> = {
data: T;
error: null;
} | {
data: null;
error: { code: string; message: string };
};