Kerykeion

5.12.7 · active · verified Sun Apr 12

Kerykeion is an actively developed Python library for astrological calculations, generating detailed natal charts, house positions, planetary aspects, and high-quality SVG charts. It features a data-driven approach, integrates seamlessly with LLM and AI applications for contextual astrological data, and maintains a frequent release cadence with new features in minor versions and major architectural shifts planned for new major versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to generate a natal chart using Kerykeion's v5+ factory-based architecture. It involves creating an `AstrologicalSubjectFactory` for subject details, using `ChartDataFactory` to compute astrological data, and finally `ChartDrawer` to render the SVG chart. For online location data, a GeoNames username is required, which can be set via an environment variable. The example saves a classic-style SVG chart file.

import os
from kerykeion import AstrologicalSubjectFactory, ChartDataFactory, ChartDrawer

# Set GeoNames username for online calculations. Required for fetching city/nation coordinates.
# Register for a free account at geonames.org if you don't have one.
os.environ['KERYKEION_GEONAMES_USERNAME'] = os.environ.get('KERYKEION_GEONAMES_USERNAME', 'demo')

# 1. Create an AstrologicalSubjectFactory instance
subject_factory = AstrologicalSubjectFactory(
    name='John Doe',
    year=1990, month=5, day=15,
    hour=10, minute=30,
    city='London', nation='UK',
    gender='male'
)

# 2. Compute chart data using ChartDataFactory
chart_data_factory = ChartDataFactory(subject_factory)
natal_chart_data = chart_data_factory.make_natal_chart_data()

# 3. Draw the chart using ChartDrawer
chart_drawer = ChartDrawer(natal_chart_data)

# Generate and save the SVG chart
output_filename = 'john_doe_natal_chart.svg'
chart_drawer.save_svg(output_filename, style='classic')

print(f"Natal chart saved to {output_filename}")

# You can also get data as a Pydantic model
# print(natal_chart_data.model_dump_json(indent=2))

view raw JSON →