TypeScript SDK for the StudyPlug API — generate educational content for K-8 math, reading, vocabulary, spelling, and science.
npm install studyplug
import { StudyPlug } from "studyplug";
const sp = new StudyPlug({ apiKey: "sp_live_..." });
// Generate 5 addition problems
const { data } = await sp.generate({ skill: "add-within-10", count: 5 });
console.log(data.items);
// Generate a single problem
const single = await sp.generate.single({ skill: "add-within-20" });
console.log(single.data.item);
- Zero dependencies — lightweight, works everywhere
- Full TypeScript support — every response is fully typed
- Structured errors — typed error classes with helper functions
- Curriculum catalog — browse grades, subjects, topics, skills, and standards
- Deterministic generation — pass a
seedfor reproducible content
// List all grades
const grades = await sp.grades.list();
// List skills for a grade/subject
const skills = await sp.skills.list({ grade: "grade-3", subject: "math" });
// Get skill details
const skill = await sp.skills.get("multiply-by-5");
// Find skills by standard
const standards = await sp.standards.list({ framework: "ccss-math" });
import { StudyPlug, isRateLimitError, isNotFoundError } from "studyplug";
try {
const result = await sp.generate({ skill: "add-within-10", count: 5 });
} catch (err) {
if (isRateLimitError(err)) {
console.log(`Rate limited. Retry after ${err.retryAfter}s`);
} else if (isNotFoundError(err)) {
console.log("Skill not found");
}
}
| Method | Description |
|---|---|
sp.generate(params) |
Generate a batch of content items |
sp.generate.single(params) |
Generate a single content item |
sp.grades.list() |
List all grades |
sp.grades.get(slug) |
Get grade details |
sp.subjects.list() |
List all subjects |
sp.subjects.get(slug) |
Get subject details |
sp.topics.list(params?) |
List topics (optionally filtered) |
sp.skills.list(params?) |
List skills (optionally filtered) |
sp.skills.get(slug) |
Get skill details |
sp.standards.list(params?) |
List standards |
sp.standards.get(code) |
Get standard details |
sp.health() |
API health check |
const sp = new StudyPlug({
apiKey: "sp_live_...", // optional for anonymous tier
baseUrl: "https://api.studyplug.org", // default
timeout: 10000, // ms, default 30000
});
StudyPlug.org — free K-5 printable worksheets for math, reading, vocabulary, spelling, and science. Every worksheet is generated by the same API this SDK connects to.
MIT