Client SDK's
AstroAPI biedt client SDK's voor populaire programmeertalen. Deze SDK's zijn gegenereerd op basis van onze OpenAPI-specificatie en bieden type-veilige toegang tot alle API-endpoints.
Beschikbare SDK's
| Taal | Download | Beschrijving |
|---|---|---|
| TypeScript | Download | TypeScript-client met volledige typedefinities op basis van Fetch API |
| JavaScript | Download | JavaScript-client met Promise-gebaseerde API |
| Python | Download | Python-client met de requests-bibliotheek |
| PHP | Download | PHP-client met PSR-7 HTTP-ondersteuning |
Installatie
TypeScript / JavaScript
Pak de SDK uit en voeg deze toe aan uw project:
bash
unzip astroapi-sdk-typescript.zip -d ./astroapi-sdkImporteer en gebruik:
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
Pak uit en installeer afhankelijkheden:
bash
unzip astroapi-sdk-python.zip -d ./astroapi
cd astroapi
pip install -r requirements.txtGebruik:
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
Pak uit en installeer via Composer:
bash
unzip astroapi-sdk-php.zip -d ./astroapi
cd astroapi
composer installGebruik:
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-generatie
Als u een SDK voor een andere taal nodig heeft, kunt u er zelf een genereren:
bash
npx @openapitools/openapi-generator-cli generate \
-i https://api.astroapi.cloud/openapi \
-g <generator-name> \
-o ./outputZie de OpenAPI Generator-documentatie voor een volledige lijst van beschikbare generators.
Volgende stappen
- Aan de slag - Snelstartgids
- Authenticatie - API key-instelling
- API-referentie - Volledige endpoint-documentatie