오픈 API
간단한 HTTP API로 임시 받은편지함을 만들고 메일을 읽을 수 있습니다. 자동화 테스트와 회원가입 검증에 적합하며, 모든 엔드포인트는 JSON을 반환합니다.
인증
받은편지함을 만들면 토큰이 반환됩니다. 이후 요청에 함께 보내세요:
Authorization: Bearer <token>
요청 제한
API 키가 없으면 IP당 분당 최대 10개의 받은편지함을 만들 수 있습니다. 더 높은 한도가 필요하면 생성 시 API 키를 보내세요:
X-API-Key: tm_xxxxxxxxxxxxxxxx
엔드포인트
| 메서드 | 경로 | 설명 |
|---|---|---|
| GET | /api/domains | 사용 가능한 도메인 목록 |
| POST | /api/mailbox | 받은편지함 생성. 빈 본문은 랜덤 주소, {"local":"abc","domain":"…"}는 지정 주소 |
| GET | /api/mailbox | 현재 받은편지함 정보 |
| DELETE | /api/mailbox | 받은편지함과 모든 메일 삭제 |
| GET | /api/messages | 받은편지함 목록 (최신 100개) |
| GET | /api/messages/{id} | 메일 조회 (본문 및 첨부파일) |
| DELETE | /api/messages/{id} | 메일 삭제 |
| GET | /api/messages/{id}/raw | 원본 .eml 다운로드 |
| GET | /api/attachments/{id} | 첨부파일 다운로드 |
| GET | /api/events | SSE 이벤트 스트림, 새 메일 도착 시 event: mail 전송 |
예제
# 1. 받은편지함 생성. 빈 본문은 랜덤 주소, {"local":"abc","domain":"…"}는 지정 주소
curl -s -X POST https://www.temp-mail.cc/api/mailbox \
-H 'Content-Type: application/json' -d '{}'
# => {"address":"[email protected]","token":"…","expires_at":"…"}
# 2. 받은편지함 목록 (최신 100개)
curl -s https://www.temp-mail.cc/api/messages \
-H 'Authorization: Bearer <token>'
# 3. 메일 조회 (본문 및 첨부파일)
curl -s https://www.temp-mail.cc/api/messages/123 \
-H 'Authorization: Bearer <token>'
# Python
import requests, time
base = "https://www.temp-mail.cc"
mb = requests.post(f"{base}/api/mailbox", json={}).json()
headers = {"Authorization": f"Bearer {mb['token']}"}
print(mb["address"])
while True:
msgs = requests.get(f"{base}/api/messages", headers=headers).json()["messages"]
if msgs:
print(requests.get(f"{base}/api/messages/{msgs[0]['id']}", headers=headers).json()["text"])
break
time.sleep(3)
오류
오류 시 2xx가 아닌 상태 코드와 JSON 본문이 반환됩니다:
{"error": "rate_limited", "message": "…"}