-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquickstart.py
More file actions
60 lines (49 loc) · 1.98 KB
/
Copy pathquickstart.py
File metadata and controls
60 lines (49 loc) · 1.98 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
"""VedAstro API quickstart — no API key required (free tier, 5 req/min).
Install: pip install requests
"""
import requests
BASE = "https://api.vedastro.org/api"
def call(method: str, url: str, json: dict | None = None) -> dict:
"""Call the VedAstro API and unwrap the Status/Payload envelope."""
resp = requests.request(method, url, json=json, timeout=30)
resp.raise_for_status()
body = resp.json()
if body["Status"] != "Pass":
raise RuntimeError(f"VedAstro API error: {body['Payload']}")
return body["Payload"]
def main():
# 1. Resolve an address to coordinates.
# NOTE: result is nested under Payload["AddressToGeoLocation"] — not all
# endpoints nest this way, check the README's verified examples per endpoint.
payload = call(
"POST",
f"{BASE}/Calculate/AddressToGeoLocation",
{"Address": "mumbai", "Ayanamsa": "RAMAN"},
)
print("Resolved location:", payload["AddressToGeoLocation"])
birth_time = {
"StdTime": "14:30 25/10/1992 +05:30", # HH:MM DD/MM/YYYY +-HH:MM — NOT ISO 8601
"Location": {"Name": "Mumbai", "Latitude": 19.0760, "Longitude": 72.8777},
}
# 2. Horoscope predictions — this endpoint returns the array directly as
# Payload (no nested key), unlike AddressToGeoLocation above.
predictions = call(
"POST",
f"{BASE}/Calculate/HoroscopePredictions",
{"birthTime": birth_time, "Ayanamsa": "RAMAN", "sortByWeight": True},
)
print(f"Got {len(predictions)} predictions")
# 3. Dasa period active at a given check time — nested under Payload["DasaAtTime"]
dasa = call(
"POST",
f"{BASE}/Calculate/DasaAtTime",
{
"birthTime": birth_time,
"checkTime": {"StdTime": "12:00 11/07/2026 +05:30", "Location": birth_time["Location"]},
"Ayanamsa": "RAMAN",
"levels": 1,
},
)
print("Dasa at check time:", dasa["DasaAtTime"])
if __name__ == "__main__":
main()