📚 Tài Liệu API

Hướng dẫn chi tiết cách sử dụng API Mail Reader để tích hợp vào ứng dụng của bạn

🚀 Giới Thiệu

Mail Reader API cung cấp các endpoint để kiểm tra domain, lấy danh sách email và quản lý hòm thư tạm thời. Tất cả các API đều miễn phí và không yêu cầu authentication.

Miễn Phí 100%
Không giới hạn số lượng request, hoàn toàn miễn phí
🔒
Không cần API key hay authentication
📊
JSON Response
Tất cả response đều ở định dạng JSON
🌐
CORS Enabled
Hỗ trợ gọi API từ bất kỳ domain nào

🌐 Base URL

https://thanhori.click/docthumaildomain/

📡 API Endpoints

1. Kiểm Tra Trạng Thái Domain

GET ?action=check_domain&domain={domain}

Kiểm tra xem domain có hỗ trợ nhận email hay không. API sẽ check MX record của domain.

Parameters:

Tham số Kiểu Bắt buộc Mô tả
action string Phải là "check_domain"
domain string Tên domain cần kiểm tra (vd: example.com)

Ví dụ Request:

JavaScript
fetch('https://thanhori.click/docthumaildomain/?action=check_domain&domain=thanhori.click')
  .then(response => response.json())
  .then(data => console.log(data));

Response (Success - Domain Online):

JSON
{
  "result": "online",
  "message": "Domain có thể nhận email"
}

Response (Domain Offline):

JSON
{
  "result": "offline",
  "message": "Domain không hỗ trợ nhận email"
}

Response (Error):

JSON
{
  "result": "error",
  "message": "Domain không hợp lệ"
}

2. Lấy Danh Sách Tất Cả Domains

GET ?action=fetch_domains

Lấy danh sách tất cả các domain có sẵn từ hệ thống và lưu vào file domain.json.

⚠️ Lưu ý

API này nên được gọi tối đa 1 lần/giờ để tránh tải server. Sử dụng API get_cached_domains để lấy dữ liệu đã cache.

Ví dụ Request:

JavaScript
fetch('https://thanhori.click/docthumaildomain/?action=fetch_domains')
  .then(response => response.json())
  .then(data => console.log(data));

Response (Success):

JSON
{
  "success": true,
  "count": 150,
  "domains": [
    "domain1.com",
    "domain2.net",
    "domain3.org",
    ...
  ]
}

3. Lấy Danh Sách Domains Từ Cache

GET ?action=get_cached_domains

Lấy danh sách domains từ file cache (domain.json) mà không cần gọi API external.

💡 Khuyến nghị

Sử dụng API này thay vì fetch_domains để giảm tải server. Dữ liệu được cập nhật tự động mỗi 1 giờ.

Ví dụ Request:

cURL
curl https://thanhori.click/docthumaildomain/?action=get_cached_domains

Response (Success):

JSON
{
  "success": true,
  "domains": [
    "thanhori.click",
    "example.com",
    "test.net",
    ...
  ]
}

4. Lấy Danh Sách Email

GET ?action=get_emails&email={email}&page={page}&limit={limit}

Lấy danh sách email trong hòm thư của một địa chỉ email cụ thể. Hỗ trợ phân trang.

Parameters:

Tham số Kiểu Bắt buộc Mô tả
action string Phải là "get_emails"
email string Địa chỉ email cần lấy thư (vd: test@thanhori.click)
page integer Không Số trang (mặc định: 1)
limit integer Không Số email mỗi trang (mặc định: 20, tối đa: 100)

Ví dụ Request:

Python
import requests

url = "https://thanhori.click/docthumaildomain/"
params = {
    "action": "get_emails",
    "email": "test@thanhori.click",
    "page": 1,
    "limit": 20
}

response = requests.get(url, params=params)
data = response.json()
print(data)

Response (Success):

JSON
{
  "email": "test@thanhori.click",
  "page": 1,
  "limit": 20,
  "total": 45,
  "hasmore": true,
  "emails": [
    {
      "id": "abc123",
      "sender": "noreply@example.com",
      "subject": "Xác nhận đăng ký",
      "date": "2026-02-02T14:30:00Z",
      "body": "Nội dung email...",
      "html_body": "...",
      "has_attachments": false
    },
    ...
  ]
}

Response (Error):

JSON
{
  "error": true,
  "message": "Email không hợp lệ"
}

🔗 Truy Cập Trực Tiếp Qua URL

Bạn có thể truy cập trực tiếp hòm thư của một email bằng cách thêm email vào URL:

https://thanhori.click/docthumaildomain/{email}

💡 Ví dụ

Để xem hòm thư của test@thanhori.click, truy cập:

https://thanhori.click/docthumaildomain/test@thanhori.click

❌ Mã Lỗi

HTTP Code Mô tả
200 Request thành công
400 Request không hợp lệ (thiếu tham số hoặc sai định dạng)
404 Không tìm thấy dữ liệu
500 Lỗi server
503 Service không khả dụng

💻 Ví Dụ Tích Hợp

JavaScript (Fetch API)

JavaScript
async function checkDomain(domain) {
  const response = await fetch(
    `https://thanhori.click/docthumaildomain/?action=check_domain&domain=${domain}`
  );
  const data = await response.json();
  return data.result === 'online';
}

async function getEmails(email, page = 1, limit = 20) {
  const url = `https://thanhori.click/docthumaildomain/?action=get_emails&email=${email}&page=${page}&limit=${limit}`;
  const response = await fetch(url);
  const data = await response.json();
  
  if (data.error) {
    throw new Error(data.message);
  }
  
  return data;
}

// Sử dụng
checkDomain('thanhori.click').then(isOnline => {
  console.log('Domain online:', isOnline);
});

getEmails('test@thanhori.click').then(data => {
  console.log('Emails:', data.emails);
});

PHP (cURL)

PHP
function getEmails($email, $page = 1, $limit = 20) {
    $url = "https://thanhori.click/docthumaildomain/";
    $params = http_build_query([
        'action' => 'get_emails',
        'email' => $email,
        'page' => $page,
        'limit' => $limit
    ]);
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url . '?' . $params);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);
    
    return json_decode($response, true);
}

// Sử dụng
$data = getEmails('test@thanhori.click', 1, 20);
print_r($data);

Node.js (Axios)

JavaScript
const axios = require('axios');

async function getEmails(email, page = 1, limit = 20) {
  try {
    const response = await axios.get('https://thanhori.click/docthumaildomain/', {
      params: {
        action: 'get_emails',
        email: email,
        page: page,
        limit: limit
      }
    });
    
    return response.data;
  } catch (error) {
    console.error('Error:', error.message);
    throw error;
  }
}

// Sử dụng
getEmails('test@thanhori.click')
  .then(data => console.log(data))
  .catch(error => console.error(error));

⚡ Giới Hạn & Best Practices

⚠️ Rate Limits

Hiện tại API không có giới hạn cứng, nhưng vui lòng:

  • Không spam requests liên tục
  • Cache dữ liệu domains (sử dụng get_cached_domains)
  • Implement retry logic với exponential backoff
  • Không gọi fetch_domains quá 1 lần/giờ

💡 Best Practices

  • Luôn kiểm tra domain status trước khi tạo email
  • Sử dụng pagination khi lấy danh sách email
  • Handle errors gracefully
  • Validate email format trước khi gửi request
  • Lưu email vào localStorage để sử dụng lại

📞 Hỗ Trợ

Nếu bạn gặp vấn đề hoặc cần hỗ trợ, vui lòng liên hệ qua:

📧
Email
support@thanhori.click
🌐
Website
thanhori.click
📱
GitHub
github.com/thanhori