-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
48 lines (40 loc) · 1.56 KB
/
example.js
File metadata and controls
48 lines (40 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { createRoxy } from '@roxyapi/sdk';
const roxy = createRoxy(process.env.ROXY_API_KEY);
/**
* Natal Chart API: complete Western birth chart with planets, houses, aspects,
* Ascendant, Midheaven. Call /location/search first -- never hardcode coordinates.
*/
async function main() {
// Step 1: geocode the birth city
const { data: loc, error: locErr } = await roxy.location.searchCities({
query: { q: 'New York' },
});
if (locErr) throw new Error(locErr.error);
const { latitude, longitude, timezone } = loc.cities[0];
// Step 2: generate the natal chart
const { data, error } = await roxy.astrology.generateNatalChart({
body: {
date: '1990-07-15',
time: '14:30:00',
latitude,
longitude,
timezone,
houseSystem: 'placidus',
},
});
if (error) throw new Error(error.error);
console.log(`Ascendant: ${data.ascendant.sign} ${data.ascendant.degree.toFixed(2)}`);
console.log(`Midheaven: ${data.midheaven.sign} ${data.midheaven.degree.toFixed(2)}`);
console.log(`Dominant element: ${data.summary.dominantElement}`);
console.log(`Dominant modality: ${data.summary.dominantModality}`);
console.log('\nFirst 5 planets:');
for (const p of data.planets.slice(0, 5)) {
const retro = p.isRetrograde ? ' (R)' : '';
console.log(` ${p.name} in ${p.sign} (house ${p.house})${retro}`);
}
console.log('\nTop 3 aspects:');
for (const a of data.aspects.slice(0, 3)) {
console.log(` ${a.planet1} -> ${a.planet2}: ${a.type} orb=${a.orb.toFixed(2)} strength=${a.strength}`);
}
}
main().catch(console.error);