const axios = require('axios'); async function getStickerLyPack(url, needRelation = true) { const stickerId = url.match(/sticker\.ly\/s\/([A-Z0-9]+)/i) || url.match(/sticker\.ly\/([A-Z0-9]+)/i); if (!stickerId) { throw new Error('Invalid sticker.ly URL. Could not extract ID.'); } console.log(`Extracted sticker ID: ${stickerId}`); try { const response = await axios.get(`https://api.sticker.ly/v4/stickerPack/${stickerId}`, { params: { needRelation }, headers: { 'User-Agent': 'androidapp.stickerly/3.31.0 (M2006C3LG; U; Android 29; in-ID; id;)' } }); return response.data; } catch (error) { console.error('Error fetching sticker pack:', error.message); throw error; } } async function getSearchStickerLy(keyword = 'jokowi') { try { const response = await axios.post( 'https://api.sticker.ly/v4/stickerPack/smartSearch', { keyword, enabledKeywordSearch: true, filter: { extendSearchResult: false, sortBy: 'RECOMMENDED', languages: ['ALL'], minStickerCount: 5, searchBy: 'ALL', stickerType: 'ALL', }, }, { headers: { 'User-Agent': 'androidapp.stickerly/3.31.0 (M2006C3LG; U; Android 29; in-ID; id;)', 'Content-Type': 'application/json', }, } ); return response.data; } catch (error) { console.error( 'Error:', error.response?.data || error.message ); throw error; } } /* // contoh penggunaan getSearchStickerLy('jokowi') .then((data) => { console.log(data); }) .catch((err) => { console.error(err); }); */ // Contoh penggunaan getStickerLyPack('https://sticker.ly/s/PMXSZM', true) .then(result => { console.log('Sticker ID:', result.id); console.log('Sticker Data:', result.data); }) .catch(err => console.error(err));