Client-SDKs
AstroAPI stellt Client-SDKs für gängige Programmiersprachen bereit. Diese SDKs werden aus unserer OpenAPI-Spezifikation generiert und bieten typsicheren Zugriff auf alle API-Endpunkte.
Verfügbare SDKs
| Sprache | Download | Beschreibung |
|---|---|---|
| TypeScript | Herunterladen | TypeScript-Client mit vollständigen Typdefinitionen über die Fetch API |
| JavaScript | Herunterladen | JavaScript-Client mit Promise-basierter API |
| Python | Herunterladen | Python-Client, der die requests-Bibliothek verwendet |
| PHP | Herunterladen | PHP-Client mit PSR-7-HTTP-Unterstützung |
Installation
TypeScript / JavaScript
Entpacken Sie das SDK und fügen Sie es Ihrem Projekt hinzu:
bash
unzip astroapi-sdk-typescript.zip -d ./astroapi-sdkImportieren und verwenden:
typescript
import { Configuration, CalculationsApi } from "./astroapi-sdk";
const config = new Configuration({
basePath: "https://api.astroapi.cloud",
headers: {
"X-Api-Key": "your-api-key"
}
});
const api = new CalculationsApi(config);
const chart = await api.postApiCalcNatal({
datetime: "1990-06-15T14:30:00",
latitude: 51.5074,
longitude: -0.1278,
timezone: "Europe/London"
});Python
Entpacken und Abhängigkeiten installieren:
bash
unzip astroapi-sdk-python.zip -d ./astroapi
cd astroapi
pip install -r requirements.txtVerwendung:
python
from astroapi import Configuration, ApiClient, CalculationsApi
configuration = Configuration(
host="https://api.astroapi.cloud"
)
configuration.api_key["X-Api-Key"] = "your-api-key"
with ApiClient(configuration) as api_client:
api = CalculationsApi(api_client)
chart = api.post_api_calc_natal(
datetime="1990-06-15T14:30:00",
latitude=51.5074,
longitude=-0.1278,
timezone="Europe/London"
)PHP
Entpacken und über Composer installieren:
bash
unzip astroapi-sdk-php.zip -d ./astroapi
cd astroapi
composer installVerwendung:
php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$config = AstroAPI\Configuration::getDefaultConfiguration()
->setHost('https://api.astroapi.cloud')
->setApiKey('X-Api-Key', 'your-api-key');
$apiInstance = new AstroAPI\Api\CalculationsApi(
new GuzzleHttp\Client(),
$config
);
$chart = $apiInstance->postApiCalcNatal(
'1990-06-15T14:30:00',
51.5074,
-0.1278,
'Europe/London'
);SDK-Generierung
Wenn Sie ein SDK für eine andere Sprache benötigen, können Sie es selbst generieren:
bash
npx @openapitools/openapi-generator-cli generate \
-i https://api.astroapi.cloud/openapi \
-g <generator-name> \
-o ./outputEine vollständige Liste der verfügbaren Generatoren finden Sie in der OpenAPI-Generator-Dokumentation.
Nächste Schritte
- Erste Schritte – Schnellstartanleitung
- Authentifizierung – API-Schlüssel einrichten
- API-Referenz – Vollständige Endpunkt-Dokumentation