Developer

API Documentation

v1 · REST · JSON

Tích hợp đọc Hotmail/Outlook vào tool của bạn qua REST API.

Base URL

https://getcode.khommo.vn

Authentication

Mọi request cần kèm header X-API-Key.

X-API-Key: rmh_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
!

Để lấy API key, liên hệ qua Telegram @khommovn. Key có dạng rmh_... và giới hạn mặc định 100 request/phút.

POST/api/v1/read-mailĐọc email Hotmail/Outlook

Request Body (JSON)

FieldTypeRequiredMô tả
emailstringBắt buộcĐịa chỉ email Hotmail/Outlook
refreshTokenstringBắt buộcOAuth2 refresh token
clientIdstringBắt buộcClient ID của app Azure
mode"imap" | "graph"Tuỳ chọnMặc định: "imap"

Response

FieldTypeMô tả
successbooleantrue nếu đọc mail thành công
messagesMailMessage[]Danh sách email, mới nhất trước
errorstring?Mô tả lỗi nếu success = false

MailMessage object

FieldTypeMô tả
idstringID email
fromstringNgười gửi: "Name <email>"
subjectstringTiêu đề email
receivedAtstringThời gian nhận (ISO 8601)
snippetstringĐoạn preview nội dung (≤200 ký tự)
bodystringNội dung đầy đủ (có thể là HTML)
extractedCodeExtractedCode?Mã OTP/code tự động nhận diện

Response Example

{
  "success": true,
  "messages": [
    {
      "id": "1234",
      "from": "Microsoft <account-security-noreply@accountprotection.microsoft.com>",
      "subject": "Mã xác minh Microsoft của bạn",
      "receivedAt": "2025-05-27T10:30:00Z",
      "snippet": "Dùng mã xác minh này 847291...",
      "body": "<html>...</html>",
      "extractedCode": {
        "code": "847291",
        "confidence": "high",
        "source": "body",
        "matchedKeyword": "auto-detected"
      }
    }
  ]
}

Code Examples

cURL

curl -X POST https://getcode.khommo.vn/api/v1/read-mail \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "email": "yourmail@hotmail.com",
    "refreshToken": "M.C...",
    "clientId": "04b07795-...",
    "mode": "imap"
  }'

JavaScript (fetch)

const res = await fetch('https://getcode.khommo.vn/api/v1/read-mail', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'YOUR_API_KEY',
  },
  body: JSON.stringify({
    email: 'yourmail@hotmail.com',
    refreshToken: 'M.C...',
    clientId: '04b07795-...',
    mode: 'imap',
  }),
})

const data = await res.json()
if (data.success) {
  console.log(data.messages[0]?.extractedCode?.code)
}

Python (requests)

import requests

resp = requests.post(
    'https://getcode.khommo.vn/api/v1/read-mail',
    headers={
        'X-API-Key': 'YOUR_API_KEY',
    },
    json={
        'email': 'yourmail@hotmail.com',
        'refreshToken': 'M.C...',
        'clientId': '04b07795-...',
        'mode': 'imap',
    },
    timeout=20,
)

data = resp.json()
if data['success']:
    print(data['messages'][0]['extractedCode']['code'])

Error Codes

HTTP StatusCodeMô tả
401UnauthorizedThiếu hoặc sai X-API-Key
400Bad RequestThiếu email / refreshToken / clientId
429Too Many RequestsVượt rate limit
502Bad GatewayKhông đọc được mail từ server

Lưu ý

  • ·API không lưu email, refreshToken hay nội dung mail. Chỉ đếm lượt gọi cho thống kê.
  • ·Timeout mặc định 15 giây mỗi request.
  • ·Nếu mode=imap thất bại, thử lại với mode=graph.
  • ·API key không được chia sẻ công khai. Mỗi key có rate limit riêng (mặc định 100 req/phút).