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)

Step 3 — 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 4 — 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)
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)

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.1.1.tar.gz (12.0 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.1.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for freeastro-0.1.1.tar.gz
Algorithm Hash digest
SHA256 48b4c969702ea4d8694c35c052e5ef5a9b276925b40752bebcdba4853d5f4e75
MD5 9b823f1b04abe49da209702005922123
BLAKE2b-256 53f232c4852c2fe236e17529a629fda6779ca10de0f2c6d7868fb1a199739447

See more details on using hashes here.

Provenance

The following attestation bundles were made for freeastro-0.1.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.1.1-py3-none-any.whl.

File metadata

  • Download URL: freeastro-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31a9485bb03ac7bde94ccdc5f2ad2a5792892b26299cc3a20e4cb1e6c1b2b023
MD5 7756dee32475f21038650fe817abd0f9
BLAKE2b-256 af57c0b75e38bb3b81bf170c2f740ec79637c9282737e5ef210f561eea2c3094

See more details on using hashes here.

Provenance

The following attestation bundles were made for freeastro-0.1.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

0.2.1

2 files

0.2.0

2 files

This release

0.1.1 This release

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