Tích hợp OTPMail vào ứng dụng của bạn
Base URL
https://api.otpmail.online
/api/{email}
Lấy email mới nhất của một địa chỉ email cụ thể.
Tham số
email
string
bắt buộc
Địa chỉ email đầy đủ (ví dụ: test@otpmail.online)
Tham số query
html
boolean
tùy chọn
Thêm ?html=true để nhận nội dung HTML gốc của email
Ví dụ
curl https://api.otpmail.online/api/test@otpmail.online
Phản hồi
{
"success": true,
"mail": {
"sender": "noreply@example.com",
"subject": "Your verification code",
"content": "Your OTP code is 123456",
"time": "02:30:00"
},
"otp": "123456"
}
Khi hòm thư trống hoặc đã hết hạn, API có thể trả HTTP 200 với success: false.
{
"success": false,
"error": "Đợi thư..."
}
Tên miền Công khai
Hiển thị trên website và API /api/domains. Ai cũng có thể đọc email qua API mà không cần xác thực.
Tên miền Riêng tư
Không hiển thị công khai. Cần API Key để truy cập email. Khi bạn thêm domain và chọn "API Key riêng tư", hệ thống sẽ cấp cho bạn 1 key gắn với domain đó.
Cách dùng API Key
Truyền key qua query parameter hoặc header:
# Query parameter
curl https://api.otpmail.online/api/test@yourdomain.com?apikey=sk_live_abc123...
# Hoặc HTTP header
curl -H "x-api-key: sk_live_abc123..." https://api.otpmail.online/api/test@yourdomain.com
/api/domains
Lấy danh sách tất cả domain đang hoạt động trên hệ thống.
Ví dụ
curl https://api.otpmail.online/api/domains
Phản hồi
{
"success": true,
"domains": [
"otpmail.online",
"cubongman.online",
"bongman.shop"
]
}
| Mã | Ý nghĩa |
|---|---|
200 |
Thành công; hòm thư trống có thể trả success=false trong phản hồi 200 |
404 |
Endpoint không tồn tại hoặc route không được hỗ trợ |
429 |
Quá giới hạn rate limit |
500 |
Lỗi server |
Python
import requests
# Lấy email
email = "test123@otpmail.online"
res = requests.get(f"https://api.otpmail.online/api/{email}")
data = res.json()
if data["success"]:
print(f"OTP: {data['otp']}")
print(f"From: {data['mail']['sender']}")
else:
print("Chưa có email")
JavaScript
const email = "test123@otpmail.online";
const res = await fetch(`https://api.otpmail.online/api/${email}`);
const data = await res.json();
if (data.success) {
console.log(`OTP: ${data.otp}`);
console.log(`From: ${data.mail.sender}`);
}
cURL
# Lấy email mới nhất
curl -s https://api.otpmail.online/api/test@otpmail.online | jq .
# Lấy danh sách domain
curl -s https://api.otpmail.online/api/domains | jq .