astro96_api 0.2.0
astro96_api: ^0.2.0 copied to clipboard
Official client for the 96Astro astrology API (kundli, panchang, horoscope, matching, PDF and audio reports), with retries and idempotency keys.
96Astro API client for Dart and Flutter #
The official client for the 96Astro API: kundli, panchang, horoscopes, matching, numerology, Western
charts, and PDF and audio reports. Compiled and run in our tests on the oldest version named below: tools/sdk/thin_conformance/run.py checks its requests, retries and errors, and makes one real call to the API. Here each method takes a Map (or a JSON string) and returns the parsed response.
Install #
dart pub add astro96_api # or: flutter pub add astro96_api
It needs Dart 3 and depends only on package:http, so it runs on servers, the command line and every Flutter platform.
Use #
import 'package:astro96_api/astro96_api.dart';
final astro = Astro96Client(apiKey: apiKey);
final answer = await astro.planetPositions({
'datetime': '1990-10-18T14:30:00',
'timezone': 'Asia/Kolkata',
'latitude': 28.6139,
'longitude': 77.209,
});
print(answer['data']);
There is one method for each capability in the API reference, and every option the API
accepts can be passed in the request. PDF and MP3 reports use createPdfJob, createAudioJob and getJob.
Keys and Flutter apps #
Keep your secret key on your server, and never ship it in an app: anyone can extract it. In a Flutter app, call your own backend (which may itself use this package), and let the backend call the API.
Errors and retries #
An error answer raises Astro96Exception with the API's error code. Calls that fail with a retryable error are retried with the
same idempotency key, so they are never charged twice.