REQUEST
cURL
JavaScript
Python
PHP
Flutter (Dart)
Swift
Kotlin
Go
Ruby
# Replace YOUR_API_KEY with the key from your dashboard
curl -X POST "https://starsapi.com/api/v3/transit/western/retrograde" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query_type": "year",
"year": 2026,
"timezone": "Asia/Kolkata"
}'
const response = await fetch(
'https://starsapi.com/api/v3/transit/western/retrograde',
{
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query_type: 'year',
year: 2026,
timezone: 'Asia/Kolkata'
})
}
);
const result = await response.json();
if (result.success) {
console.log(result.data);
}
import requests
import os
response = requests.post(
'https://starsapi.com/api/v3/transit/western/retrograde',
headers={'X-Api-Key': os.environ['STARSAPI_KEY']},
json={
'query_type': 'year',
'year': 2026,
'timezone': 'Asia/Kolkata'
}
)
result = response.json()
if result['success']:
print(result['data'])
<?php
$payload = [
'query_type' => 'year',
'year' => 2026,
'timezone' => 'Asia/Kolkata',
];
$ch = curl_init('https://starsapi.com/api/v3/transit/western/retrograde');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-Key: ' . getenv('STARSAPI_KEY'),
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
if ($data['success']) {
print_r($data['data']);
}
import 'package:http/http.dart' as http;
import 'dart:convert';
Future<Map<String, dynamic>> getAscendant() async {
final response = await http.post(
Uri.parse('https://starsapi.com/api/v3/transit/western/retrograde'),
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: jsonEncode({
'query_type': 'year',
'year': 2026,
'timezone': 'Asia/Kolkata',
}),
);
return jsonDecode(response.body);
}
import Foundation
func getAscendant() async throws -> [String: Any] {
var request = URLRequest(url: URL(string:
"https://starsapi.com/api/v3/transit/western/retrograde"
)!)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "X-Api-Key")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = """
{
"query_type": "year",
"year": 2026,
"timezone": "Asia/Kolkata"
}
""".data(using: .utf8)
let (data, _) = try await URLSession.shared.data(for: request)
return try JSONSerialization.jsonObject(with: data) as! [String: Any]
}
import okhttp3.*
import org.json.JSONObject
val client = OkHttpClient()
val JSON = "application/json; charset=utf-8".toMediaType()
fun getAscendant(callback: (JSONObject) -> Unit) {
val payload = """
{
"query_type": "year",
"year": 2026,
"timezone": "Asia/Kolkata"
}
""".trimIndent()
val request = Request.Builder()
.url("https://starsapi.com/api/v3/transit/western/retrograde")
.addHeader("X-Api-Key", "YOUR_API_KEY")
.post(payload.toRequestBody(JSON))
.build()
client.newCall(request).enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) {
callback(JSONObject(response.body!!.string()))
}
override fun onFailure(call: Call, e: java.io.IOException) {
e.printStackTrace()
}
})
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
payload, _ := json.Marshal(map[string]interface{}{
"query_type": "year",
"year": 2026,
"timezone": "Asia/Kolkata",
})
req, _ := http.NewRequest("POST",
"https://starsapi.com/api/v3/transit/western/retrograde",
bytes.NewBuffer(payload))
req.Header.Set("X-Api-Key", os.Getenv("STARSAPI_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["data"])
}
require 'net/http'
require 'json'
uri = URI('https://starsapi.com/api/v3/transit/western/retrograde')
payload = {
'query_type' => 'year',
'year' => 2026,
'timezone' => 'Asia/Kolkata'
}
req = Net::HTTP::Post.new(uri)
req['X-Api-Key'] = ENV['STARSAPI_KEY']
req['Content-Type'] = 'application/json'
req.body = payload.to_json
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
res = http.request(req)
data = JSON.parse(res.body)
puts data['data'] if data['success']
{
"status": 200,
"success": true,
"data": {
"query": {
"query_type": "year",
"year": 2026,
"timezone": "Asia/Kolkata",
"zodiac": "tropical",
"planet": "all",
"motion": "all"
},
"transits": [
{
"planet": "Mercury",
"motion": "Rx",
"sign": "Aries",
"start_date": "2026-03-15",
"start_time": "04:22:00",
"end_date": "2026-04-07",
"end_time": "18:45:00",
"duration_days": 23.6,
"station_degree": "12°18'42\""
}
],
"count": 12
},
"meta": {
"endpoint": "/api/v3/transit/western/retrograde",
"version": "3.0",
"zodiac": "tropical"
}
}