Cosmic Notifications - 우주 현상 알림
AstroWay API를 request-response 방식에서 이벤트 스트림으로 바꿔봐. 하늘을 반복해서 폴링하는 대신, 이벤트 타입에 URL을 구독하면 AstroWay가 해당 순간에 웹훅을 자동으로 보내줘 (HMAC-SHA256 서명, 자동 재시도 및 ‘죽은’ 구독 자동 해제 포함).
어떤 이벤트 (live)
섹션 제목: “어떤 이벤트 (live)”이 모든 이벤트는 글로벌(하늘 상태가 출생 차트와 무관함)이며, 구독자는 동일한 payload를 받아.
| 이벤트 | 등록 | 발생 시점 |
|---|---|---|
retrograde-start | POST /v1/webhooks/retrograde-start | 행성(수성–명왕성)이 역행 상태가 됨 |
retrograde-end | POST /v1/webhooks/retrograde-end | 행성이 역행을 멈추고 (정방향) 움직임 |
sign-ingress | POST /v1/webhooks/sign-ingress | 행성(태양 + 수성–명왕성)이 새로운 별자리로 진입 |
void-of-course-start | POST /v1/webhooks/void-of-course-start | 달의 ‘코스 없는’ 기간(VOC) 시작 |
eclipse-alert | POST /v1/webhooks/eclipse-alert | 일식 또는 월식 7일 전 |
구독 방법
섹션 제목: “구독 방법”계정에 연결된 API 키가 필요해.
curl -X POST https://api.astroway.info/v1/webhooks/retrograde-start \ -H "X-Api-Key: aw_live_..." \ -H "Content-Type: application/json" \ -d '{ "url": "https://your-app.com/hooks/astroway" }'# { "id": 44, "event": "retrograde-start",# "url": "https://your-app.com/hooks/astroway",# "signing_secret": "a1b2…", ← збережіть, ним перевіряється підпис# "active": true }구독 관리: GET /v1/webhooks (목록), GET /v1/webhooks/{id}, DELETE /v1/webhooks/{id}, POST /v1/webhooks/{id}/test (테스트 전송을 당신의 URL로).
당신의 URL에 도착하는 내용
섹션 제목: “당신의 URL에 도착하는 내용”POST 요청에 헤더 X-AstroWay-Signature: sha256=<hmac>, X-AstroWay-Event, X-AstroWay-Delivery-Id와 본문이 포함돼:
{ "event": "retrograde-start", "delivered_at": "2026-07-15T12:00:00.000Z", "subscription_id": 44, "data": { "planet": "Mercury", "station": "retrograde", "exactAt": "2026-07-15T11:48:09.967Z", "sign": "Leo", "longitude": 142.31 }}서명 검증
섹션 제목: “서명 검증”서명은 HMAC-SHA256(signing_secret, raw_body)를 hex 형태로 만든 거야. 헤더 X-AstroWay-Signature와 비교해 (접두사 sha256= 없이):
import { createHmac, timingSafeEqual } from 'node:crypto';
function verify(rawBody, header, secret) { const expected = createHmac('sha256', secret).update(rawBody).digest('hex'); const got = header.replace(/^sha256=/, ''); return got.length === expected.length && timingSafeEqual(Buffer.from(got), Buffer.from(expected));}구독은 연속 5번 실패한 전송(2xx가 아니거나 8초 타임아웃) 후 자동으로 해제돼 – GET /v1/webhooks 로 다시 켜면, 일시 정지/재개가 카운터를 초기화해.
구독 등록 및 관리 - 호출당 Tier 1 (10 크레딧), 자주 일어나지는 않아. 이벤트를 당신의 URL로 전달하는 것은 과금되지 않아 – 별도 요금이 없어.