Developer guide9 MIN READ01 / 38
On this page

Astrology API v1: birth chart endpoints and authentication

The Western and Vedic APIs accept JSON chart requests from your server. The first example calculates a Western natal chart for a birth instant and location in Mumbai.

Base URL: https://api.astrology.melmanlabs.com

Scope and reading order

This reference describes the v1 request formats listed below. The live playground uses Vedic and Western v3. Only a varga calculation feeding Vedic transits requests provenance=true&evidence=true for the reference chart and its provider engine version. Other panels use the default response. On hosts without v3 routes the playground retries on Vedic v2 or Western v1. Recorded examples retain their v1 shapes. When copying a playground request, retain the actual URL, body and calculation preferences shown in its Request & response panel.

For a first integration, run the Mumbai natal request and locate value.natal in the returned JSON. Its countedBodies field tells you which bodies contributed to the element and modality counts. If your interface needs longitudes and house cusps for a wheel, follow the response guide to the compose operation. For interpreting the returned chart, choose a chart reading guide. The JSON learning examples illustrate concepts and are not the implemented request schema.

Make your first request

Create a customer API key in the dashboard. Store it on your server as ASTROLOGY_API_KEY, then request a natal chart:

curl --request POST 'https://api.astrology.melmanlabs.com/western/v1/natal' \
  --header "X-API-Key: $ASTROLOGY_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "instant": "2000-01-01T12:00:00Z",
    "houseObserver": { "latitude": 19.076, "longitude": 72.8777 }
  }'

A successful calculation returns HTTP 200 and JSON. Vedic v1/v2 and Western v1 preserve the original response envelope. These routes ignore metadata selectors and detail=none. By default they summarize provider evidence as sources; detail=full returns native evidence. Western v2 is unmounted.

Vedic v3 and Western v3 expose the same operations and inputs as Vedic v2 and Western v1 respectively. On these v3 routes and astronomy v1, calculation POSTs omit envelope metadata by default. These routes accept independent rules=true, provenance=true, probes=true and evidence=true switches. Each selected category is returned at the root when available. detail=none overrides all switches and detail=full returns the original full layout.

Authentication

Send your customer key in the X-API-Key header on every calculation or capability request. Customer API calls use this header rather than a dashboard bearer token. Missing, unknown or revoked keys receive 401. Usage controls can return 429.

Call from your server. Keep the key out of browser JavaScript, public repositories and client-visible logs. If it is exposed, revoke it and create a replacement in the dashboard.

Find an endpoint

Paths follow /<tradition>/v1/<operation>, with no /api prefix. Discovery uses GET; calculations use POST with JSON. Calculations return results directly and do not create saved charts or birth records.

Astronomy positions

The calculation host now implements POST /astronomy/v1/positions and GET /astronomy/v1/capabilities. These additions require deployment before use on the public host. See the position API guide for a first request, observer diagrams, per-body include arrays, output fields, lunar measurements and optional issues. Astronomy has its own response shape and does not return the chart envelope described below.

Western astrology

Method Path Use it for
GET /western/v1/capabilities Available configurations and supported features
POST /western/v1/natal Natal chart
POST /western/v1/chart Multiple techniques in one chart request
POST /western/v1/compose Tropical positions and available houses/angles for rendering
POST /western/v1/harmonics Harmonic charts
POST /western/v1/directions Directions
POST /western/v1/progressions Progressions to a target instant
POST /western/v1/transit Transits relative to a natal chart
POST /western/v1/synastry Compare two birth charts
POST /western/v1/composite Composite of two birth charts
POST /western/v1/returns Return search with explicit location and search budget

Vedic astrology

Method Path Use it for
GET /vedic/v1/capabilities Available configurations and supported features
POST /vedic/v1/chart Multiple Vedic calculations in one request
POST /vedic/v1/varga Divisional charts
POST /vedic/v1/dasha Dasha periods
POST /vedic/v1/ashtakavarga Ashtakavarga
POST /vedic/v1/shadbala Planetary strength
POST /vedic/v1/yogas Yoga and dosha calculations
POST /vedic/v1/drishti Drishti
POST /vedic/v1/judgments Rule-based judgments
POST /vedic/v1/panchang Daily panchang
POST /vedic/v1/muhurta Muhurta windows
POST /vedic/v1/transits Transit snapshots or windows
POST /vedic/v1/matching Matching a pair

Vedic uses transits, while Western uses transit. A listed endpoint can still require a specific profile, observer or additional options. Discover supported configurations before selecting a feature:

curl 'https://api.astrology.melmanlabs.com/vedic/v1/capabilities' \
  --header "X-API-Key: $ASTROLOGY_API_KEY"

Request shapes

Send Content-Type: application/json. Send a JSON object no larger than 64 KB. Birth-chart requests require an instant string or number. Use an ISO timestamp with an explicit timezone, or epoch milliseconds.

Single calculations

For a single calculation, send the shared birth details and any calculation options in request. The quick-start example above shows a natal chart with no additional options.

Shared field Meaning
instant Moment being calculated; required
houseObserver Location used for houses and chart angles
positionObserver Separate observer for planetary positions when supported by the selected calculation settings
profile Calculation settings reference; omit it to use the default settings
allowPartial Allows supported calculations to return available results when some requested features are unavailable
request Options for the selected calculation

Observer and feature requirements depend on the selected calculation. A missing observer is not automatically filled from another field. allowPartial does not bypass input validation or guarantee success after arbitrary failures. Unknown top-level chart fields are discarded rather than treated as additional calculation options.

Single-calculation chart envelopes include completeness fields and any requested metadata. For planetary strength, use /vedic/v1/shadbala; in a combined request, select "strengths".

Combined charts

/vedic/v1/chart takes layers and optional requests keyed by the selected calculation name:

{
  "instant": "2000-01-01T12:00:00Z",
  "houseObserver": { "latitude": 19.076, "longitude": 72.8777 },
  "layers": ["dasha", "varga"]
}

/western/v1/chart takes techniques and optional requests keyed by technique name. For example, a natal-only request adds "techniques": ["natal"] to the input above and omits layers. Some techniques need additional reference charts or options; adding their names alone does not satisfy those inputs. These requests use plural requests, whereas single-feature shortcuts use singular request.

Vedic operation requests

These four operations accept their own input fields directly. They do not use the shared birth-chart format or wrap their input inside request.

Endpoint Top-level input
/vedic/v1/panchang localDate, dayStart, observer, optional profile
/vedic/v1/muhurta days, observer, purpose, packVersion, direction, optional minimumMinutes and profile
/vedic/v1/transits mode, reference, optional profile and bindus; snapshot mode adds asOf, window mode adds window, step, optional bodies
/vedic/v1/matching pair, optional profile

Western operation inputs

Some operations need more than the shared birth input:

Operation Additional input
composite first and second, each containing birth-chart input
synastry first and second for the two-birth operation
progressions Birth input plus request.targetInstant and progression options
returns Birth input plus request.anchorInstant, request.budget and request.locationPolicy
transit Birth input plus request.at for a moving-sky snapshot

Combined Western chart example

{
  "instant": "2000-01-01T12:00:00Z",
  "houseObserver": { "latitude": 19.076, "longitude": 72.8777 },
  "techniques": ["natal", "harmonics"],
  "requests": { "harmonics": { "factor": 5 } }
}

Send the combined request above to POST /western/v1/chart.

Read the response

Results are returned as JSON without an additional data wrapper. POST /western/v1/compose returns the tropical snapshot directly for chart rendering, including body positions and available houses/angles. It accepts shared chart fields and optional houses: false to skip house placement; it does not take techniques or use the chart-result envelope below. allowPartial is ignored by this snapshot operation.

Vedic and Western calculation results share these envelope fields:

Field Meaning
value Calculated values, grouped by the requested calculation
rules (opt-in) Rules used to produce the result
probes (opt-in) Identifiers for contributing probe reads
evidence (opt-in) Operation-specific provider evidence
provenance (opt-in) Calculation settings and source information that help you identify how a result was produced
missing Explicitly omitted features and their reasons
complete Whether the result is complete for the requested calculation

A 200 response can carry an incomplete chart when the service permits partial results. Clients must inspect complete and missing before presenting all requested features as available.

Presenting partial results

Treat missing as part of the result, not an empty placeholder. Render the available values with their units and settings, and explain which requested features were omitted. Do not replace unavailable positions, scores or times with zero: zero can be a valid calculated value.

Compare equivalent results. For example, Shadbala needs component coverage to make a strength comparison meaningful, while a solar return needs a successful event search before its event chart can be read. Keep the input, rules and provenance with any exported result.

Handle errors

Calculation errors use a nested error object. For example, malformed JSON returns:

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Body is not valid JSON."
  }
}

Authentication, usage-limit and connection failures use a different shape:

{
  "code": "INVALID_API_KEY",
  "message": "<safe explanation>",
  "traceId": "<support reference>",
  "status": 401
}

The second example shows the structure; placeholder values are not literal response text. Normalize body.error ?? body in your client, then branch on the code and HTTP status. Calculation errors may also include optional detail.

HTTP status Meaning Recommended action
400 Invalid JSON, instant, observer or required input Correct the request before retrying
401 Missing, invalid or revoked customer key Check the server-side key
404 Unknown route, version, profile or rulebook Verify the path and supported configuration
422 Unsupported feature, incompatible profile or calculation limit Check capabilities and calculation options
429 Request limited by usage controls Check usage and reduce request frequency
502 Calculation service could not be reached or returned an invalid response Retry cautiously with a bounded backoff
503 Calculation source unavailable Retry cautiously with a bounded backoff
504 Calculation timed out Retry cautiously with a bounded backoff
500 Unexpected failure Retain diagnostic details and contact support if persistent

Retries may consume additional allowance; avoid unbounded retries. Preserve a traceId when present for support.

Integration checklist

  • Use an explicit timezone in birth timestamps, or send epoch milliseconds.
  • Pass observer coordinates required by the calculation; one observer field is not automatically substituted for another.
  • Check both the HTTP status and result completeness.
  • Keep keys on your server and inspect usage in the dashboard.
  • Test your workflow and server location against the regional benchmarks.
  • Use the vocabulary guide for domain terminology.

The API accepts JSON bodies up to 64 KB. Oversized bodies currently reach its generic 500 response, so keep payloads within that limit. Unknown URLs, unsupported methods and unavailable versions return 404 rather than redirecting to another contract.