Created
June 30, 2025 13:39
-
-
Save ZTRdiamond/0c5ae09c876d6539ebaec8190e76cfe7 to your computer and use it in GitHub Desktop.
wattpad search, web dongeng anak esempe🤓
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios from "axios"; | |
| async function wattpadSearch(query, page = 1, limit = 10) { | |
| try { | |
| return new Promise(async (resolve, reject) => { | |
| if (!query) return reject("missing query input!"); | |
| if (!Number.isInteger(limit)) return reject("invalid limit input!"); | |
| const response = await axios.get('https://www.wattpad.com/v4/search/stories/', { | |
| params: { | |
| query, | |
| limit, | |
| mature: true, | |
| fields: | |
| "stories(id,title,voteCount,readCount,commentCount,description,mature,completed,cover,url,numParts,isPaywalled,paidModel,length,language(id),user(name),lastPublishedPart(createDate),promoted,sponsor(name,avatar),tags,tracking(clickUrl,impressionUrl,thirdParty(impressionUrls,clickUrls)),contest(endDate,ctaLabel,ctaURL)),total,tags,nextUrl", | |
| offset: page | |
| }, | |
| headers: { | |
| 'authority': 'www.wattpad.com', | |
| 'accept': 'application/json, text/javascript, */*; q=0.01', | |
| 'user-agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36' | |
| } | |
| }); | |
| const data = response.data; | |
| if (!data?.stories?.length) return reject("no result found!"); | |
| return resolve({ | |
| success: true, | |
| result: data | |
| }); | |
| }); | |
| } catch (e) { | |
| return { | |
| success: false, | |
| error: e.message || e | |
| }; | |
| } | |
| } | |
| export default wattpadSearch; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
📚
wattpadSearch(query, page?, limit?)Fungsi ini digunakan untuk melakukan pencarian cerita dari Wattpad melalui endpoint API publik (non-dokumentasi resmi). Mendukung filter konten dewasa, pagination, dan detail metadata cerita.
✅ Fitur Utama
pagemature🧪 Contoh Penggunaan
🧩 Parameter
querystringpagenumberoffset: 1, page ke-2 =offset: 2, dst.limitnumber10, maksimal umum30.📥 Response Output
Jika sukses:
Jika gagal:
🛠️ Struktur
fieldsyang Diambil🧠 Tips
limit=30dan kombinasipageuntuk navigasi.story.mature === true.