PHP code example of astroway / sdk
1. Go to this page and download the library: Download astroway/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/ */
astroway / sdk example snippets
$aw = new Astroway([
'apiKey' => getenv('ASTROWAY_API_KEY'),
'httpClient' => $myPsr18Client, // any Psr\Http\Client\ClientInterface
'requestFactory'=> $myRequestFactory, // optional Psr\Http\Message\RequestFactoryInterface
'streamFactory' => $myStreamFactory, // optional Psr\Http\Message\StreamFactoryInterface
]);
use Astroway\Astroway;
$aw = new Astroway(['apiKey' => getenv('ASTROWAY_API_KEY')]);
$chart = $aw->chart()->compute([
'date' => '1990-07-14',
'time' => '14:30:00',
'timezoneOffset' => 3,
'latitude' => 50.45,
'longitude' => 30.52,
'houseSystem' => 'P',
]);
$asc = $chart['angles']['asc'];
printf("ASC: %s %.2f°\n", $asc['sign'], $asc['degree']);
$result = $aw->synastry()->compute([
'chart1' => ['date' => '1990-07-14', 'time' => '14:30:00', 'timezoneOffset' => 3, 'latitude' => 50.45, 'longitude' => 30.52],
'chart2' => ['date' => '1992-03-22', 'time' => '09:15:00', 'timezoneOffset' => 2, 'latitude' => 48.85, 'longitude' => 2.35],
]);
echo "Score: {$result['compatibility']['score']}/100 ({$result['compatibility']['label']})\n";
$transits = $aw->transits()->compute([
'date' => '1990-07-14', 'time' => '14:30:00', 'timezoneOffset' => 3, 'latitude' => 50.45, 'longitude' => 30.52,
'targetDate' => '2027-01-01',
]);
$dasha = $aw->vedic()->dashasVimshottariMaha([
'date' => '1985-07-22', 'time' => '06:45:00', 'timezoneOffset' => 5.5,
'latitude' => 19.07, 'longitude' => 72.87,
]);
$card = $aw->tarot()->riderWaiteDaily(['seed' => 42]);
$hd = $aw->humanDesign()->compute([
'date' => '1990-07-14', 'time' => '14:30:00', 'timezoneOffset' => 3, 'latitude' => 50.45, 'longitude' => 30.52,
]);
echo "{$hd['type']} — {$hd['strategy']} — {$hd['authority']}\n";
use Astroway\Errors\ApiError;
use Astroway\Errors\AuthenticationError;
use Astroway\Errors\BadRequestError;
use Astroway\Errors\RateLimitError;
try {
$aw->post('/chart', body: $body);
} catch (RateLimitError $e) {
sleep($e->retryAfterSeconds ?? 60);
// retry once...
} catch (AuthenticationError $e) {
throw new RuntimeException('Rotate your AstroWay API key');
} catch (BadRequestError $e) {
fwrite(STDERR, 'Validation failed: ' . json_encode($e->body) . PHP_EOL);
} catch (ApiError $e) {
fwrite(STDERR, sprintf("API error %d (%s): %s [request_id=%s]\n", $e->status, $e->errorCode, $e->getMessage(), $e->requestId));
}
$aw = new Astroway([
'apiKey' => 'aw_live_...', // ing / self-hosted
'authScheme' => 'header', // 'header' (X-Api-Key, default) or 'bearer' (Authorization: Bearer)
'retry' => [
'maxRetries' => 2, // total attempts = 1 + maxRetries
'baseDelayMs' => 250,
'maxDelayMs' => 30_000,
'retryableStatuses' => [408, 409, 429, 500, 502, 503, 504],
],
'defaultHeaders' => ['X-Trace-Id' => '...'],
'httpClient' => null, // any PSR-18 ClientInterface (auto-discovered if omitted)
'requestFactory' => null, // any PSR-17 RequestFactoryInterface (auto-discovered)
'streamFactory' => null, // any PSR-17 StreamFactoryInterface (auto-discovered)
]);