Render the assessment inline on your page using the @edpire/sdk JavaScript SDK. No redirect — the learner stays on your site.Step 1 — Mint an embed token (server-side only)
// On your server — never expose your API key to the browserconst res = await fetch("https://app.edpire.com/api/v1/embed/token", { method: "POST", headers: { Authorization: `Bearer ${process.env.EDPIRE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ assessment_id: "asmt_xxx", learner_ref: "your-user-id", }),})const { data } = await res.json()// data.token — pass this to the browser
Step 2 — Mount the SDK in the browser
The CDN bundle (cdn.edpire.com) is coming soon. Until then, use the npm package (npm install @edpire/sdk).
Build a fully custom learner experience (Duolingo-style flows, flashcard drills, practice modes) using Edpire’s SDK components for rendering and the /check endpoint for real-time per-question grading.Step 1 — Fetch the assessment
import { flattenAssessment } from "@edpire/sdk"const steps = flattenAssessment(assessment)// steps[0] = { exerciseId, questionId, content, points, sequenceNumber, index }
Step 3 — Render questions with EdpireQuestion
import { EdpireQuestion } from "@edpire/sdk/react"<EdpireQuestion content={step.content} onAnswersChange={setAnswers} feedback={feedback} dir="ltr"/>
Step 4 — Grade each question via your backend proxy
// Your backend proxies this to Edpire (keeps API key server-side)const result = await fetch("/api/edpire/check", { method: "POST", body: JSON.stringify({ assessment_id: assessmentId, exercise_id: step.exerciseId, question_id: step.questionId, answers: currentAnswers, learner_ref: userId, session_id: sessionId, // UUID, generated once per attempt }),}).then((r) => r.json())// result.data = { correct, score, max_score, feedback }
Step 5 — Submit the full attempt when doneThe /check endpoint is stateless and does not create submission records. After all questions, submit the full answer set via POST /assessments/{id}/submit.
Rate limiting: Each (session_id, question_id) pair is limited to 3 checks per hour (configurable per org). Generate a fresh session_id per attempt.
When to use: Custom UX (Duolingo-style, flashcards, hearts/lives), immediate per-question feedback.
Your server collects answers in whatever UI you build, then submits the full answer set to Edpire for grading. No Edpire UI or SDK involved at all.Step 1 — Fetch assessment content
import { EdpireClient } from "@edpire/sdk/client"const client = new EdpireClient({ apiKey: process.env.EDPIRE_API_KEY! })const assessment = await client.getAssessment("assessment-uuid")// assessment.exercises[].questions[].content_ast — render in your own UI
Step 2 — Collect answers in your UIBuild your own question rendering. The answers must match this structure: