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
-**Methods are grouped by domain and named for the spec operation id.**`roxy.Astrology.GenerateNatalChart(...)`, `roxy.VedicAstrology.GenerateBirthChart(...)`. Never invent a name; the full list is in `docs/llms-full.txt`.
30
-
-**Argument order is `(ctx, pathParams..., params, body)`, but the arity varies.**`params` is a nilable `*XxxParams` of query parameters (it carries `Lang` on i18n endpoints); pass `nil` for none. POST endpoints add a typed `body` last. **An endpoint with no query parameters has NO `params` argument at all** (for example `roxy.Usage.GetUsageStats(ctx)` and `roxy.Languages.ListLanguages(ctx)`). Do not pass a stray `nil` to those: `nil` would be read as a request editor and panic. When unsure, let autocomplete show the signature.
30
+
-**Argument order is `(ctx, pathParams..., params, body)`, but the arity varies.**`params` is a nilable `*XxxParams` of query parameters (it carries `Lang` on i18n endpoints); pass `nil` for none. POST endpoints add a typed `body` last. **An endpoint with no query parameters has NO `params` argument at all** (for example `roxy.Usage.GetUsageStats(ctx)` and `roxy.Languages.ListLanguages(ctx)`). Do not pass a stray `nil` to those: it COMPILES (the last arg is variadic) then PANICS at runtime in applyEditors. Call them with `ctx` only. When unsure, let autocomplete show the signature.
31
31
-**The request body type is always `roxyapi.<MethodName>JSONRequestBody`** (some are aliases of a named request like `NatalChartRequest`; both names work). Build it as a struct literal.
32
32
-**Read the success body from `JSON200`** (a typed struct, nil unless the call was a 2xx): `resp.JSON200.Cities[0].Latitude`. `resp.StatusCode()` and `resp.Bytes()` give the raw response.
33
33
-**Handle errors with `errors.As` on `*RoxyError`.** Switch on `Code` (stable), not `Message`. On a 400, range over `Issues`.
`Q` accepts a bare city (`"Paris"`), city plus country (`"Berlin Germany"`), or comma qualified (`"Springfield, Illinois"`). Use the qualified form to disambiguate.
58
+
`Q` accepts a bare city (`"Paris"`), city plus country (`"Berlin Germany"`), or comma qualified (`"Springfield, Illinois"`). Use the qualified form to disambiguate, with a full country name, not an abbreviation (`"London, United Kingdom"`, not `"London, UK"`).
59
59
60
60
## Domains
61
61
@@ -105,9 +105,12 @@ import (
105
105
roxyapi "github.com/RoxyAPI/sdk-go"
106
106
)
107
107
108
-
// The Timezone field is a per-request union. Every timezone-taking request R exposes
109
-
// the type R_Timezone with two builders: FromRTimezone0(decimalOffset) and
110
-
// FromRTimezone1(ianaName). Both return an error you can ignore for a static value.
108
+
// The Timezone field is a per-request union. Build it with the generated From..0
109
+
// (decimal offset) or From..1 (IANA) method. The union TYPE NAME is not always
110
+
// guessable: a $ref body uses <Request>_Timezone (NatalChartRequest_Timezone); an
111
+
// inline body (most POST endpoints) uses <Operation>JSONBody_Timezone, e.g.
112
+
// GenerateBodygraphJSONBody_Timezone. If unsure, write the field with any value and
113
+
// read the expected type from the compiler error, or use autocomplete.
111
114
vartz roxyapi.NatalChartRequest_Timezone
112
115
_ = tz.FromNatalChartRequestTimezone1("Europe/Berlin") // or .FromNatalChartRequestTimezone0(1)
113
116
@@ -190,7 +193,10 @@ LLMs hallucinate confidently here. The specific traps:
190
193
191
194
## Go-specific gotchas
192
195
193
-
-**Some methods have no `params` argument** (see Rules). Passing `nil` to those panics. Affected: `Usage.GetUsageStats`, `Languages.ListLanguages`, `Crystals.ListCrystalColors`, `Crystals.ListCrystalPlanets`, `Dreams.GetSymbolLetterCounts`.
196
+
-**Some methods have no `params` argument** (see Rules). Passing `nil` to those compiles but PANICS at runtime (the trailing arg is a variadic request editor). Affected: `Usage.GetUsageStats`, `Languages.ListLanguages`, `Crystals.ListCrystalColors`, `Crystals.ListCrystalPlanets`, `Dreams.GetSymbolLetterCounts`.
197
+
-**`Timezone` union type names vary:**`<Request>_Timezone` for a named body, `<Operation>JSONBody_Timezone` for an inline body (most POST endpoints). Cannot guess it? Write the field with any value and read the expected type from the compiler error, or use autocomplete.
198
+
-**`NewRoxy` returns `*roxyapi.Roxy`** (the type for your own function signatures and struct fields) and returns an error on an empty API key, so a missing `ROXYAPI_KEY` fails at construction, not as a confusing later 401.
199
+
-**A successful `SearchCities` can return zero cities.** Check `len(search.JSON200.Cities) == 0` before indexing `[0]`.
194
200
-**Person-pair and forecast bodies use anonymous nested structs** (`CalculateSynastry`, `CalculateGunMilan`, `GenerateTimeline` carry inline `Person1`/`Person2`/`BirthData` structs). They are awkward to build as a Go literal; for those, see https://roxyapi.com/api-reference for the JSON shape.
195
201
-**`SearchCities` paginates** with `Limit` and `Offset` (`roxyapi.Ptr(20)`); the default page is 10.
196
202
-**One direct runtime dependency.**`go get` pulls `github.com/oapi-codegen/runtime` (Apache 2.0); it brings two small transitive modules (`google/uuid`, `apapsch/go-jsonmerge`). The HTTP layer is the standard library `net/http`.
@@ -248,6 +256,23 @@ Every endpoint is also a remote MCP tool at `https://roxyapi.com/mcp/{domain}` (
248
256
-**Read responses off `JSON200`** (`resp.JSON200.Cities[0].Latitude`). It is nil unless the call was a 2xx (errors are returned, not in the body).
249
257
-**Person-pair / forecast bodies use anonymous structs** (see note above) and are best built from the JSON shape in the API reference.
250
258
259
+
## FAQ
260
+
261
+
**Q: `SearchCities` returned 200 but `Cities[0]` panics, or my city is not found.**
262
+
A: A successful search can still return an empty `Cities` slice, so check `len(search.JSON200.Cities) == 0` before indexing. Two-letter country abbreviations are not matched: use the full country name (`"London, United Kingdom"`, not `"London, UK"`) or just the bare city (`"London"`).
263
+
264
+
**Q: I got `nil pointer dereference` in `applyEditors`. What did I do?**
265
+
A: You passed `nil` to an endpoint that has no query-parameters argument (`roxy.Usage.GetUsageStats`, `roxy.Languages.ListLanguages`, `roxy.Crystals.ListCrystalColors`, `roxy.Crystals.ListCrystalPlanets`, `roxy.Dreams.GetSymbolLetterCounts`). That `nil` is read as a request editor: the call compiles, then panics at runtime. Call them with `ctx` only, for example `roxy.Usage.GetUsageStats(ctx)`.
266
+
267
+
**Q: `NewRoxy` returned no error but every call is `401 api_key_required`.**
268
+
A: Make sure `ROXYAPI_KEY` is exported. `NewRoxy` returns an error for an empty key; a non-empty but wrong key only fails on the first request.
269
+
270
+
**Q: How do I build the `Timezone` when I cannot guess the union type name?**
271
+
A: The union type is `<Request>_Timezone` for a named request body (`NatalChartRequest_Timezone`) and `<Operation>JSONBody_Timezone` for an inline body (`GenerateBodygraphJSONBody_Timezone`). If you cannot guess it, write the `Timezone:` field with any value and read the expected type from the compiler error, or let autocomplete fill it. Build it with `.From<Type>Timezone1("IANA")` or `.From<Type>Timezone0(decimal)`.
272
+
273
+
**Q: What type does `NewRoxy` return, so I can store it or pass it to a function?**
274
+
A: `*roxyapi.Roxy`.
275
+
251
276
## Error handling and advanced use
252
277
253
278
Any 4xx or 5xx is returned as a `*RoxyError`. Switch on `Code` (stable); `Message` is human readable.
0 commit comments