Email ảo bảo mật để nhận OTP
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
Đối với tên miền riêng tư, truyền key qua query parameter hoặc header:
# Query parameter
curl "https://api.otpmail.online/api/test@yourdomain.com?api_key=sk_live_abc123..."
# Hoặc HTTP header (Khuyên dùng)
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 từ Tên miền Công khai
res = requests.get("https://api.otpmail.online/api/test@otpmail.online")
# Lấy email từ Tên miền Riêng tư (yêu cầu API Key)
headers = {"x-api-key": "sk_live_abc123..."}
res = requests.get("https://api.otpmail.online/api/test@yourdomain.com", headers=headers)
data = res.json()
if data["success"]:
print(f"OTP: {data['otp']}")
print(f"From: {data['mail']['sender']}")
else:
print("Chưa có email")
JavaScript
// Lấy email từ Tên miền Công khai
let res = await fetch("https://api.otpmail.online/api/test@otpmail.online");
// Lấy email từ Tên miền Riêng tư (yêu cầu API Key)
res = await fetch("https://api.otpmail.online/api/test@yourdomain.com", {
headers: { "x-api-key": "sk_live_abc123..." }
});
const data = await res.json();
if (data.success) {
console.log(`OTP: ${data.otp}`);
console.log(`From: ${data.mail.sender}`);
}
cURL
# Lấy email từ Tên miền Công khai
curl -s https://api.otpmail.online/api/test@otpmail.online | jq .
# Lấy email từ Tên miền Riêng tư
curl -H "x-api-key: sk_live_abc123..." https://api.otpmail.online/api/test@yourdomain.com | jq .