Skip to content

Embeddable Widgets

Create and manage embeddable widgets for your website. Widgets provide ready-to-use UI components for astrology features that can be integrated into any web page with a single script tag.

Required Module

All widget endpoints require the module:embeddable-widgets module to be enabled for your organization.


Widget Types

The following widget types are available based on your active modules:

TypeDescriptionRequired Module
natalInteractive natal chartnatal:calc
synastrySynastry comparison chartsynastry:calc
transitTransit chart overlaytransit:calc
compositeComposite relationship chartcomposite:calc
moonphaseMoon phase displaymoonphase:calc
daily-horoscopeDaily horoscope for all signsmodule:daily-report
numerologyNumerology profile formmodule:numerology
compatibilitySun sign compatibilitycompatibility:calc
moon-calendarMonthly moon calendarmoon-calendar:calc

Widget Management

List Widgets

bash
curl "https://api.astroapi.cloud/api/widgets" \
  -H "X-Api-Key: your-api-key"

Get Widget

bash
curl "https://api.astroapi.cloud/api/widgets/wgt_abc123" \
  -H "X-Api-Key: your-api-key"

Create Widget

Widgets are created using JSON:API format:

bash
curl -X POST "https://api.astroapi.cloud/api/widgets" \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
    "data": {
      "type": "widgets",
      "attributes": {
        "name": "My Natal Chart Widget",
        "widgetType": "natal",
        "allowedDomains": ["example.com", "www.example.com"],
        "customization": {
          "language": "en",
          "layout": "card",
          "colors": {
            "primary": "#5b2d8e",
            "background": "#ffffff",
            "text": "#1a1a1a"
          },
          "widgetOptions": {
            "showAspects": true,
            "showPoints": true,
            "showHouses": true,
            "chartSize": 500,
            "theme": "light"
          }
        }
      }
    }
  }'

Update Widget

bash
curl -X PATCH "https://api.astroapi.cloud/api/widgets/wgt_abc123" \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
    "data": {
      "type": "widgets",
      "id": "wgt_abc123",
      "attributes": {
        "name": "Updated Widget Name",
        "customization": {
          "language": "nl"
        }
      }
    }
  }'

Delete Widget

bash
curl -X DELETE "https://api.astroapi.cloud/api/widgets/wgt_abc123" \
  -H "X-Api-Key: your-api-key"

Widget Response

json
{
    "data": {
        "type": "widgets",
        "id": "wgt_abc123",
        "attributes": {
            "name": "My Natal Chart Widget",
            "widgetType": "natal",
            "allowedDomains": ["example.com", "www.example.com"],
            "embedCode": "<script src=\"https://cdn.astroapi.cloud/widget.js\" data-widget-id=\"wgt_abc123\"></script>",
            "customization": {
                "language": "en",
                "layout": "card",
                "colors": {
                    "primary": "#5b2d8e",
                    "background": "#ffffff",
                    "text": "#1a1a1a"
                },
                "widgetOptions": {
                    "showAspects": true,
                    "showPoints": true,
                    "showHouses": true,
                    "chartSize": 500,
                    "theme": "light"
                }
            },
            "createdAt": "2024-06-15T12:00:00Z",
            "updatedAt": "2024-06-15T12:00:00Z"
        }
    }
}

Regenerate API Key

Regenerate the widget's embedded API key. Use this if the key has been compromised:

bash
curl -X POST "https://api.astroapi.cloud/api/widgets/wgt_abc123/regenerate-key" \
  -H "X-Api-Key: your-api-key"

Key Rotation

After regenerating the key, existing embeds using the old key will stop working immediately. You do not need to update the embed code — the widget ID remains the same.


Available Widget Options

Retrieve the widget types available to your organization based on your active modules:

bash
curl "https://api.astroapi.cloud/api/widgets/options" \
  -H "X-Api-Key: your-api-key"

Response

json
{
    "data": {
        "availableTypes": ["natal", "moonphase", "daily-horoscope"],
        "planFeatures": {
            "canRemoveBranding": false,
            "canUseCustomLogo": false,
            "canUseCustomCss": true,
            "maxDomains": 5
        }
    }
}

Plan Features

FeatureDescription
canRemoveBrandingWhether the AstroAPI branding can be hidden
canUseCustomLogoWhether a custom logo can be shown in place of the default
canUseCustomCssWhether custom CSS can be injected into the widget
maxDomainsMaximum number of allowed domains per widget

Customization Object

The customization object controls the appearance and behavior of the widget:

json
{
    "colors": {
        "primary": "#5b2d8e",
        "secondary": "#a07cc5",
        "background": "#ffffff",
        "text": "#1a1a1a",
        "border": "#e0e0e0"
    },
    "fonts": {
        "family": "Inter, sans-serif",
        "size": "14px"
    },
    "borders": {
        "radius": "8px",
        "width": "1px"
    },
    "spacing": {
        "padding": "16px",
        "gap": "12px"
    },
    "shadows": {
        "card": "0 2px 8px rgba(0,0,0,0.1)"
    },
    "layout": "card",
    "interaction": {
        "allowUserInput": true,
        "showTooltips": true
    },
    "branding": {
        "showPoweredBy": true,
        "logoUrl": null
    },
    "language": "en",
    "customCss": ".astroapi-widget { font-weight: 500; }",
    "widgetOptions": {
        "showAspects": true,
        "showPoints": true,
        "showHouses": true,
        "chartSize": 500,
        "theme": "light"
    }
}

Customization Fields

FieldTypeDescription
colors.primarystringPrimary accent color (hex)
colors.secondarystringSecondary accent color (hex)
colors.backgroundstringWidget background color (hex)
colors.textstringMain text color (hex)
colors.borderstringBorder color (hex)
fonts.familystringCSS font-family value
fonts.sizestringBase font size (CSS value)
borders.radiusstringBorder radius for cards and inputs (CSS value)
borders.widthstringBorder width (CSS value)
spacing.paddingstringInternal padding (CSS value)
spacing.gapstringGap between elements (CSS value)
shadows.cardstringCSS box-shadow for card elements
layoutstringWidget layout style (see below)
interaction.allowUserInputbooleanWhether users can input their own birth data
interaction.showTooltipsbooleanShow tooltips on hover
branding.showPoweredBybooleanShow "Powered by AstroAPI" badge
branding.logoUrlstring | nullCustom logo URL (requires canUseCustomLogo)
languagestringDisplay language code
customCssstring | nullCustom CSS injection (requires canUseCustomCss)
widgetOptions.showAspectsbooleanShow aspect lines on charts
widgetOptions.showPointsbooleanShow planet symbols on charts
widgetOptions.showHousesbooleanShow house divisions on charts
widgetOptions.chartSizenumberChart size in pixels
widgetOptions.themestringColor theme ("light" or "dark")

Layout Options

ValueDescription
compactMinimal space, suitable for sidebars
cardRounded card with shadow (default)
fullFull-width, no borders
minimalNo background, borderless

Embedding a Widget

After creating a widget, copy the embedCode from the response and paste it into your website's HTML:

html
<!-- Place this where you want the widget to appear -->
<div id="astroapi-widget-container"></div>

<!-- Load the widget script -->
<script
    src="https://cdn.astroapi.cloud/widget.js"
    data-widget-id="wgt_abc123">
</script>

Domain Allowlist

Widgets will only load on domains listed in allowedDomains. Make sure to add all domains (including www variants) where you plan to embed the widget.

AstroAPI Documentation