Installation
The studyplug package is a zero-dependency TypeScript client for the StudyPlug API.
It works in Node.js, Deno, Bun, and any environment with a global fetch.
Requirements
Section titled “Requirements”- Node.js 18+ (or any runtime with global
fetch) - TypeScript 5+ (optional but recommended)
Install
Section titled “Install”npm install studyplugpnpm add studyplugyarn add studyplugBasic Import
Section titled “Basic Import”import { StudyPlug } from "studyplug";
const sp = new StudyPlug();The SDK ships ESM-only with full TypeScript declarations. All types are exported from the package root:
import type { ContentItem, SkillSummary, GenerateParams } from "studyplug";Authentication
Section titled “Authentication”The free tier works without an API key (IP-based rate limits apply). To use an authenticated key for higher rate limits, pass it in the constructor:
const sp = new StudyPlug({ apiKey: process.env.STUDYPLUG_API_KEY,});The key is sent as the X-StudyPlug-Key header on every request.
Configuration Options
Section titled “Configuration Options”const sp = new StudyPlug({ apiKey: "sp_live_...", // optional baseUrl: "https://api.studyplug.org", // default timeout: 30_000, // 30s default maxRetries: 2, // retries on 429 fetch: customFetchImpl, // optional override});| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | undefined | API key for the X-StudyPlug-Key header |
baseUrl | string | "https://api.studyplug.org" | API base URL |
timeout | number | 30000 | Request timeout in milliseconds |
maxRetries | number | 2 | Max automatic retries on 429 responses |
fetch | typeof fetch | globalThis.fetch | Custom fetch implementation |
Verify It Works
Section titled “Verify It Works”const sp = new StudyPlug();const { status } = await sp.health();console.log(status); // "ok"Next Steps
Section titled “Next Steps”Head to the Quick Start to browse the curriculum and generate your first content.