search

Copy page

Copy page as Markdown for LLMs

View as Markdown

View this page as plain text


Open in ChatGPT

Ask ChatGPT about this page

Open in Claude

Ask Claude about this page

Find Sun and Moon API

Empower your astrological explorations by accessing precise Sun and Moon data through the Find Sun and Moon API. This API provides rising and setting details for the Sun and Moon as per Indian Astrology.


Step-by-Step API Integration and Postman Testing

For a complete walkthrough of testing this API using Postman, refer to the official support article below:

Guide: Step-by-Step Find Sun and Moon API Postman Testing Integration


Supported Language Codes

Support Article URL: Translating Indian Vedic APIs into a Different Language

CodeLanguage
enEnglish
hiHindi
bnBengali
maMarathi
tmTamil
tlTelugu
mlMalayalam
knKannada

Guide:
These language codes are supported by this API. You can specify your preferred language by passing the parameter lan in the request body. Default language is en (English).


API Endpoint

POST https://astroapi-2.divineapi.com/indian-api/v2/find-sun-and-moon

This endpoint returns the rising and setting details of the Sun and Moon for the provided date and location.


Headers

NameTypeDescription
AuthorizationStringYour API Access Token. Format: Bearer {token}

Request Body

NameTypeRequiredDescription
api_keyStringYesYour API key.
dayIntegerYesDay of Panchang (e.g., 24).
monthIntegerYesMonth of Panchang (e.g., 05).
yearIntegerYesYear of Panchang (e.g., 2023).
placeStringNoLocation name (e.g., New Delhi).
latFloatYesLatitude (e.g., 28.6139).
lonFloatYesLongitude (e.g., 77.2090).
tzoneFloatYesTimezone (e.g., 5.5). See Timezone Guide.
lanStringNoLanguage code as per the supported list above. Default is en.

Example Response

200: OK – Fetched Sun and Moon Details Successfully

{
    "success": 1,
    "data": {
        "sunrise": "05:26:20 AM",
        "sunset": "07:09:54 PM",
        "moonrise": "09:02:52 AM",
        "moonset": "11:31:49 PM",
        "weekday": "Budhavara"
    }
}

Example Code Implementations

Below are example implementations in various programming environments.


cURL

curl --location 'https://astroapi-2.divineapi.com/indian-api/v2/find-sun-and-moon' \
--header 'Authorization: Bearer {Your Auth Token}' \
--form 'api_key="{Your API Key}"' \
--form 'day="24"' \
--form 'month="05"' \
--form 'year="2023"' \
--form 'place="New Delhi"' \
--form 'lat="28.6139"' \
--form 'lon="77.2090"' \
--form 'tzone="5.5"' \
--form 'lan="en"'

NodeJS

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://astroapi-2.divineapi.com/indian-api/v2/find-sun-and-moon',
  'headers': {
    'Authorization': 'Bearer {Your Auth Token}'
  },
  formData: {
    'api_key': '{Your API Key}',
    'day': '24',
    'month': '05',
    'year': '2023',
    'place': 'New Delhi',
    'lat': '28.6139',
    'lon': '77.2090',
    'tzone': '5.5',
    'lan': 'en'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

JavaScript (jQuery AJAX)

var form = new FormData();
form.append("api_key", "{Your API Key}");
form.append("day", "24");
form.append("month", "05");
form.append("year", "2023");
form.append("place", "New Delhi");
form.append("lat", "28.6139");
form.append("lon", "77.2090");
form.append("tzone", "5.5");
form.append("lan", "en");

var settings = {
  "url": "https://astroapi-2.divineapi.com/indian-api/v2/find-sun-and-moon",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "Bearer {Your Auth Token}"
  },
  "processData": false,
  "mimeType": "multipart/form-data",
  "contentType": false,
  "data": form
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

Python

import requests

url = "https://astroapi-2.divineapi.com/indian-api/v2/find-sun-and-moon"

payload = {'api_key': '{Your API Key}',
'day': '24',
'month': '05',
'year': '2023',
'Place': 'New Delhi',
'lat': '28.6139',
'lon': '77.2090',
'tzone': '5.5',
'lan': 'en'}

headers = {
  'Authorization': 'Bearer {Your Auth Token}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)