Skip to main content

freeastro

A free Python library that calculates astrological birth charts (natal charts).

Good for:

  • Building horoscope or astrology apps
  • Automating birth chart generation for multiple people
  • Adding astrology features to an existing web service
  • Learning astrology calculations programmatically

Give it a birth date, time, and place — get back the positions of planets and house cusps as Python objects or JSON.

Install

pip install freeastro

The first time you run freeastro, it automatically downloads a ~17 MB planetary data file (NASA DE421 ephemeris). After that, everything works offline.

Usage

Step 1 — Create a subject

Pass the birth data of the person you want to calculate a chart for:

from freeastro import AstrologicalSubject

subject = AstrologicalSubject(
    name="John Doe",
    year=1990,
    month=1,
    day=15,
    hour=12,      # 24-hour format, local time
    minute=0,
    latitude=35.6762,    # Tokyo: positive = North
    longitude=139.6503,  # Tokyo: positive = East
    tz_str="Asia/Tokyo", # timezone string
)

How to find latitude, longitude, and timezone

City latitude longitude tz_str
Tokyo 35.6762 139.6503 "Asia/Tokyo"
New York 40.7128 -74.0060 "America/New_York"
London 51.5074 -0.1278 "Europe/London"
Paris 48.8566 2.3522 "Europe/Paris"
Sydney -33.8688 151.2093 "Australia/Sydney"

For other cities, right-click on Google Maps to get coordinates. Find the timezone string on this list.

Notes on signs:

  • South latitudes are negative (e.g. Sydney: -33.8688)
  • West longitudes are negative (e.g. New York: -74.0060)

Step 2 — Read planet positions

# Sun sign and degree
print(subject.sun.sign)         # "Capricorn"
print(subject.sun.sign_degree)  # 24.70  (degrees within that sign)
print(subject.sun.house)        # 9      (which house the Sun is in)

# Check if a planet is retrograde
print(subject.mercury.retrograde)  # True

# Available planets
print(subject.moon)
print(subject.mercury)
print(subject.venus)
print(subject.mars)
print(subject.jupiter)
print(subject.saturn)
print(subject.uranus)
print(subject.neptune)
print(subject.pluto)
print(subject.true_node)  # Moon's True North Node

Step 3 — Read aspects

Aspects describe angular relationships between planets (e.g. a trine, a square).

# All aspects in the chart
for aspect in subject.aspects:
    print(aspect)
# <Aspect Moon Trine Mercury (orb -0.91°)>
# <Aspect Sun Conjunction Venus (orb +6.21°)>
# ...

# Filter by type
trines = [a for a in subject.aspects if a.aspect == "Trine"]

# Check a specific pair
sun_moon = [a for a in subject.aspects
            if {a.planet1, a.planet2} == {"Sun", "Moon"}]

Supported aspects: Conjunction (0°), Opposition (180°), Trine (120°), Square (90°), Sextile (60°).

Step 4 — Read house cusps

# Ascendant (1st house cusp)
print(subject.first_house.sign)  # "Taurus"

# Midheaven (10th house cusp) as ecliptic longitude
print(subject.mc)   # 296.92

# All 12 houses
for house in subject.houses:
    print(f"House {house.number}: {house.sign} {house.sign_degree:.1f}°")

Step 5 — Export the data

# As a Python dict
data = subject.to_dict()

# As a JSON string (pretty-printed)
json_str = subject.to_json()
print(json_str)

Example JSON output (excerpt):

{
  "subject_name": "John Doe",
  "year": 1990,
  "month": 1,
  "day": 15,
  "planets": [
    {
      "name": "Sun",
      "sign": "Capricorn",
      "position": 294.70,
      "sign_degree": 24.70,
      "house": 9,
      "retrograde": false
    }
  ],
  "asc": 43.12,
  "mc": 296.92
}

Data fields

Planet

Field Example Meaning
name "Sun" Planet name
sign "Capricorn" Zodiac sign the planet is in
sign_degree 24.70 Degrees within that sign (0–30)
position 294.70 Absolute ecliptic longitude (0–360). For most uses, sign + sign_degree is enough.
house 9 House number (1–12)
retrograde False Whether the planet appears to move backward

House

Field Example Meaning
number 1 House number (1–12)
sign "Taurus" Zodiac sign of the house cusp
sign_degree 13.12 Degrees within that sign (0–30)
position 43.12 Absolute ecliptic longitude (0–360). For most uses, sign + sign_degree is enough.

Aspect

Field Example Meaning
planet1 "Moon" First planet
planet2 "Mercury" Second planet
aspect "Trine" Aspect type
angle 119.09 Actual angular distance between planets (0–180)
orb -0.91 How far off from the exact angle (Trine = 120°, so 119.09 − 120 = −0.91)

Troubleshooting

The download hangs or fails on first run freeastro downloads a ~17 MB file from a NASA server. If it fails, check your internet connection and try running again. The file is cached after the first successful download.

I get a ZoneInfoNotFoundError for my timezone The tz_str value must be an exact match from the tz database. Common mistakes: "JST" should be "Asia/Tokyo", "EST" should be "America/New_York".

The planet positions look off Double-check that:

  • hour and minute are in local time, not UTC
  • South latitudes are negative (e.g. -33.86 for Sydney)
  • West longitudes are negative (e.g. -74.00 for New York)

ModuleNotFoundError: No module named 'freeastro' Run pip install freeastro first. If you're using a virtual environment, make sure it's activated.

Requirements

  • Python 3.10 or later
  • Internet connection on first run (to download the ephemeris)

License

MIT — free to use for any purpose, including commercial projects.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

freeastro-0.2.1.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

freeastro-0.2.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file freeastro-0.2.1.tar.gz.

File metadata

  • Download URL: freeastro-0.2.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for freeastro-0.2.1.tar.gz
Algorithm Hash digest
SHA256 061e93576443bfb38e705ff6d3305969786a53d00dbabd4f18a7f36f74fe15db
MD5 6f6f097ac0d06812a32846793f7304ed
BLAKE2b-256 7732b84b8da1e85fb121c240dccc1c9f142199d1ea845e563f68eadd00f0ac77

See more details on using hashes here.

Provenance

The following attestation bundles were made for freeastro-0.2.1.tar.gz:

Publisher: publish.yml on kanekoyuichi/freeastro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file freeastro-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: freeastro-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for freeastro-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c7086691910fc9f6331fb57f2d798a377a272e6cb486f8a6f195cba1f034ab47
MD5 96c5b7e43170e2f9c7ffbed871560b9c
BLAKE2b-256 3c8c8534e3c819551cff917d746e5b5ac1438654d37a0b18d061c4f6af039818

See more details on using hashes here.

Provenance

The following attestation bundles were made for freeastro-0.2.1-py3-none-any.whl:

Publisher: publish.yml on kanekoyuichi/freeastro

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page