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

Astro ChatBot API

Introducing the Astro ChatBot API, a simple and reliable way to let users ask any astrology question in plain language and get one grounded, chart-based answer back. You send a question and the person's birth details; DivineAPI fetches and compresses their chart, and streams back an answer written for a reader, not a developer. This API is designed for websites, mobile apps, chatbots, CRM dashboards, or astrology portals that want a conversational astrology experience instead of static reports.

It supports seven endpoints: one to ask a question inside a stored conversation, four to manage and inspect those conversations and your account, and one liveness check.


API Endpoint 

POST https://ask.divineapi.com/session

Guide: The full history of one conversation, for restoring a chat screen. Returns every message in order with its role and timestamp, plus the birth details stored against the session. Returns 404 if the session does not exist.


Authentication

Every request requires two headers:

HeaderDescription
AuthorizationBearer {api_acc_token} - identifies the user
x-api-keyUse api_key

Headers

NameTypeDescription

Content-Type*

String

application/json.  Example: Content-Type: application/json

Fields marked with * are mandatory.


Request Body

NameTypeDescription

user_id*

String

Your ID for the end user. Recorded on every request and used for usage reporting.

session_id*StringYour ID for this conversation. A new ID starts a fresh thread.

200: OK Answered Successfully

{
    "session_id": "session090091",
    "messages": [
        {
            "role": "user",
            "text": "When will I get job?",
            "ts": 1790748381.631
        },
        {
            "role": "assistant",
            "text": "Your chart suggests a meaningful job opportunity is most likely to develop from late 2026 into 2027, with progress building through persistence rather than one sudden stroke of luck.\n\nYou are approaching your Saturn return in Aries, exact around March 27, 2026. Because natal Saturn is in your 6th house of work and daily responsibilities, this is a serious career-building period: applications, training, routines, and accepting greater responsibility can lead to something more stable. It may feel slower than you want, but it favors lasting employment.\n\nYour progressed Midheaven is in Sagittarius, while progressed Jupiter is in the 11th house, supporting opportunities through networking, friends, professional communities, online platforms, education, or international connections.",
            "ts": 1790748381.639
        }
    ],
    "birth_details": {
        "day": "24",
        "lat": "28.7041",
        "lon": "77.1025",
        "min": "40",
        "hour": "14",
        "year": "1996",
        "month": "05",
        "place": "New Delhi",
        "tzone": "5.5",
        "gender": "female",
        "full_name": "Priya Sharma"
    }
}

Example Code Implementations

Below are example implementations in various programming environments.


cURL

curl --location 'https://ask.divineapi.com/session' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_acc_token}' \
--header 'x-api-key: {api-key}' \
--data '{
    "session_id": "session090091",
    "user_id": "u_8812dwqdq"
}'

 

curl -X POST "https://ask.divineapi.com/session" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {api_acc_token}" \
  -H "x-api-key: {api-key}" \
  -d '{
    "session_id": "session090091",
    "user_id": "u_8812dwqdq"
}'
const axios = require('axios');

const response = await axios.post(
  'https://ask.divineapi.com/session',
  {
    'session_id': "session090091",
    'user_id': "u_8812dwqdq",
  },
  {
  headers: {
      'Content-Type': "application/json",
      'Authorization': "Bearer {api_acc_token}",
      'x-api-key': "{api-key}",
    },
}
);

console.log(response.data);
import requests

url = "https://ask.divineapi.com/session"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer {api_acc_token}",
    "x-api-key": "{api-key}",
}
payload = {
    "session_id": "session090091",
    "user_id": "u_8812dwqdq",
}

response = requests.post(url, headers=headers, json=payload)

print(response.json())
const response = await fetch(
  'https://ask.divineapi.com/session',
  {
    method: 'POST',
    headers: {
        'Content-Type': "application/json",
        'Authorization': "Bearer {api_acc_token}",
        'x-api-key': "{api-key}",
      },
    body: JSON.stringify({"session_id":"session090091","user_id":"u_8812dwqdq"}),
  }
);

const data = await response.json();
console.log(data);
<?php

use GuzzleHttp\Client;

$client = new Client();

$response = $client->request('POST', 'https://ask.divineapi.com/session', [
    'headers' => [
        'Content-Type' => 'application/json',
        'Authorization' => 'Bearer {api_acc_token}',
        'x-api-key' => '{api-key}',
    ],
    'json' => [
        'session_id' => 'session090091',
        'user_id' => 'u_8812dwqdq',
    ],
]);

echo $response->getBody();
package main

import (
    "bytes"
    "fmt"
    "net/http"
    "io"
)

func main() {
    jsonBody := []byte(`{"session_id":"session090091","user_id":"u_8812dwqdq"}`)
    req, _ := http.NewRequest("POST", "https://ask.divineapi.com/session", bytes.NewBuffer(jsonBody))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer {api_acc_token}")
    req.Header.Set("x-api-key", "{api-key}")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body2, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body2))
}
import okhttp3.*;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();

        MediaType JSON = MediaType.get("application/json; charset=utf-8");
        String json = "{\"session_id\":\"session090091\",\"user_id\":\"u_8812dwqdq\"}";
        RequestBody body = RequestBody.create(json, JSON);

        Request request = new Request.Builder()
            .url("https://ask.divineapi.com/session")
            .post(body)
            .addHeader("Content-Type", "application/json")
            .addHeader("Authorization", "Bearer {api_acc_token}")
            .addHeader("x-api-key", "{api-key}")
            .build();

        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}
import Foundation

let url = URL(string: "https://ask.divineapi.com/session")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer {api_acc_token}", forHTTPHeaderField: "Authorization")
request.setValue("{api-key}", forHTTPHeaderField: "x-api-key")

request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let jsonBody = """{"session_id":"session090091","user_id":"u_8812dwqdq"}"""
request.httpBody = jsonBody.data(using: .utf8)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
import okhttp3.*

fun main() {
    val client = OkHttpClient()

    val mediaType = "application/json".toMediaType()
    val body = "{\"session_id\":\"session090091\",\"user_id\":\"u_8812dwqdq\"}".toRequestBody(mediaType)

    val request = Request.Builder()
        .url("https://ask.divineapi.com/session")
        .post(body!!)
        .addHeader("Content-Type", "application/json")
        .addHeader("Authorization", "Bearer {api_acc_token}")
        .addHeader("x-api-key", "{api-key}")
        .build()

    client.newCall(request).execute().use { response ->
        println(response.body?.string())
    }
}
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program {
    static async Task Main() {
        using var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer {api_acc_token}");
        client.DefaultRequestHeaders.Add("x-api-key", "{api-key}");

using System.Text;
        var json = "{\"session_id\":\"session090091\",\"user_id\":\"u_8812dwqdq\"}";
        var content = new StringContent(json, Encoding.UTF8, "application/json");

        var response = await client.PostAsync("https://ask.divineapi.com/session", content);
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}
Response 200
{
    "session_id": "session090091",
    "messages": [
        {
            "role": "user",
            "text": "When will I get job?",
            "ts": 1790748381.631
        },
        {
            "role": "assistant",
            "text": "Your chart suggests a meaningful job opportunity is most likely to develop from late 2026 into 2027, with progress building through persistence rather than one sudden stroke of luck.\n\nYou are approaching your Saturn return in Aries, exact around March 27, 2026. Because natal Saturn is in your 6th house of work and daily responsibilities, this is a serious career-building period: applications, training, routines, and accepting greater responsibility can lead to something more stable. It may feel slower than you want, but it favors lasting employment.\n\nYour progressed Midheaven is in Sagittarius, while progressed Jupiter is in the 11th house, supporting opportunities through networking, friends, professional communities, online platforms, education, or international connections.",
            "ts": 1790748381.639
        }
    ],
    "birth_details": {
        "day": "24",
        "lat": "28.7041",
        "lon": "77.1025",
        "min": "40",
        "hour": "14",
        "year": "1996",
        "month": "05",
        "place": "New Delhi",
        "tzone": "5.5",
        "gender": "female",
        "full_name": "Priya Sharma"
    }
}