mysticapi 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/README.md +160 -0
- package/dist/index.d.mts +265 -0
- package/dist/index.d.ts +265 -0
- package/dist/index.js +270 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +247 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +74 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
- Initial release. Isomorphic, zero-dependency client for MysticAPI.
|
|
6
|
+
- Methods: `skyToday()`, `bodygraph(birth)`, `skyPersonal(birth)`, `skyPersonalGet(birth)`, and the keyless `MysticApi.getFreeKey(email)` / `getFreeKey(email)` helper.
|
|
7
|
+
- Typed `MysticApiError` surfacing HTTP status, machine-readable code, the JSON error body, the docs URL, and the `429` `Retry-After` (in seconds).
|
|
8
|
+
- Dual ESM + CJS build with type declarations. Runs on Node 18+, Bun, browsers, and Cloudflare Workers.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Latimer Woods Tech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# mysticapi
|
|
2
|
+
|
|
3
|
+
Official isomorphic client for **[MysticAPI](https://mysticapi.com)** — a metered engine API for deterministic, Human Design–compatible **bodygraphs**, **personal sky charts**, and **ephemeris**. Same input always returns the same output (JPL-validated pure-JS ephemeris; no generative output).
|
|
4
|
+
|
|
5
|
+
- **Zero dependencies.** Uses the runtime's global `fetch`.
|
|
6
|
+
- **Runs everywhere:** Node 18+, Bun, browsers, and Cloudflare Workers.
|
|
7
|
+
- **Fully typed**, including a typed error that surfaces the JSON error body, HTTP status, and the `429` `Retry-After`.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install mysticapi
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Get a key (30 seconds, no card)
|
|
14
|
+
|
|
15
|
+
Free tier is 50 calls/month, no card. The key is emailed to you.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { MysticApi } from 'mysticapi';
|
|
19
|
+
|
|
20
|
+
await MysticApi.getFreeKey('you@example.com'); // → check your inbox for mk_live_...
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Paid tiers (Maker $19 / Pro $49 / Scale $149 per month, flat — never credits) are self-serve Stripe links listed at <https://mysticapi.com/llms.txt>; your key is emailed within a minute of checkout.
|
|
24
|
+
|
|
25
|
+
## Quick start
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { MysticApi } from 'mysticapi';
|
|
29
|
+
|
|
30
|
+
const mystic = new MysticApi({ apiKey: process.env.MYSTIC_API_KEY! });
|
|
31
|
+
// baseUrl defaults to https://mysticapi.com; pass { baseUrl } to override.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 1. Today's sky — `skyToday()`
|
|
35
|
+
|
|
36
|
+
`GET /v1/sky/today` — active retrogrades, moon phase, geocentric positions for 13 bodies (zodiac + Energy Blueprint gate/line), and a 30-day forward scan of stations and new/full moons.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const sky = await mystic.skyToday();
|
|
40
|
+
|
|
41
|
+
console.log(sky.date); // "2026-07-07"
|
|
42
|
+
console.log(sky.moon.phaseName); // "Waxing Gibbous"
|
|
43
|
+
console.log(sky.moon.illumination); // 0.82
|
|
44
|
+
console.log(sky.retrogrades.active); // [{ planet: "mercury", label: "Mercury Retrograde" }]
|
|
45
|
+
console.log(sky.positions.sun.zodiac); // { sign: "Cancer", degree: 15.2 }
|
|
46
|
+
console.log(sky.positions.sun.gate); // { gate: 4, line: 3 }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Response shape:
|
|
50
|
+
|
|
51
|
+
```jsonc
|
|
52
|
+
{
|
|
53
|
+
"date": "2026-07-07",
|
|
54
|
+
"moon": { "phaseName": "Waxing Gibbous", "illumination": 0.82, "nextFullMoon": { "date": "2026-07-10", "type": "full_moon", "daysAway": 3 } },
|
|
55
|
+
"retrogrades": { "active": [{ "planet": "mercury", "label": "Mercury Retrograde" }], "upcomingStations": [ /* SkyEvent[] */ ] },
|
|
56
|
+
"positions": { "sun": { "longitude": 105.2, "zodiac": { "sign": "Cancer", "degree": 15.2 }, "gate": { "gate": 4, "line": 3 }, "retrograde": false } /* …13 bodies */ },
|
|
57
|
+
"upcoming": [ /* SkyEvent[] — next 30 days */ ]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 2. Bodygraph — `bodygraph(birth)`
|
|
62
|
+
|
|
63
|
+
`POST /v1/bodygraph` — a birth instant **in UTC** → the full Energy Blueprint (Human Design) chart JSON plus a rendered body-graph SVG. No latitude/longitude needed; the body-graph is location-independent.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const { chart, svg } = await mystic.bodygraph({
|
|
67
|
+
year: 1979, month: 8, day: 5, hour: 22, minute: 51, // UTC — convert local time first
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
console.log(chart.chart?.type); // "Manifesting Generator"
|
|
71
|
+
console.log(chart.chart?.authority); // "Sacral"
|
|
72
|
+
console.log(chart.chart?.profile); // "3/5"
|
|
73
|
+
// `svg` is a complete <svg>…</svg> string — write it to a file or inline it.
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Response shape:
|
|
77
|
+
|
|
78
|
+
```jsonc
|
|
79
|
+
{
|
|
80
|
+
"chart": {
|
|
81
|
+
"birth": { "year": 1979, "month": 8, "day": 5, "jdn": 2444091.45 },
|
|
82
|
+
"design": { /* the 88°-solar-arc design moment */ },
|
|
83
|
+
"personalityGates": { "sun": { "gate": 4, "line": 3 } /* … */ },
|
|
84
|
+
"designGates": { "sun": { "gate": 49, "line": 1 } /* … */ },
|
|
85
|
+
"chart": { "type": "Manifesting Generator", "authority": "Sacral", "strategy": "…", "profile": "3/5", "definition": "…", "cross": "…", "channels": [ /* … */ ], "centers": { /* … */ } }
|
|
86
|
+
},
|
|
87
|
+
"svg": "<svg …>…</svg>"
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 3. Personal sky — `skyPersonal(birth)`
|
|
92
|
+
|
|
93
|
+
`POST /v1/sky/personal` — a birth instant → the natal sky rendered as an SVG string (`image/svg+xml`). Deterministic per birth. Retrogrades render `℞`; fixed stars conjunct natal points light up.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
const svg = await mystic.skyPersonal(
|
|
97
|
+
{ year: 1990, month: 1, day: 2, hour: 3, minute: 4 },
|
|
98
|
+
{ animate: false }, // optional — request a static render
|
|
99
|
+
);
|
|
100
|
+
// svg === "<svg xmlns=\"http://www.w3.org/2000/svg\" …>…</svg>"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
There is also `skyPersonalGet(birth, opts?)` if you want the `GET` query-param form (handy for shareable URLs).
|
|
104
|
+
|
|
105
|
+
## Error handling
|
|
106
|
+
|
|
107
|
+
Every non-2xx response throws a typed `MysticApiError`. Network/transport failures throw with `status: 0`, `code: 'network_error'`.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { MysticApi, MysticApiError } from 'mysticapi';
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
await mystic.skyToday();
|
|
114
|
+
} catch (err) {
|
|
115
|
+
if (err instanceof MysticApiError) {
|
|
116
|
+
err.status; // 401 | 402 | 429 | 400 | 0 | …
|
|
117
|
+
err.code; // "missing_api_key" | "quota_exceeded" | "http_402" | …
|
|
118
|
+
err.message; // human-readable message from the API
|
|
119
|
+
err.docs; // documentation URL, when provided
|
|
120
|
+
err.retryAfter; // number of seconds (set on 429 when Retry-After is present)
|
|
121
|
+
|
|
122
|
+
if (err.isRateLimited) await sleep(err.retryAfter! * 1000); // back off, then retry
|
|
123
|
+
if (err.isUnauthorized) { /* bad or missing key */ }
|
|
124
|
+
if (err.isPaymentRequired) { /* 402 — supply a key or an x402 payment */ }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Cloudflare Workers
|
|
130
|
+
|
|
131
|
+
Works out of the box — the client uses global `fetch`. Read the key from a secret binding:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
export default {
|
|
135
|
+
async fetch(_req: Request, env: { MYSTIC_API_KEY: string }): Promise<Response> {
|
|
136
|
+
const mystic = new MysticApi({ apiKey: env.MYSTIC_API_KEY });
|
|
137
|
+
const sky = await mystic.skyToday();
|
|
138
|
+
return Response.json(sky);
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
You can also inject a custom `fetch` via `new MysticApi({ apiKey, fetch })`.
|
|
144
|
+
|
|
145
|
+
## API
|
|
146
|
+
|
|
147
|
+
| Method | HTTP | Returns |
|
|
148
|
+
| --- | --- | --- |
|
|
149
|
+
| `new MysticApi({ apiKey, baseUrl?, fetch? })` | — | client |
|
|
150
|
+
| `skyToday()` | `GET /v1/sky/today` | `Promise<SkyToday>` |
|
|
151
|
+
| `bodygraph(birth)` | `POST /v1/bodygraph` | `Promise<BodygraphResult>` (`{ chart, svg }`) |
|
|
152
|
+
| `skyPersonal(birth, opts?)` | `POST /v1/sky/personal` | `Promise<string>` (SVG) |
|
|
153
|
+
| `skyPersonalGet(birth, opts?)` | `GET /v1/sky/personal` | `Promise<string>` (SVG) |
|
|
154
|
+
| `MysticApi.getFreeKey(email, opts?)` | `POST /v1/keys/free` | `Promise<FreeKeyResponse>` |
|
|
155
|
+
|
|
156
|
+
`birth` is `{ year, month, day, hour, minute, second? }` in **UTC**. All types are exported. The machine-readable contract lives at <https://mysticapi.com/.well-known/openapi.json>.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT © Latimer Woods Tech
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the MysticAPI HTTP contract.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors https://mysticapi.com/.well-known/openapi.json (OpenAPI 3.1). The live
|
|
5
|
+
* spec is the source of truth; these types track it and are kept deliberately
|
|
6
|
+
* permissive (index signatures on open-ended objects) so the client never breaks
|
|
7
|
+
* when the engine adds fields.
|
|
8
|
+
*/
|
|
9
|
+
/** A birth instant expressed in UTC. Convert local time + timezone to UTC first. */
|
|
10
|
+
interface BirthInput {
|
|
11
|
+
/** Full year, 1–2200. */
|
|
12
|
+
year: number;
|
|
13
|
+
/** Month, 1–12. */
|
|
14
|
+
month: number;
|
|
15
|
+
/** Day of month, 1–31. */
|
|
16
|
+
day: number;
|
|
17
|
+
/** Hour, 0–23 (UTC). */
|
|
18
|
+
hour: number;
|
|
19
|
+
/** Minute, 0–59 (UTC). */
|
|
20
|
+
minute: number;
|
|
21
|
+
/** Second, 0–59 (UTC). Defaults to 0. */
|
|
22
|
+
second?: number;
|
|
23
|
+
}
|
|
24
|
+
/** A zodiac placement: sign name plus degree within the sign. */
|
|
25
|
+
interface ZodiacPlacement {
|
|
26
|
+
sign: string;
|
|
27
|
+
degree: number;
|
|
28
|
+
}
|
|
29
|
+
/** An Energy Blueprint gate/line placement on the 64-gate wheel. */
|
|
30
|
+
interface GatePlacement {
|
|
31
|
+
/** Gate number, 1–64. */
|
|
32
|
+
gate: number;
|
|
33
|
+
/** Line number, 1–6. */
|
|
34
|
+
line: number;
|
|
35
|
+
}
|
|
36
|
+
/** Geocentric position of a single celestial body. */
|
|
37
|
+
interface BodyPosition {
|
|
38
|
+
label?: string;
|
|
39
|
+
/** Ecliptic longitude in degrees, 0 ≤ longitude < 360. */
|
|
40
|
+
longitude?: number;
|
|
41
|
+
zodiac?: ZodiacPlacement;
|
|
42
|
+
gate?: GatePlacement;
|
|
43
|
+
retrograde?: boolean;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
/** A forthcoming sky event (retrograde station or new/full moon). May be null. */
|
|
47
|
+
interface SkyEvent {
|
|
48
|
+
date?: string;
|
|
49
|
+
type?: 'retrograde_start' | 'retrograde_end' | 'new_moon' | 'full_moon';
|
|
50
|
+
planet?: string;
|
|
51
|
+
title?: string;
|
|
52
|
+
/** Practical prep guidance for the event. */
|
|
53
|
+
prep?: string;
|
|
54
|
+
daysAway?: number;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
/** Moon phase snapshot for {@link SkyToday}. */
|
|
58
|
+
interface MoonState {
|
|
59
|
+
phaseName?: string;
|
|
60
|
+
/** Illuminated fraction, 0–1. */
|
|
61
|
+
illumination?: number;
|
|
62
|
+
elongationDeg?: number;
|
|
63
|
+
nextNewMoon?: SkyEvent | null;
|
|
64
|
+
nextFullMoon?: SkyEvent | null;
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
}
|
|
67
|
+
/** Active + upcoming retrograde state for {@link SkyToday}. */
|
|
68
|
+
interface RetrogradeState {
|
|
69
|
+
active?: Array<{
|
|
70
|
+
planet?: string;
|
|
71
|
+
label?: string;
|
|
72
|
+
}>;
|
|
73
|
+
upcomingStations?: SkyEvent[];
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
}
|
|
76
|
+
/** Response of {@link MysticApi.skyToday}: the universal (non-personal) sky. */
|
|
77
|
+
interface SkyToday {
|
|
78
|
+
date: string;
|
|
79
|
+
generatedAt?: string;
|
|
80
|
+
moon: MoonState;
|
|
81
|
+
retrogrades: RetrogradeState;
|
|
82
|
+
/** Positions keyed by body id (e.g. `sun`, `moon`, `mercury`, ...). */
|
|
83
|
+
positions: Record<string, BodyPosition>;
|
|
84
|
+
upcoming: SkyEvent[];
|
|
85
|
+
attribution?: string;
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The computed Energy Blueprint chart. The engine returns a rich, evolving
|
|
90
|
+
* object (birth with jdn, the 88°-solar-arc design moment, per-body conscious +
|
|
91
|
+
* unconscious gate maps, and the derived chart: type, authority, strategy,
|
|
92
|
+
* profile, definition, incarnation cross, channels, centers). Known top-level
|
|
93
|
+
* fields are typed; the index signature keeps forward-compatibility.
|
|
94
|
+
*/
|
|
95
|
+
interface BodygraphChart {
|
|
96
|
+
birth?: Record<string, unknown>;
|
|
97
|
+
design?: Record<string, unknown>;
|
|
98
|
+
personalityGates?: Record<string, GatePlacement>;
|
|
99
|
+
designGates?: Record<string, GatePlacement>;
|
|
100
|
+
chart?: {
|
|
101
|
+
type?: string;
|
|
102
|
+
authority?: string;
|
|
103
|
+
strategy?: string;
|
|
104
|
+
profile?: string;
|
|
105
|
+
definition?: string;
|
|
106
|
+
cross?: string;
|
|
107
|
+
channels?: unknown;
|
|
108
|
+
centers?: unknown;
|
|
109
|
+
[key: string]: unknown;
|
|
110
|
+
};
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
}
|
|
113
|
+
/** Response of {@link MysticApi.bodygraph}: chart JSON plus a rendered SVG. */
|
|
114
|
+
interface BodygraphResult {
|
|
115
|
+
chart: BodygraphChart;
|
|
116
|
+
/** Body-graph SVG markup (a complete `<svg>…</svg>` string). */
|
|
117
|
+
svg: string;
|
|
118
|
+
attribution?: string;
|
|
119
|
+
}
|
|
120
|
+
/** Response of {@link MysticApi.getFreeKey}. The key itself arrives by email. */
|
|
121
|
+
interface FreeKeyResponse {
|
|
122
|
+
message?: string;
|
|
123
|
+
docs?: string;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
}
|
|
126
|
+
/** Options for {@link MysticApi.skyPersonal}. */
|
|
127
|
+
interface SkyPersonalOptions {
|
|
128
|
+
/** When `false`, request a static (non-animated) SVG. Defaults to the API default. */
|
|
129
|
+
animate?: boolean;
|
|
130
|
+
}
|
|
131
|
+
/** The JSON error envelope returned by MysticAPI on non-2xx responses. */
|
|
132
|
+
interface ApiErrorBody {
|
|
133
|
+
error?: string;
|
|
134
|
+
message?: string;
|
|
135
|
+
docs?: string;
|
|
136
|
+
[key: string]: unknown;
|
|
137
|
+
}
|
|
138
|
+
/** Constructor options for {@link MysticApi}. */
|
|
139
|
+
interface MysticApiOptions {
|
|
140
|
+
/** Your API key, e.g. `mk_live_...`. Get a free one via {@link MysticApi.getFreeKey}. */
|
|
141
|
+
apiKey: string;
|
|
142
|
+
/** Override the API base URL. Defaults to `https://mysticapi.com`. */
|
|
143
|
+
baseUrl?: string;
|
|
144
|
+
/** Inject a fetch implementation. Defaults to the runtime's global `fetch`. */
|
|
145
|
+
fetch?: typeof globalThis.fetch;
|
|
146
|
+
}
|
|
147
|
+
/** Options for the keyless helpers ({@link MysticApi.getFreeKey}). */
|
|
148
|
+
interface KeylessOptions {
|
|
149
|
+
/** Override the API base URL. Defaults to `https://mysticapi.com`. */
|
|
150
|
+
baseUrl?: string;
|
|
151
|
+
/** Inject a fetch implementation. Defaults to the runtime's global `fetch`. */
|
|
152
|
+
fetch?: typeof globalThis.fetch;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Default MysticAPI base URL. */
|
|
156
|
+
declare const DEFAULT_BASE_URL = "https://mysticapi.com";
|
|
157
|
+
/**
|
|
158
|
+
* Isomorphic MysticAPI client. Zero dependencies — uses the runtime's global
|
|
159
|
+
* `fetch`, so it runs unchanged on Node 18+, Bun, browsers, and Cloudflare
|
|
160
|
+
* Workers.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const mystic = new MysticApi({ apiKey: 'mk_live_...' });
|
|
165
|
+
* const sky = await mystic.skyToday();
|
|
166
|
+
* console.log(sky.moon.phaseName);
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare class MysticApi {
|
|
170
|
+
private readonly apiKey;
|
|
171
|
+
private readonly baseUrl;
|
|
172
|
+
private readonly fetchImpl;
|
|
173
|
+
constructor(options: MysticApiOptions);
|
|
174
|
+
private authHeaders;
|
|
175
|
+
/**
|
|
176
|
+
* Today's universal sky: active retrogrades, moon phase + illumination,
|
|
177
|
+
* geocentric positions for 13 bodies (zodiac + Energy Blueprint gate/line),
|
|
178
|
+
* and a 30-day forward scan of retrograde stations and new/full moons.
|
|
179
|
+
*
|
|
180
|
+
* `GET /v1/sky/today` — metered (1 call).
|
|
181
|
+
*/
|
|
182
|
+
skyToday(): Promise<SkyToday>;
|
|
183
|
+
/**
|
|
184
|
+
* Compute an Energy Blueprint (Human Design) chart from a birth instant and
|
|
185
|
+
* return the full chart JSON plus a rendered body-graph SVG. Location is not
|
|
186
|
+
* required — the body-graph is location-independent.
|
|
187
|
+
*
|
|
188
|
+
* `POST /v1/bodygraph` — metered (1 call).
|
|
189
|
+
*/
|
|
190
|
+
bodygraph(birth: BirthInput): Promise<BodygraphResult>;
|
|
191
|
+
/**
|
|
192
|
+
* Render a personal-sky chart from a birth instant. Returns the SVG markup as
|
|
193
|
+
* a string (`image/svg+xml`). Deterministic: the same birth always yields the
|
|
194
|
+
* same sky.
|
|
195
|
+
*
|
|
196
|
+
* `POST /v1/sky/personal` — metered (1 call).
|
|
197
|
+
*/
|
|
198
|
+
skyPersonal(birth: BirthInput, options?: SkyPersonalOptions): Promise<string>;
|
|
199
|
+
/**
|
|
200
|
+
* Render a personal-sky chart via `GET /v1/sky/personal` (birth as query
|
|
201
|
+
* params). Equivalent to {@link MysticApi.skyPersonal}; useful when you want a
|
|
202
|
+
* shareable URL shape. Returns the SVG markup as a string.
|
|
203
|
+
*/
|
|
204
|
+
skyPersonalGet(birth: BirthInput, options?: SkyPersonalOptions): Promise<string>;
|
|
205
|
+
/**
|
|
206
|
+
* Request a free, no-card API key. The key is emailed (the API responds `202`
|
|
207
|
+
* with a confirmation message — the secret itself is never returned in the
|
|
208
|
+
* body). One active key per email; 50 calls/month.
|
|
209
|
+
*
|
|
210
|
+
* `POST /v1/keys/free` — no auth required.
|
|
211
|
+
*/
|
|
212
|
+
static getFreeKey(email: string, options?: KeylessOptions): Promise<FreeKeyResponse>;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Standalone helper to request a free, no-card API key (emailed to `email`).
|
|
216
|
+
* Same as {@link MysticApi.getFreeKey}; exported for keyless call sites.
|
|
217
|
+
*
|
|
218
|
+
* `POST /v1/keys/free` — no auth required.
|
|
219
|
+
*/
|
|
220
|
+
declare function getFreeKey(email: string, options?: KeylessOptions): Promise<FreeKeyResponse>;
|
|
221
|
+
|
|
222
|
+
/** Fields used to construct a {@link MysticApiError}. */
|
|
223
|
+
interface MysticApiErrorInit {
|
|
224
|
+
status: number;
|
|
225
|
+
code: string;
|
|
226
|
+
message: string;
|
|
227
|
+
docs?: string;
|
|
228
|
+
retryAfter?: number;
|
|
229
|
+
body?: ApiErrorBody | string;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Error thrown for any non-2xx MysticAPI response (and for network failures,
|
|
233
|
+
* which surface as `status: 0`, `code: 'network_error'`).
|
|
234
|
+
*
|
|
235
|
+
* The parsed JSON error envelope (`{ error, message, docs }`) is exposed on
|
|
236
|
+
* {@link MysticApiError.body}, the machine-readable code on
|
|
237
|
+
* {@link MysticApiError.code}, and — for `429` — the `Retry-After` value in
|
|
238
|
+
* seconds on {@link MysticApiError.retryAfter}.
|
|
239
|
+
*/
|
|
240
|
+
declare class MysticApiError extends Error {
|
|
241
|
+
/** HTTP status code. `0` for a network/transport failure. */
|
|
242
|
+
readonly status: number;
|
|
243
|
+
/** Machine-readable error code (from the body's `error` field, or a synthetic one). */
|
|
244
|
+
readonly code: string;
|
|
245
|
+
/** Documentation URL surfaced by the API, when present. */
|
|
246
|
+
readonly docs?: string;
|
|
247
|
+
/** For `429`: the `Retry-After` value in seconds, when the header is present. */
|
|
248
|
+
readonly retryAfter?: number;
|
|
249
|
+
/** The parsed JSON error body, or raw text when the body was not JSON. */
|
|
250
|
+
readonly body?: ApiErrorBody | string;
|
|
251
|
+
constructor(init: MysticApiErrorInit);
|
|
252
|
+
/** True for a `401` (missing/invalid API key). */
|
|
253
|
+
get isUnauthorized(): boolean;
|
|
254
|
+
/** True for a `402` (payment required — no key and no valid x402 payment). */
|
|
255
|
+
get isPaymentRequired(): boolean;
|
|
256
|
+
/** True for a `429` (monthly allotment reached or rate limited). */
|
|
257
|
+
get isRateLimited(): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Build a {@link MysticApiError} from a failed {@link Response}, parsing the
|
|
260
|
+
* JSON error envelope and the `Retry-After` header.
|
|
261
|
+
*/
|
|
262
|
+
static fromResponse(res: Response, path: string): Promise<MysticApiError>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export { type ApiErrorBody, type BirthInput, type BodyPosition, type BodygraphChart, type BodygraphResult, DEFAULT_BASE_URL, type FreeKeyResponse, type GatePlacement, type KeylessOptions, type MoonState, MysticApi, MysticApiError, type MysticApiErrorInit, type MysticApiOptions, type RetrogradeState, type SkyEvent, type SkyPersonalOptions, type SkyToday, type ZodiacPlacement, getFreeKey };
|