-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.ts
More file actions
71 lines (60 loc) · 2.24 KB
/
Copy pathexample.ts
File metadata and controls
71 lines (60 loc) · 2.24 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { createRoxy } from '@roxyapi/sdk';
const roxy = createRoxy(process.env.ROXY_API_KEY!);
/**
* Astrology Compatibility API: scores two birth charts through Western synastry aspects and
* returns an overall percent, five category scores, sign pair narratives, and a relationship
* archetype. Roxy Ephemeris, verified against NASA JPL Horizons.
* Call /location/search for each person first -- never hardcode coordinates.
*/
async function main() {
// Step 1: geocode person 1 birth city
const { data: loc1, error: locErr1 } = await roxy.location.searchCities({
query: { q: 'New York' },
});
if (locErr1) throw new Error(locErr1.error);
const { latitude: lat1, longitude: lng1, timezone: tz1 } = loc1.cities[0];
// Step 2: geocode person 2 birth city
const { data: loc2, error: locErr2 } = await roxy.location.searchCities({
query: { q: 'Los Angeles' },
});
if (locErr2) throw new Error(locErr2.error);
const { latitude: lat2, longitude: lng2, timezone: tz2 } = loc2.cities[0];
// Step 3: score the astrology compatibility between the two charts
const { data, error } = await roxy.astrology.calculateCompatibility({
body: {
person1: {
date: '1990-07-15',
time: '14:30:00',
latitude: lat1,
longitude: lng1,
timezone: tz1,
},
person2: {
date: '1992-03-20',
time: '09:15:00',
latitude: lat2,
longitude: lng2,
timezone: tz2,
},
},
});
if (error) throw new Error(error.error);
console.log('Overall compatibility score:', data.overallScore);
console.log('Archetype:', data.archetype.label);
console.log('\nCategory scores:');
for (const [name, score] of Object.entries(data.categories)) {
console.log(` ${name}: ${score}`);
}
console.log(
`\nAspect breakdown: ${data.aspectBreakdown.total} total ` +
`(${data.aspectBreakdown.harmonious} harmonious, ${data.aspectBreakdown.challenging} challenging)`
);
console.log('\nTop 3 key aspects:');
for (const aspect of data.keyAspects.slice(0, 3)) {
console.log(
` ${aspect.planet1} ${aspect.type} ${aspect.planet2} orb ${aspect.orb} [${aspect.interpretation}]`
);
}
console.log('\nSummary:', data.summary);
}
main().catch(console.error);