Skip to content

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.

  • Node.js 18+ (or any runtime with global fetch)
  • TypeScript 5+ (optional but recommended)
Terminal window
npm install studyplug
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";

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.

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
});
OptionTypeDefaultDescription
apiKeystringundefinedAPI key for the X-StudyPlug-Key header
baseUrlstring"https://api.studyplug.org"API base URL
timeoutnumber30000Request timeout in milliseconds
maxRetriesnumber2Max automatic retries on 429 responses
fetchtypeof fetchglobalThis.fetchCustom fetch implementation
const sp = new StudyPlug();
const { status } = await sp.health();
console.log(status); // "ok"

Head to the Quick Start to browse the curriculum and generate your first content.