scraperjavascript4215
AnimeKai (anikai.org) Web Scraper & Stream Resolver API
Full AnimeKai scraper dengan 7,900+ anime catalog, search, filter genre/status/format, detail, episode list, poster/banner images, dan embed stream player resolver.
Vamz Spectre25 Okt 2026594 baris kode
Jalankan via Terminal / CLI:
# 1. Download file script
curl -sL "https://code.vamxapi.my.id/snippet/raw/anikai" -o anikai.js
# 2. Jalankan script
node anikai.js
Panduan Penggunaan:
curl -sL "https://code.vamxapi.my.id/snippet/raw/anikai" -o anikai.js node anikai.js search "naruto" node anikai.js detail 518 node anikai.js stream "one-piece-5773" 1180
anikai.js(594 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
/**
* AnimeKai (anikai.org) Web Scraper & Stream Resolver API
* Target: https://anikai.org
* Author: Vamz Spectre (VamxAPI)
*
* Capabilities:
* - Full Catalog Indexing: 7,900+ anime titles with automatic in-memory & disk caching.
* - Fast Search & Filter: By title (English, Romaji, Kanji), slug, genre, format, status, year.
* - Latest Releases & Popular Anime charts.
* - Complete Anime Detail: Full synopsis, posters, banners, servers, audio tracks, and episode count.
* - Complete Episode List: Episode numbers, titles, release dates, filler & recap indicators.
* - Stream Resolver: Direct player URL & responsive iframe embed for any episode, server, and audio track (sub/dub).
* - Pure Node.js: Zero external npm dependencies, IPv4-safe network handling.
*
* Download & Run (1:1 Konsisten):
* curl -sL "https://code.vamxapi.my.id/snippet/raw/anikai" -o anikai.js
*
* Usage:
* # 1. Search Anime:
* node anikai.js search "naruto"
* node anikai.js search "one piece" 5
*
* # 2. Latest Updated Anime:
* node anikai.js latest 10
*
* # 3. Popular / Top Rated Anime:
* node anikai.js popular 10
*
* # 4. Anime Detail & Episode List:
* node anikai.js detail "one-piece-5773"
* node anikai.js detail 5773
*
* # 5. Episode List Only:
* node anikai.js episodes 5773
*
* # 6. Stream Player URL & Iframe Embed:
* node anikai.js stream "one-piece-5773" 1180 2 sub
*/
const https = require("https");
const http = require("http");
const fs = require("fs");
const path = require("path");
const { URL } = require("url");
const BASE_URL = "https://anikai.org";
const IMAGE_BASE_URL = "https://img.anikai.org";
const CACHE_FILE_PATH = path.join("/tmp", "anikai_catalog_cache.json");
const CACHE_TTL_MS = 60 * 60 * 1000; // 1 jam TTL
let memoryCatalogCache = null;
let memoryCacheTimestamp = 0;
/**
* Lightweight native HTTP/HTTPS client (IPv4 forced, auto redirect, fast keepalive)
*/
function request(urlStr, options = {}) {
return new Promise((resolve, reject) => {
try {
const parsed = new URL(urlStr);
const isHttps = parsed.protocol === "https:";
const client = isHttps ? https : http;
const req = client.request(parsed, {
method: options.method || "GET",
family: 4,
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,application/json,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.9",
"Referer": BASE_URL + "/",
...options.headers
},
timeout: options.timeout || 15000
}, (res) => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
const redirectUrl = new URL(res.headers.location, urlStr).toString();
return resolve(request(redirectUrl, options));
}
const chunks = [];
res.on("data", chunk => chunks.push(chunk));
res.on("end", () => {
const body = Buffer.concat(chunks).toString("utf-8");
resolve({
status: res.statusCode,
headers: res.headers,
body,
json: () => JSON.parse(body)
});
});
});
req.on("error", (err) => reject(new Error(`AnimeKai Request Error: ${err.message}`)));
req.on("timeout", () => {
req.destroy();
reject(new Error("AnimeKai Request Timeout (15s)"));
});
if (options.body) req.write(options.body);
req.end();
} catch (err) {
reject(err);
}
});
}
/**
* Build image URLs helper
*/
function buildImages(slug, id) {
const fileKey = slug.endsWith(`-${id}`) ? slug : `${slug}-${id}`;
return {
poster: `${IMAGE_BASE_URL}/poster/w_360/h_480/${fileKey}.webp`,
poster_sm: `${IMAGE_BASE_URL}/poster-sm/w_200/h_267/${fileKey}.webp`,
thumb: `${IMAGE_BASE_URL}/thumb/w_128/h_176/${fileKey}.webp`,
banner: `${IMAGE_BASE_URL}/banner/w_1900/h_400/${fileKey}.webp`
};
}
/**
* Normalisasi item anime dari catalog-index.json
*/
function formatAnimeItem(item) {
const slug = item.s || "";
const id = item.i || null;
return {
id: id,
slug: slug,
title: item.n || item.j || slug,
title_english: item.n || null,
title_romaji: item.j || null,
title_kanji: item.na || null,
format: item.f || null,
status: item.st || null,
genres: Array.isArray(item.g) ? item.g : [],
year: item.y || null,
rating: item.r || null,
score: typeof item.sc === "number" ? item.sc : null,
episodes_total: typeof item.tt === "number" ? item.tt : null,
release_date: item.rd || null,
latest_episode_date: item.le || null,
updated_at: item.u || null,
images: buildImages(slug, id),
watch_url: `${BASE_URL}/watch/${slug}/`
};
}
/**
* Fetch dan cache catalog-index.json (in-memory + /tmp)
*/
async function getCatalog(forceRefresh = false) {
const now = Date.now();
if (!forceRefresh && memoryCatalogCache && (now - memoryCacheTimestamp < CACHE_TTL_MS)) {
return memoryCatalogCache;
}
if (!forceRefresh && fs.existsSync(CACHE_FILE_PATH)) {
try {
const stats = fs.statSync(CACHE_FILE_PATH);
if (now - stats.mtimeMs < CACHE_TTL_MS) {
const raw = fs.readFileSync(CACHE_FILE_PATH, "utf-8");
memoryCatalogCache = JSON.parse(raw);
memoryCacheTimestamp = now;
return memoryCatalogCache;
}
} catch {}
}
const res = await request(`${BASE_URL}/catalog-index.json`);
if (res.status !== 200) {
throw new Error(`Gagal memuat catalog-index (HTTP ${res.status})`);
}
const catalog = res.json();
memoryCatalogCache = catalog;
memoryCacheTimestamp = now;
try {
fs.writeFileSync(CACHE_FILE_PATH, JSON.stringify(catalog), "utf-8");
} catch {}
return catalog;
}
/**
* Search anime berdasarkan kata kunci dan filter opsional
*/
async function searchAnime(query, options = {}) {
if (!query || typeof query !== "string" || !query.trim()) {
throw new Error("Parameter query pencarian wajib diisi");
}
const catalog = await getCatalog();
const q = query.trim().toLowerCase();
const limit = Math.max(1, parseInt(options.limit || 20, 10));
const page = Math.max(1, parseInt(options.page || 1, 10));
const genreFilter = options.genre ? options.genre.toLowerCase() : null;
const formatFilter = options.format ? options.format.toLowerCase() : null;
const statusFilter = options.status ? options.status.toLowerCase() : null;
const yearFilter = options.year ? parseInt(options.year, 10) : null;
const matches = [];
for (const item of catalog) {
const titleEn = (item.n || "").toLowerCase();
const titleJp = (item.j || "").toLowerCase();
const titleKanji = (item.na || "").toLowerCase();
const slug = (item.s || "").toLowerCase();
const isMatch = titleEn.includes(q) || titleJp.includes(q) || titleKanji.includes(q) || slug.includes(q);
if (!isMatch) continue;
if (genreFilter && (!item.g || !item.g.some(g => g.toLowerCase() === genreFilter))) {
continue;
}
if (formatFilter && (item.f || "").toLowerCase() !== formatFilter) {
continue;
}
if (statusFilter && (item.st || "").toLowerCase() !== statusFilter) {
continue;
}
if (yearFilter && item.y !== yearFilter) {
continue;
}
matches.push(item);
}
const totalResults = matches.length;
const startIndex = (page - 1) * limit;
const paginated = matches.slice(startIndex, startIndex + limit);
return {
status: true,
creator: "Vamz Spectre",
query: query.trim(),
page: page,
limit: limit,
total_results: totalResults,
total_pages: Math.ceil(totalResults / limit) || 1,
results: paginated.map(formatAnimeItem)
};
}
/**
* Dapatkan anime terbaru (berdasarkan episode terbaru atau update date)
*/
async function getLatest(options = {}) {
const catalog = await getCatalog();
const limit = Math.max(1, parseInt(options.limit || 20, 10));
const page = Math.max(1, parseInt(options.page || 1, 10));
const sorted = [...catalog].sort((a, b) => {
const dateA = a.le || a.u || a.ca || "";
const dateB = b.le || b.u || b.ca || "";
return dateB.localeCompare(dateA);
});
const totalResults = sorted.length;
const startIndex = (page - 1) * limit;
const paginated = sorted.slice(startIndex, startIndex + limit);
return {
status: true,
creator: "Vamz Spectre",
type: "latest",
page: page,
limit: limit,
total_results: totalResults,
results: paginated.map(formatAnimeItem)
};
}
/**
* Dapatkan anime populer / top score
*/
async function getPopular(options = {}) {
const catalog = await getCatalog();
const limit = Math.max(1, parseInt(options.limit || 20, 10));
const page = Math.max(1, parseInt(options.page || 1, 10));
const filtered = catalog.filter(item => typeof item.sc === "number" && item.sc > 0);
filtered.sort((a, b) => (b.sc || 0) - (a.sc || 0));
const totalResults = filtered.length;
const startIndex = (page - 1) * limit;
const paginated = filtered.slice(startIndex, startIndex + limit);
return {
status: true,
creator: "Vamz Spectre",
type: "popular",
page: page,
limit: limit,
total_results: totalResults,
results: paginated.map(formatAnimeItem)
};
}
/**
* Ambil daftar episode anime dari /episodes/${animeId}.json
*/
async function getEpisodes(animeId) {
if (!animeId) {
throw new Error("Parameter animeId wajib diisi");
}
const res = await request(`${BASE_URL}/episodes/${animeId}.json`);
if (res.status !== 200) {
throw new Error(`Daftar episode tidak ditemukan untuk ID ${animeId} (HTTP ${res.status})`);
}
const rawEpisodes = res.json();
const episodes = (Array.isArray(rawEpisodes) ? rawEpisodes : []).map(ep => ({
episode: ep[0],
title: ep[1] || `Episode ${ep[0]}`,
release_date: ep[2] || null,
is_filler: Boolean(ep[3]),
is_recap: Boolean(ep[4])
}));
return {
status: true,
creator: "Vamz Spectre",
anime_id: parseInt(animeId, 10),
total_episodes: episodes.length,
episodes: episodes
};
}
/**
* Dapatkan detail lengkap anime: metadata + synopsis + watch info + full episodes list
*/
async function getDetail(slugOrId) {
if (!slugOrId) {
throw new Error("Parameter slug atau animeId wajib diisi");
}
const catalog = await getCatalog();
let animeEntry = null;
const numericId = parseInt(slugOrId, 10);
if (!isNaN(numericId) && String(numericId) === String(slugOrId).trim()) {
animeEntry = catalog.find(item => item.i === numericId);
} else {
const cleanSlug = String(slugOrId).trim().replace(/^\/watch\/|\/$/g, "");
animeEntry = catalog.find(item => item.s === cleanSlug || item.s === cleanSlug.toLowerCase());
}
const slug = animeEntry ? animeEntry.s : String(slugOrId).trim().replace(/^\/watch\/|\/$/g, "");
const watchPageRes = await request(`${BASE_URL}/watch/${slug}/`);
if (watchPageRes.status !== 200) {
throw new Error(`Halaman anime tidak ditemukan untuk slug "${slug}" (HTTP ${watchPageRes.status})`);
}
const html = watchPageRes.body;
const dataId = (html.match(/data-id=([^\s>]+)/) || [])[1];
const dataSeal = (html.match(/data-seal=([^\s>]+)/) || [])[1];
const dataPlayer = (html.match(/data-player=([^\s>]+)/) || [])[1] || "https://play.anikai.org";
const dataServerDefault = (html.match(/data-server-default=([^\s>]+)/) || [])[1] || "2";
const rawServers = [...html.matchAll(/data-server=([^\s>]+)/g)].map(m => m[1]);
const availableServers = [...new Set(rawServers)];
const rawAudios = [...html.matchAll(/data-audio=([^\s>]+)/g)].map(m => m[1]);
const availableAudios = [...new Set(rawAudios)];
const synopsisMatch = html.match(/<p id=synopsis-text[^>]*>([\s\S]*?)<\/p>/i);
const synopsis = synopsisMatch ? synopsisMatch[1].replace(/<[^>]+>/g, "").trim() : null;
const id = (animeEntry && animeEntry.i) ? animeEntry.i : (dataId ? parseInt(dataId, 10) : null);
let episodesData = [];
if (id) {
try {
const epRes = await getEpisodes(id);
episodesData = epRes.episodes;
} catch {}
}
const baseFormatted = animeEntry ? formatAnimeItem(animeEntry) : {
id: id,
slug: slug,
title: (html.match(/<title>([^<]+)<\/title>/) || [])[1]?.replace(/\s*\|\s*AnimeKai.*$/, "").trim() || slug,
images: buildImages(slug, id || 0),
watch_url: `${BASE_URL}/watch/${slug}/`
};
return {
status: true,
creator: "Vamz Spectre",
data: {
...baseFormatted,
synopsis: synopsis,
player: {
player_host: dataPlayer,
seal: dataSeal || null,
server_default: dataServerDefault,
available_servers: availableServers.length > 0 ? availableServers : ["1", "2", "3"],
available_audios: availableAudios.length > 0 ? availableAudios : ["sub", "dub"]
},
episodes: episodesData
}
};
}
/**
* Resolve direct video player URL dan iframe embed
*/
async function getStream(slugOrId, episodeNumber = 1, server = null, audio = "sub") {
if (!slugOrId) {
throw new Error("Parameter slug atau animeId wajib diisi");
}
const ep = parseInt(episodeNumber || 1, 10);
const detailRes = await getDetail(slugOrId);
const anime = detailRes.data;
if (!anime.player || !anime.player.seal) {
throw new Error("Video player seal tidak tersedia untuk judul ini (kemungkinan masih preview)");
}
const selectedServer = server ? String(server) : (anime.player.server_default || "2");
const selectedAudio = (audio && audio.toLowerCase() === "dub") ? "dub" : "sub";
const playerHost = anime.player.player_host || "https://play.anikai.org";
const streamHash = `${anime.player.seal}.${ep}.${selectedServer}.${selectedAudio}`;
const streamUrl = `${playerHost}/watch#${streamHash}`;
const iframeHtml = `<iframe src="${streamUrl}" title="${anime.title} Episode ${ep}" allow="autoplay; fullscreen; encrypted-media; picture-in-picture" allowfullscreen frameborder="0" width="100%" height="100%"></iframe>`;
const episodeItem = anime.episodes.find(e => e.episode === ep) || null;
return {
status: true,
creator: "Vamz Spectre",
data: {
anime_id: anime.id,
slug: anime.slug,
title: anime.title,
episode: ep,
episode_info: episodeItem,
server: selectedServer,
audio: selectedAudio,
stream_url: streamUrl,
iframe_embed: iframeHtml,
player_options: {
servers: anime.player.available_servers,
audios: anime.player.available_audios
}
}
};
}
// ==========================================
// CLI Runner (1:1 Konsisten dengan download)
// ==========================================
if (require.main === module) {
const args = process.argv.slice(2);
const command = args[0] ? args[0].toLowerCase() : "";
if (command === "search") {
const query = args[1];
const limit = args[2] ? parseInt(args[2], 10) : 20;
if (!query) {
console.error(JSON.stringify({
status: false,
creator: "Vamz Spectre",
error: "Harap masukkan kata kunci pencarian. Contoh: node anikai.js search \"naruto\""
}, null, 2));
process.exit(1);
}
searchAnime(query, { limit })
.then(res => console.log(JSON.stringify(res, null, 2)))
.catch(err => {
console.error(JSON.stringify({ status: false, creator: "Vamz Spectre", error: err.message }, null, 2));
process.exit(1);
});
} else if (command === "latest") {
const limit = args[1] ? parseInt(args[1], 10) : 20;
getLatest({ limit })
.then(res => console.log(JSON.stringify(res, null, 2)))
.catch(err => {
console.error(JSON.stringify({ status: false, creator: "Vamz Spectre", error: err.message }, null, 2));
process.exit(1);
});
} else if (command === "popular") {
const limit = args[1] ? parseInt(args[1], 10) : 20;
getPopular({ limit })
.then(res => console.log(JSON.stringify(res, null, 2)))
.catch(err => {
console.error(JSON.stringify({ status: false, creator: "Vamz Spectre", error: err.message }, null, 2));
process.exit(1);
});
} else if (command === "detail") {
const slugOrId = args[1];
if (!slugOrId) {
console.error(JSON.stringify({
status: false,
creator: "Vamz Spectre",
error: "Harap masukkan slug atau ID anime. Contoh: node anikai.js detail \"one-piece-5773\""
}, null, 2));
process.exit(1);
}
getDetail(slugOrId)
.then(res => console.log(JSON.stringify(res, null, 2)))
.catch(err => {
console.error(JSON.stringify({ status: false, creator: "Vamz Spectre", error: err.message }, null, 2));
process.exit(1);
});
} else if (command === "episodes") {
const animeId = args[1];
if (!animeId) {
console.error(JSON.stringify({
status: false,
creator: "Vamz Spectre",
error: "Harap masukkan animeId. Contoh: node anikai.js episodes 5773"
}, null, 2));
process.exit(1);
}
getEpisodes(animeId)
.then(res => console.log(JSON.stringify(res, null, 2)))
.catch(err => {
console.error(JSON.stringify({ status: false, creator: "Vamz Spectre", error: err.message }, null, 2));
process.exit(1);
});
} else if (command === "stream") {
const slugOrId = args[1];
const episode = args[2] ? parseInt(args[2], 10) : 1;
const server = args[3] || null;
const audio = args[4] || "sub";
if (!slugOrId) {
console.error(JSON.stringify({
status: false,
creator: "Vamz Spectre",
error: "Harap masukkan slug atau animeId. Contoh: node anikai.js stream \"one-piece-5773\" 1180"
}, null, 2));
process.exit(1);
}
getStream(slugOrId, episode, server, audio)
.then(res => console.log(JSON.stringify(res, null, 2)))
.catch(err => {
console.error(JSON.stringify({ status: false, creator: "Vamz Spectre", error: err.message }, null, 2));
process.exit(1);
});
} else {
console.log(JSON.stringify({
status: false,
creator: "Vamz Spectre",
message: "AnimeKai (anikai.org) Web Scraper & Stream Resolver API",
download: 'curl -sL "https://code.vamxapi.my.id/snippet/raw/anikai" -o anikai.js',
commands: {
search: "node anikai.js search <query> [limit]",
latest: "node anikai.js latest [limit]",
popular: "node anikai.js popular [limit]",
detail: "node anikai.js detail <slug_or_id>",
episodes: "node anikai.js episodes <anime_id>",
stream: "node anikai.js stream <slug_or_id> [episode] [server] [audio]"
},
examples: [
'node anikai.js search "naruto"',
'node anikai.js latest 10',
'node anikai.js popular 10',
'node anikai.js detail "one-piece-5773"',
'node anikai.js episodes 5773',
'node anikai.js stream "one-piece-5773" 1180 2 sub'
]
}, null, 2));
}
}
module.exports = {
searchAnime,
getLatest,
getPopular,
getDetail,
getEpisodes,
getStream,
getCatalog
};