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

Uploaded Python 3

File details

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

File metadata

  • Download URL: freeastro-0.2.0.tar.gz
  • Upload date:
  • Size: 13.4 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.0.tar.gz
Algorithm Hash digest
SHA256 a0e6a1f189f254071d93bf6e43bd2ecb1146d65ec72b3145ede1e87e8b4d21ff
MD5 e9d820747ade82a9985fece1c92bc788
BLAKE2b-256 d33b55116390d58feb3bb81c207f7900ee91df45b3a98723b56cb4036126cc61

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: freeastro-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52834436102ca8bb92b8967a544ed55beb8c1d610399ac66d3339ed672c56dcf
MD5 28eaf0fb8ff02ffe969b78ea5af9253e
BLAKE2b-256 131836e71e37dcda06a18c2a7f23a6af10a51d20dae970c853f55c3531735a3b

See more details on using hashes here.

Provenance

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

This release

0.2.0 This release

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