search & detail sekolah (lebih sigma)
by RFour · Jul 30, 2026 ·javascript
Basically uhh search and detail Indonesian school info's, and uhh, that's it, pretty cool, this one data is more accurate I think.
TeacherSekolahSearchSchool
| 1 | const axios = require('axios'); |
| 2 | |
| 3 | const client = axios.create({ |
| 4 | baseURL: 'https://dapo.kemendikdasmen.go.id', |
| 5 | headers: { |
| 6 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/137.0.0.0 Mobile Safari/537.36', |
| 7 | 'Accept': '*/*' |
| 8 | } |
| 9 | }); |
| 10 | |
| 11 | async function getToken() { |
| 12 | await client.get('/'); |
| 13 | const res = await client.get('/env.js'); |
| 14 | const raw = res.data; |
| 15 | const token = raw.match(/VITE_API_TOKEN["']?\s*:\s*["']([^"']+)["']/)?.[1]; |
| 16 | const url = raw.match(/VITE_STRAPI_URL["']?\s*:\s*["']([^"']+)["']/)?.[1]; |
| 17 | return { token, url }; |
| 18 | } |
| 19 | |
| 20 | function carisekolah(q, cb) { |
| 21 | getToken().then(({ token, url }) => { |
| 22 | client.get(url + '/api/detail-sekolah/search?q=' + encodeURIComponent(q), { |
| 23 | headers: { 'Authorization': 'Bearer ' + token } |
| 24 | }).then(r => { |
| 25 | const data = r.data.data || []; |
| 26 | cb(JSON.stringify(data, null, 2)); |
| 27 | }).catch(() => cb(null)); |
| 28 | }).catch(() => cb(null)); |
| 29 | } |
| 30 | |
| 31 | function infosekolah(npsn, cb) { |
| 32 | getToken().then(({ token, url }) => { |
| 33 | client.get(url + '/api/detail-sekolah?npsn=' + npsn, { |
| 34 | headers: { 'Authorization': 'Bearer ' + token } |
| 35 | }).then(r => { |
| 36 | const data = r.data.data || []; |
| 37 | cb(JSON.stringify(data, null, 2)); |
| 38 | }).catch(() => cb(null)); |
| 39 | }).catch(() => cb(null)); |
| 40 | } |
| 41 | |
| 42 | carisekolah('sman 72 jakarta', console.log); |
| 43 | infosekolah('20100796', console.log); |