// sdk · Go
AstroWay API용 Go SDK
공식 AstroWay Go 모듈: 모든 API 엔드포인트를 메서드로 제공, 예: aw.Chart.Compute, 호출마다 context 포함. 408/409/429/5xx 에서 Retry-After를 존중하고, POST는 Idempotency-Key 하나를 유지해 재시도 시 두 번 청구되지 않음. errors.Is 로 오류를 검사하고, 응답을 직접 타입으로 디코드. 표준 라이브러리만 사용, Go 1.22+.
// 01 / install
설치
go get github.com/astroway/astroway-go 가져오기: astroway "github.com/astroway/astroway-go"
레지스트리 보기 → github.com/astroway/astroway-go
// 02 / highlights
특징
- OpenAPI 사양 725 메서드
- 모든 호출에 context.Context
- Retry-After와 Idempotency-Key 재시도
- errors.Is: ErrQuotaExceeded, ErrRateLimit
- 표준 라이브러리만
// 03 / first request
첫 요청
package main
import (
"context"
"fmt"
"log"
"os"
astroway "github.com/astroway/astroway-go"
)
func main() {
aw := astroway.New(os.Getenv("ASTROWAY_API_KEY"))
res, err := aw.Chart.Compute(context.Background(), map[string]any{
"date": "1990-07-14", "time": "14:30:00", "timezoneOffset": 3,
"latitude": 50.4501, "longitude": 30.5234, "houseSystem": "P",
})
if err != nil {
log.Fatal(err)
}
var chart struct {
Houses struct {
Ascendant float64 `json:"ascendant"`
} `json:"houses"`
}
if err := res.Decode(&chart); err != nil {
log.Fatal(err)
}
fmt.Println(chart.Houses.Ascendant) // 212.0952574979425
} Go 시작하기
월 10,000 크레딧 무료. Open-source SDK로, OpenAPI 3.1에서 생성되며 백엔드와 항상 동기화됩니다.