📨 Email Temp API Documentation

RESTful API untuk Integrasi Bot & Aplikasi

Base URL: https://email-temp.muhfikri-us.workers.dev

🚀 Quick Start

Email Temp menyediakan API sederhana untuk mengakses inbox temporary email. Cocok untuk integrasi dengan bot Telegram, Discord, atau aplikasi lainnya.

💡 Catatan: Semua endpoint menggunakan CORS headers, sehingga bisa dipanggil dari browser atau aplikasi manaun.

📬 Endpoints

GET /emails

Mengambil daftar email yang masuk (terbaru duluan)

Query Parameters:

limit integer Jumlah maksimal email yang diambil (default: 50)

Response Example:

JSON
cURL
Python
JavaScript
{
  "status": "success",
  "data": [
    {
      "id": 1,
      "sender": "noreply@example.com",
      "toAddress": "test@domain.kamu",
      "subject": "Welcome Email",
      "receivedAt": "2026-01-25T03:00:00.000Z",
      "readAt": null
    }
  ],
  "unreadCount": 5
}
curl https://email-temp.muhfikri-us.workers.dev/emails?limit=10
import requests

response = requests.get('https://email-temp.muhfikri-us.workers.dev/emails?limit=10')
data = response.json()

for email in data['data']:
    print(f"From: {email['sender']}")
    print(f"Subject: {email['subject']}")
    print(f"Received: {email['receivedAt']}")
    print("---")
fetch('https://email-temp.muhfikri-us.workers.dev/emails?limit=10')
  .then(res => res.json())
  .then(data => {
    data.data.forEach(email => {
      console.log(`From: ${email.sender}`);
      console.log(`Subject: ${email.subject}`);
    });
  });
GET /emails/:id

Mengambil detail lengkap email termasuk body content

Path Parameters:

id integer ID email yang ingin diambil

Response Example:

JSON
cURL
{
  "status": "success",
  "data": {
    "id": 1,
    "sender": "noreply@example.com",
    "toAddress": "test@domain.kamu",
    "subject": "Welcome Email",
    "body": "Hi there!\n\nWelcome to our service...",
    "receivedAt": "2026-01-25T03:00:00.000Z",
    "readAt": null
  }
}
curl https://email-temp.muhfikri-us.workers.dev/emails/1
GET /emails/address/:email

Filter email berdasarkan alamat email tujuan (toAddress)

Path Parameters:

email string Alamat email yang ingin difilter (URL encoded)

Response Example:

JSON
cURL
Python
{
  "status": "success",
  "email": "test@domain.kamu",
  "count": 3,
  "data": [
    {
      "id": 5,
      "sender": "noreply@github.com",
      "toAddress": "test@domain.kamu",
      "subject": "Verify your email",
      "body": "...",
      "receivedAt": "2026-01-25T04:00:00.000Z"
    },
    ...
  ]
}
curl https://email-temp.muhfikri-us.workers.dev/emails/address/test@domain.kamu
import requests

email = "test@domain.kamu"
response = requests.get(
    f'https://email-temp.muhfikri-us.workers.dev/emails/address/{email}'
)

data = response.json()
print(f"Found {data['count']} emails for {data['email']}")

for email in data['data']:
    print(f"From: {email['sender']}")
    print(f"Subject: {email['subject']}")
    print("---")
POST /generate-email

Generate email temporary baru

Request Body:

customName string (optional) Nama custom untuk email (jika tidak diisi akan random)
domain string (required) Domain yang ingin digunakan

Example:

cURL
Python
JavaScript
curl -X POST https://email-temp.muhfikri-us.workers.dev/generate-email \
  -H "Content-Type: application/json" \
  -d '{
    "customName": "mybot",
    "domain": "domain.kamu"
  }'
import requests

data = {
    "customName": "mybot",
    "domain": "domain.kamu"
}

response = requests.post(
    'https://email-temp.muhfikri-us.workers.dev/generate-email',
    json=data
)

result = response.json()
print(f"Email created: {result['data']['emailAddress']}")
fetch('https://email-temp.muhfikri-us.workers.dev/generate-email', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    customName: 'mybot',
    domain: 'domain.kamu'
  })
})
.then(res => res.json())
.then(data => console.log('Email:', data.data.emailAddress));
DELETE /emails/:id

Menghapus email tertentu

Example:

curl -X DELETE https://email-temp.muhfikri-us.workers.dev/emails/1

🤖 Integrasi dengan Bot

Telegram Bot Example

Contoh sederhana integrasi dengan Telegram bot menggunakan Python:

import requests
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes

API_URL = "https://email-temp.muhfikri-us.workers.dev"

async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
    # Generate email baru
    response = requests.post(f"{API_URL}/generate-email", json={
        "domain": "domain.kamu"
    })
    
    if response.json()["status"] == "success":
        email = response.json()["data"]["emailAddress"]
        await update.message.reply_text(
            f"✅ Email temporary kamu:\n\n`{email}`\n\n"
            "Gunakan /check untuk cek inbox!",
            parse_mode="Markdown"
        )

async def check(update: Update, context: ContextTypes.DEFAULT_TYPE):
    # Cek inbox
    response = requests.get(f"{API_URL}/emails?limit=5")
    emails = response.json()["data"]
    
    if len(emails) == 0:
        await update.message.reply_text("📭 Inbox masih kosong")
    else:
        message = "📬 *Inbox Kamu:*\n\n"
        for email in emails:
            message += f"✉️ From: {email['sender']}\n"
            message += f"📝 Subject: {email['subject']}\n"
            message += f"🕐 {email['receivedAt']}\n\n"
        
        await update.message.reply_text(message, parse_mode="Markdown")

# Setup bot
app = Application.builder().token("YOUR_BOT_TOKEN").build()
app.add_handler(CommandHandler("start", start))
app.add_handler(CommandHandler("check", check))
app.run_polling()

Discord Bot Example

Contoh integrasi dengan Discord bot:

import discord
import requests

API_URL = "https://email-temp.muhfikri-us.workers.dev"
client = discord.Client(intents=discord.Intents.default())

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    
    if message.content == '!email':
        # Generate email
        response = requests.post(f"{API_URL}/generate-email", json={
            "domain": "domain.kamu"
        })
        data = response.json()
        
        if data["status"] == "success":
            email = data["data"]["emailAddress"]
            await message.channel.send(f"✅ Your temp email: `{email}`")
    
    elif message.content == '!inbox':
        # Check inbox
        response = requests.get(f"{API_URL}/emails?limit=5")
        emails = response.json()["data"]
        
        if not emails:
            await message.channel.send("📭 Inbox is empty")
        else:
            msg = "**📬 Your Inbox:**\n\n"
            for email in emails:
                msg += f"From: {email['sender']}\n"
                msg += f"Subject: {email['subject']}\n---\n"
            await message.channel.send(msg)

client.run('YOUR_BOT_TOKEN')

💡 Tips & Best Practices

🔄 Polling untuk Email Baru
Untuk bot yang perlu memonitor email baru, gunakan polling dengan interval 10-15 detik:
import time
last_check_time = None

while True:
    emails = get_emails()
    new_emails = [e for e in emails if e['receivedAt'] > last_check_time]
    
    if new_emails:
        # Process new emails
        for email in new_emails:
            notify_user(email)
    
    last_check_time = datetime.now().isoformat()
    time.sleep(15)  # Check every 15 seconds
⚠️ Rate Limiting
Untuk menghindari overload, usahakan tidak melakukan request lebih dari 1 request per detik.

🔗 Useful Links