PHP code example of astroinsightapi / astroinsight-php-sdk
1. Go to this page and download the library: Download astroinsightapi/astroinsight-php-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
astroinsightapi / astroinsight-php-sdk example snippets
use AstroInsight\AstroClient;
$astro = new AstroClient(
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
baseUrl: 'https://json.astroinsightapi.com/api/v1', // Optional
language: 'en', // Optional (e.g. 'hi', 'es')
ayanamsha: 'lahiri' // Optional (e.g. 'raman', 'kp')
);
use AstroInsight\DTO\BirthDetails;
$birth = new BirthDetails(
day: 15,
month: 8,
year: 1995,
hour: 10,
min: 30,
sec: 0,
tzone: 5.5,
lat: 28.6139,
lon: 77.2090
);
// 1. Get Sun Bhinnashtakavarga
$sunAshtak = $astro->vedic->ashtakvarga->getPlanetAshtak('sun', $birth);
// 2. Fetch Major Vimshottari Dasha
$vimshottari = $astro->vedic->vimshottariDasha->getMajorDasha($birth);
// 3. Get Gemstone & Rudraksha Remedies
$gemstones = $astro->vedic->suggestions->getGemstoneSuggestions($birth);
// 4. Check Manglik Dosha
$manglik = $astro->vedic->horoscopeDosha->getManglikDosha($birth);
use AstroInsight\DTO\MatchInput;
$maleBirth = new BirthDetails(15, 8, 1995, 10, 30, lat: 28.6139, lon: 77.2090);
$femaleBirth = new BirthDetails(20, 11, 1997, 14, 15, lat: 19.0760, lon: 72.8777);
$matchInput = new MatchInput($maleBirth, $femaleBirth);
// Calculate Guna Milan
$gunaScore = $astro->vedic->matchMaking->getGunaMilan($matchInput);
// Daily Panchang
$panchang = $astro->vedic->panchang->getDailyPanchang($birth);
// Choghadiya Timings
$choghadiya = $astro->vedic->muhurta->getChoghadiya($birth);
// One Card Tarot Reading
$oneCard = $astro->tarot->getOneCardReading();
// Three Card Tarot Reading
$threeCard = $astro->tarot->getThreeCardReading();
// Yes / No Tarot Reading
$yesNo = $astro->tarot->getYesNoReading();
// Daily Horoscope for Leo
$leoDaily = $astro->horoscope->getDailyHoroscope('leo');
// Monthly Horoscope for Aries
$ariesMonthly = $astro->horoscope->getMonthlyHoroscope('aries');
// Switch language to Hindi
$astro->setLanguage('hi');
// Switch Ayanamsha calculation system
$astro->setAyanamsha('raman');
use AstroInsight\Exceptions\AuthenticationException;
use AstroInsight\Exceptions\ValidationException;
use AstroInsight\Exceptions\RateLimitException;
use AstroInsight\Exceptions\AstroException;
try {
$response = $astro->vedic->panchang->getDailyPanchang($birth);
} catch (AuthenticationException $e) {
echo "Invalid Client ID or Secret: " . $e->getMessage();
} catch (ValidationException $e) {
echo "Validation failed: " . $e->getMessage();
print_r($e->getErrors());
} catch (RateLimitException $e) {
echo "Rate limit exceeded. Try again later.";
} catch (AstroException $e) {
echo "API Error: " . $e->getMessage();
}
bash
composer bash
php composer.phar install
./vendor/bin/phpunit