You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add runnable examples, httptest-based tests, GitHub Actions CI
- examples/natal, examples/transits, examples/positions · self-contained, read TUFFYS_API_KEY
- tuffys/client_test.go · 7 tests via httptest.Server, no real API calls
covers: happy path, structured API error, raw error fallback, no-key omits header,
custom http.Client transport, context cancellation, trailing-slash baseURL
- .github/workflows/ci.yml · go vet/build/test -race on Go 1.21, 1.22, 1.23
- README: CI status badge, Examples section, swap private-repo link for case-study,
soften 'no interface{}' claim (responses are map[string]any today), drop
nonexistent WithUserAgent from design principles
Every method is typed end-to-end. No `interface{}`, no magic strings.
94
+
Inputs are typed (`Person`, `NatalChartOpts`, `AspectPoint`); responses currently decode as `map[string]any` to match the API's rich, endpoint-specific shapes. Typed response structs are on the roadmap as the OpenAPI 3.1 spec stabilizes.
94
95
95
96
---
96
97
98
+
## Examples
99
+
100
+
Runnable examples live in [`examples/`](./examples):
101
+
102
+
```bash
103
+
export TUFFYS_API_KEY="eyJ..."
104
+
go run ./examples/natal # natal chart with typed error handling
105
+
go run ./examples/transits # transits from a natal chart
106
+
go run ./examples/positions # stateless body positions
107
+
```
108
+
97
109
## Design principles
98
110
99
111
-**Zero runtime dependencies.** Embed this in anything — serverless, edge, CLI, bot — without dragging a graph.
100
112
-**Context-first.** Every method takes `context.Context`. Cancel anywhere in the tree.
101
113
-**Errors are data.**`*tuffys.APIError` carries the HTTP status, the machine-readable code, and a human message.
102
-
-**Idiomatic options.** Functional options (`WithAPIKey`, `WithHTTPClient`, `WithUserAgent`) — swap out the transport for tracing, retries, or testing.
114
+
-**Idiomatic options.** Functional options (`WithAPIKey`, `WithHTTPClient`) — swap out the transport for tracing, retries, or testing.
103
115
-**Strict input parsing on the server.** ISO-8601 datetimes required — no ambiguous local times. Pair with Go's `time.Time.Format(time.RFC3339)` and you're set.
104
116
105
117
---
106
118
107
119
## Related
108
120
109
-
-**[Main repository](https://github.com/omkarjaliparthi/tuffys-ai-astrology)** — engine, API, frontend, case study
Runnable Go examples for the Tuffy's Astrology API client.
4
+
5
+
Each example is self-contained — `go run ./examples/<name>` from the repo root.
6
+
7
+
| Example | What it shows |
8
+
|---|---|
9
+
|[`natal/`](./natal)| Quickstart · `NatalChart` with typed error handling |
10
+
|[`transits/`](./transits)| Relational endpoint · `Transits` of a natal chart to a given datetime |
11
+
|[`positions/`](./positions)| Stateless body positions — no birth data needed |
12
+
13
+
## Auth
14
+
15
+
All examples read the API key from `TUFFYS_API_KEY`:
16
+
17
+
```bash
18
+
export TUFFYS_API_KEY="eyJ..."# HS256 JWT issued by the API
19
+
go run ./examples/natal
20
+
```
21
+
22
+
For the free Developer tier, [mint a key](https://tuffys-ai-astrology.vercel.app/pricing). No credit card.
23
+
24
+
## Base URL
25
+
26
+
Examples default to the hosted API at `https://tuffys-ai-astrology.vercel.app`. Override with `TUFFYS_BASE_URL` to point at a local or custom deployment.
0 commit comments