// sdk · Go
AstroWay API 用の Go SDK
公式の AstroWay Go モジュールだよ。すべての API エンドポイントがメソッドとして提供され、例えば aw.Chart.Compute のように、呼び出しごとにコンテキストが付く。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から自動生成され、常にバックエンドと同期しています。