rynn-k / gists
akunlama.js javascript
const axios = require('axios');
const cheerio = require('cheerio');
const { uniqueNamesGenerator, adjectives, animals } = require('unique-names-generator');

class AkunLama {
    constructor() {
        this.inst = axios.create({
            baseURL: 'https://akunlama.com/api/v1',
            headers: {
                origin: 'https://akunlama.com',
                referer: 'https://akunlama.com/inbox',
                'user-agent': 'Mozilla/5.0 (Linux; Android 15; SM-F958 Build/AP3A.240905.015) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.86 Mobile Safari/537.36'
            }
        });
    }
    
    async get(prefix) {
        try {
            if (!prefix) {
                prefix = uniqueNamesGenerator({
                    dictionaries: [adjectives, animals],
                    separator: '',
                    length: 2,
                    style: 'lowerCase'
                }) + Math.floor(Math.random() * 1000);
            }
            
            const { data } = await this.inst.get(`/mail/list?recipient=${prefix}`);
            if (!data || data.length === 0) return {
                email: `${prefix}@akunlama.com`,
                emails: data
            };
            
            return {
                email: `${prefix}@akunlama.com`,
                emails: await Promise.all(data.map(async (mail) => {
                    const { data: html } = await this.inst.get(`/mail/getHtml?region=${mail.storage.region}&key=${mail.storage.key}`);
                    const $ = cheerio.load(html);
                    
                    $('script, style').remove();
                    
                    return {
                        subject: mail.message.headers.subject,
                        from: mail.message.headers.from,
                        text: $('body').text().replace(/\s+/g, ' ').trim(),
                        timestamp: mail.timestamp
                    };
                }))
            };
        } catch (error) {
            throw new Error(error.message);
        }
    }
}

// Usage:
const akun = new AkunLama();
akun.get().then(console.log);
2126 bytes ยท Updated Feb 27, 2026