Integrate VedIntel™ AstroAPI into
any PHP project
Plain PHP, WordPress, or Laravel — three full working examples below. 127 Vedic astrology endpoints, one REST API, one key. cURL is the only dependency.
Fetch ascendant with basic cURL
A self-contained PHP function that calls the ascendant endpoint using curl_init(). Works in any PHP environment — cPanel hosting, VPS, shared hosting.
<?php
// -------------------------------------------------------
// VedIntel AstroAPI — Plain PHP cURL example
// -------------------------------------------------------
define('VEDINTEL_API_KEY', getenv('VEDINTEL_API_KEY') ?: 'vai_YOUR_KEY_HERE');
define('VEDINTEL_BASE_URL', 'https://vedintelastroapi.com/api/v1');
function vedintel_get_ascendant(
string $dob, // DD/MM/YYYY
string $tob, // HH:MM (24-hour)
float $lat,
float $lon,
float $tz = 5.5,
string $ayanamsa = 'lahiri'
): array {
$params = http_build_query([
'api_key' => VEDINTEL_API_KEY,
'dob' => $dob,
'tob' => $tob,
'lat' => $lat,
'lon' => $lon,
'tz' => $tz,
'ayanamsa' => $ayanamsa,
]);
$url = VEDINTEL_BASE_URL . '/extended-horoscope/find-ascendant?' . $params;
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => ['Accept: application/json'],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
throw new RuntimeException('cURL error: ' . $error);
}
$data = json_decode($body, true);
if ($data['status'] !== 200) {
throw new RuntimeException('API error: ' . ($data['error'] ?? 'Unknown'));
}
return $data['response'];
}
// Usage
$chart = vedintel_get_ascendant('01/10/1977', '11:40', lat: 11, lon: 77);
echo 'Ascendant: ' . $chart['ascendant'] . PHP_EOL;
echo 'Moon Sign: ' . $chart['moon_sign'] . PHP_EOL;
/*
Response:
{
"ascendant": "Scorpio",
"ascendant_lord": "Mars",
"degree": 22.47,
"nakshatra": "Jyeshtha",
"sun_sign": "Virgo",
"moon_sign": "Aries"
}
*/Panchang widget with WordPress transient cache
Uses WordPress's built-in HTTP API and transients for 1-hour caching — keeps your API call count low on high-traffic sites. Exposes a [vedintel_panchang] shortcode for any page or post.
<?php
/**
* VedIntel AstroAPI — WordPress Integration
*
* Add this to your theme's functions.php or a custom plugin.
* Uses WordPress's built-in wp_remote_get() — no extra libraries.
*/
// Store your key in wp-config.php:
// define( 'VEDINTEL_API_KEY', 'vai_YOUR_KEY_HERE' );
function vedintel_get_panchang( array $args = [] ): array|WP_Error {
$defaults = [
'lat' => 28.6139, // Delhi lat (override per user)
'lon' => 77.2090, // Delhi lon
'tz' => 5.5,
'date' => wp_date( 'd/m/Y' ), // Today in DD/MM/YYYY
];
$params = wp_parse_args( $args, $defaults );
$params['api_key'] = defined( 'VEDINTEL_API_KEY' ) ? VEDINTEL_API_KEY : '';
$url = add_query_arg(
$params,
'https://vedintelastroapi.com/api/v1/panchang/panchang'
);
// Cached for 1 hour (saves API calls on high-traffic sites)
$cache_key = 'vedintel_panchang_' . md5( $url );
$cached = get_transient( $cache_key );
if ( $cached !== false ) return $cached;
$response = wp_remote_get( $url, [
'timeout' => 10,
'headers' => [ 'Accept' => 'application/json' ],
] );
if ( is_wp_error( $response ) ) return $response;
$body = json_decode( wp_remote_retrieve_body( $response ), true );
if ( empty( $body['response'] ) ) {
return new WP_Error( 'vedintel_api', $body['error'] ?? 'API error' );
}
set_transient( $cache_key, $body['response'], HOUR_IN_SECONDS );
return $body['response'];
}
// Shortcode: [vedintel_panchang]
add_shortcode( 'vedintel_panchang', function () {
$panchang = vedintel_get_panchang();
if ( is_wp_error( $panchang ) ) return '<p>Panchang unavailable.</p>';
return sprintf(
'<div class="vedintel-panchang">
<p><strong>Tithi:</strong> %s</p>
<p><strong>Nakshatra:</strong> %s</p>
<p><strong>Yoga:</strong> %s</p>
<p><strong>Sunrise:</strong> %s · <strong>Sunset:</strong> %s</p>
</div>',
esc_html( $panchang['tithi'] ?? '' ),
esc_html( $panchang['nakshatra'] ?? '' ),
esc_html( $panchang['yoga'] ?? '' ),
esc_html( $panchang['sunrise'] ?? '' ),
esc_html( $panchang['sunset'] ?? '' )
);
} );
/*
* NOTE: If you prefer zero-code setup, install the
* VedIntel™ AstroAPI WordPress Plugin — available at:
* https://vedintelastroapi.com/wordpress
*
* It gives you drag-and-drop widgets for panchang,
* kundali charts, and dasha timelines — no PHP required.
*/Mahadasha lookup as a cached Laravel service
A clean service class using Laravel's Http facade. 24-hour cache means natal chart data is computed once and served instantly thereafter — matching our own permanent natal cache behaviour.
<?php
// app/Services/VedIntelService.php
namespace App\Services;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
class VedIntelService
{
private string $apiKey;
private string $baseUrl = 'https://vedintelastroapi.com/api/v1';
public function __construct()
{
$this->apiKey = config('services.vedintel.key');
}
/**
* Get Vimshottari Mahadasha for a birth chart.
*/
public function getMahadasha(
string $dob,
string $tob,
float $lat,
float $lon,
float $tz = 5.5
): array {
$cacheKey = 'vedintel_dasha_' . md5("$dob|$tob|$lat|$lon|$tz");
return Cache::remember($cacheKey, now()->addHours(24), function () use ($dob, $tob, $lat, $lon, $tz) {
$response = Http::timeout(10)->get(
$this->baseUrl . '/dashas/current-mahadasha-full',
[
'api_key' => $this->apiKey,
'dob' => $dob,
'tob' => $tob,
'lat' => $lat,
'lon' => $lon,
'tz' => $tz,
]
);
$data = $response->json();
if ($data['status'] !== 200) {
throw new \RuntimeException('VedIntel API error: ' . ($data['error'] ?? 'Unknown'));
}
return $data['response'];
});
}
}
// config/services.php — add:
// 'vedintel' => ['key' => env('VEDINTEL_API_KEY')],
// .env — add:
// VEDINTEL_API_KEY=vai_YOUR_KEY_HERE
// Usage in a Controller:
// $dasha = app(VedIntelService::class)->getMahadasha('01/10/1977','11:40',11,77);
/*
Response:
{
"major_period": {
"planet": "Saturn",
"start_date": "2017-10-29",
"end_date": "2036-10-29"
},
"sub_period": {
"planet": "Jupiter",
"start_date": "2025-12-04",
"end_date": "2028-05-16"
},
"current_dasha": "Saturn - Jupiter"
}
*/Built for PHP developers
Plain PHP support
Works with any PHP 7.4+ project. cURL is the only dependency — available everywhere.
WordPress plugin
Prefer zero-code? Install the VedIntel WordPress Plugin for drag-and-drop widgets.
Laravel ready
Uses Laravel's Http facade with Guzzle under the hood. Cache-backed for efficiency.
Secure key handling
Always store the key in environment variables. Never in source code or the database.
Transient caching
Use WordPress transients or Laravel Cache to minimise API calls on high-traffic pages.
23 languages
Pass lang=hi, lang=ta, lang=te etc. to receive responses in Hindi, Tamil, Telugu, and more.
PHP framework compatibility
Ready to integrate in PHP?
Free plan — 500 calls/month, all 127 endpoints, no credit card. Or install the WordPress plugin for zero-code setup.
Developer plan from ₹750/mo · $9/mo · 5,000 calls/month