FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
astro-api-python-client/examples/basic_usage.py at master · astrologyapi/astro-api-python-client · GitHub
astrologyapi
/
astro-api-python-client
Public
Notifications
You must be signed in to change notification settings
Fork
9
Star
9
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
astro-api-python-client
/
examples
/
basic_usage.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
87 lines (74 loc) · 2.5 KB
Breadcrumbs
astro-api-python-client
/
examples
/
basic_usage.py
Copy path
File metadata and controls
87 lines (74 loc) · 2.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python3
"""
Basic usage example for AstrologyAPI SDK.
This demonstrates synchronous usage of the SDK.
"""
from
astrologyapi
import
AstrologyAPI
,
BirthData
# Initialize the client
# You can pass the API key directly or use the ASTROLOGYAPI_API_KEY env var
client
=
AstrologyAPI
(
"your-api-key"
)
# Define birth data
birth
=
BirthData
(
day
=
15
,
month
=
6
,
year
=
1990
,
hour
=
10
,
min
=
30
,
lat
=
28.61
,
# Latitude (Delhi)
lon
=
77.20
,
# Longitude (Delhi)
tzone
=
5.5
,
# Timezone (IST)
)
try
:
# Get Vedic birth details
print
(
"Vedic Birth Details:"
)
result
=
client
.
vedic
.
get_birth_details
(
birth
)
print
(
f" Ascendant:
{
result
.
get
(
'ascendant'
)
}
"
)
print
(
f" Sun Sign:
{
result
.
get
(
'sun_sign'
)
}
"
)
print
(
f" Moon Sign:
{
result
.
get
(
'moon_sign'
)
}
"
)
print
()
# Get planets
print
(
"Planetary Positions:"
)
planets
=
client
.
vedic
.
get_planets
(
birth
)
if
"planets"
in
planets
:
for
planet
in
planets
[
"planets"
][:
3
]:
# Show first 3 planets
print
(
f"
{
planet
.
get
(
'name'
)
}
:
{
planet
.
get
(
'sign'
)
}
{
planet
.
get
(
'degree'
)
}
"
)
print
()
# Get Western horoscope
print
(
"Western Horoscope:"
)
western
=
client
.
western
.
get_horoscope
(
birth
)
print
(
f" Western Ascendant:
{
western
.
get
(
'ascendant'
)
}
"
)
print
()
# Get location details
print
(
"Location Lookup:"
)
locations
=
client
.
location
.
get_geo_details
(
"Mumbai"
)
if
locations
:
loc
=
locations
[
0
]
print
(
f" Place:
{
loc
.
get
(
'name'
)
}
"
)
print
(
f" Latitude:
{
loc
.
get
(
'latitude'
)
}
"
)
print
(
f" Longitude:
{
loc
.
get
(
'longitude'
)
}
"
)
print
()
# Get sun-sign horoscope
print
(
"Sun-Sign Daily Horoscope (Gemini):"
)
horoscope
=
client
.
horoscopes
.
get_daily
(
"gemini"
)
print
(
f" Prediction:
{
horoscope
.
get
(
'prediction'
,
'N/A'
)[:
100
]
}
..."
)
print
()
# Get numerology
from
astrologyapi
import
NumeroData
numero
=
NumeroData
(
day
=
15
,
month
=
6
,
year
=
1990
,
name
=
"John Doe"
)
print
(
"Numerology:"
)
num_result
=
client
.
numerology
.
get_table
(
numero
)
if
"psychic_number"
in
num_result
:
print
(
f" Psychic Number:
{
num_result
[
'psychic_number'
]
}
"
)
print
()
# Get tarot reading
print
(
"Tarot Reading:"
)
tarot
=
client
.
tarot
.
get_predictions
()
print
(
f" Prediction:
{
tarot
.
get
(
'prediction'
,
'N/A'
)[:
100
]
}
..."
)
except
Exception
as
e
:
print
(
f"Error:
{
e
}
"
)
if
hasattr
(
e
,
"status_code"
):
print
(
f"Status:
{
e
.
status_code
}
"
)
if
hasattr
(
e
,
"data"
):
print
(
f"Data:
{
e
.
data
}
"
)
finally
:
client
.
close
()
Back
|
FazBrowse Home
|
New Git URL