Scraperjavascript134
Kahoot Quiz Answers Extractor & Search Scraper
Ekstrak seluruh pertanyaan, pilihan ganda, dan kunci jawaban dari Kahoot! secara instan via UUID kuis, link kuis, link challenge, atau pencarian judul kuis.
Vamx11 Okt 2026178 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/kahoot-answers-scraper" -o kahoot-answers-scraper.js
# 2. Jalankan script
node kahoot-answers-scraper.js
kahoot-answers-scraper.js(178 lines)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/**
* Kahoot Quiz Answers Extractor & Search API
* Scrapes questions, choices, correct answers, media, time limits by:
* - Direct Kahoot Quiz UUID / URL
* - Kahoot Challenge URL / Challenge ID / PIN
* - Search query string
*
* Author: Vamz Spectre / VamxAPI
*/
const DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36";
const KAHOOT_REST_API = "https://create.kahoot.it/rest/kahoots";
const KAHOOT_CHALLENGE_API = "https://kahoot.it/rest/challenges";
function cleanText(text) {
if (!text || typeof text !== "string") return "";
return text.replace(/<[^>]+>/g, "").trim();
}
/**
* Ekstraksi Quiz UUID dari input (mendukung URL challenge, URL details, atau UUID langsung)
*/
async function resolveQuizUuid(input) {
if (!input || typeof input !== "string") return "";
const trimmed = input.trim();
// 1. Jika URL challenge (contoh: https://kahoot.it/challenge/01830802?challenge-id=90bf5879...)
if (trimmed.includes("challenge")) {
const challengeIdMatch = trimmed.match(/challenge-id=([a-f0-9\-_]+)/i);
const challengeId = challengeIdMatch ? challengeIdMatch[1] : null;
if (challengeId) {
try {
const res = await fetch(`${KAHOOT_CHALLENGE_API}/${challengeId}`, {
headers: { "User-Agent": DEFAULT_USER_AGENT, "Accept": "application/json" }
});
if (res.ok) {
const data = await res.json();
if (data.quizId) return data.quizId;
}
} catch {}
}
}
// 2. Deteksi UUID standar v4 (8-4-4-4-12)
const uuidRegex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
const match = trimmed.match(uuidRegex);
return match ? match[0] : trimmed;
}
/**
* Mengambil soal dan kunci jawaban dari Kahoot kuis
* @param {string} quizIdOrUrl - UUID kuis, link kuis, atau link challenge
* @param {object} options - Opsi timeout & user-agent
*/
async function getQuizAnswers(quizIdOrUrl, options = {}) {
const uuid = await resolveQuizUuid(quizIdOrUrl);
if (!uuid) {
throw new Error("Valid Kahoot Quiz UUID, URL, or Challenge URL is required");
}
const timeoutMs = options.timeout || 15000;
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
try {
const url = `${KAHOOT_REST_API}/${uuid}`;
const res = await fetch(url, {
headers: {
"User-Agent": options.userAgent || DEFAULT_USER_AGENT,
"Accept": "application/json"
},
signal: controller.signal
});
if (!res.ok) {
if (res.status === 404) {
throw new Error("Kahoot quiz not found or is set to Private (HTTP 404)");
}
throw new Error(`Failed to fetch Kahoot quiz data (HTTP ${res.status})`);
}
const data = await res.json();
const questions = (data.questions || []).map((q, index) => {
const choices = (q.choices || []).map(c => ({
answer: cleanText(c.answer),
correct: Boolean(c.correct)
}));
const correctAnswers = choices.filter(c => c.correct).map(c => c.answer);
return {
number: index + 1,
question: cleanText(q.question || q.title || ""),
type: q.type || "quiz",
time_limit_ms: q.time || 20000,
points: q.pointsMultiplier ?? 1,
image_url: q.image || null,
choices,
correct_answers: correctAnswers
};
});
return {
success: true,
uuid: data.uuid || uuid,
title: data.title || "",
description: data.description || "",
creator_username: data.creator_username || "",
total_questions: questions.length,
cover_image: data.cover || null,
questions
};
} finally {
clearTimeout(timeoutId);
}
}
/**
* Mencari kuis Kahoot berdasarkan keyword / judul kuis
* @param {string} query - Kata kunci / judul kuis
* @param {object} options - Opsi limit dan timeout
*/
async function searchQuiz(query, options = {}) {
if (!query || typeof query !== "string") {
throw new Error("Search query string is required");
}
const limit = options.limit || 5;
const timeoutMs = options.timeout || 15000;
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
try {
const url = `${KAHOOT_REST_API}/?query=${encodeURIComponent(query)}&limit=${limit}`;
const res = await fetch(url, {
headers: {
"User-Agent": options.userAgent || DEFAULT_USER_AGENT,
"Accept": "application/json"
},
signal: controller.signal
});
if (!res.ok) {
throw new Error(`Failed to search Kahoot quizzes (HTTP ${res.status})`);
}
const data = await res.json();
const entities = data.entities || [];
const results = entities.map(item => {
const card = item.card || {};
return {
uuid: card.uuid || "",
title: card.title || "",
description: card.description || "",
creator_username: card.creator_username || "",
number_of_questions: card.number_of_questions || 0,
cover_image: card.cover || null,
details_url: `https://create.kahoot.it/details/${card.uuid}`
};
});
return {
success: true,
query,
total_results: results.length,
results
};
} finally {
clearTimeout(timeoutId);
}
}
if (typeof module !== "undefined" && module.exports) {
module.exports = { getQuizAnswers, searchQuiz };
}