Skip to main content

astro96_api 0.3.0 copy "astro96_api: ^0.3.0" to clipboard
astro96_api: ^0.3.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.

Full guide (errors, retries, PDF and audio jobs, webhook verification): https://96astroapi.com/docs/sdk-dart

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.

Name your app (optional) #

Optional: tell the API which app is calling, so you can see where your keys are used (the dashboard's Where your keys are used) and spot a leaked key.

final astro = Astro96Client(apiKey: key, appName: 'Acme Shop', appVersion: '2.1.0', appUrl: 'https://shop.acme.com');

The name is required (printable ASCII, at most 60 characters, no / or parentheses); the version (at most 40) and the url (http(s), at most 120) are optional. It is sent as the X-Astro-App header, never with your key; the API keeps the name, the version and only the host of the url. The User-Agent also carries the platform (plt/node, plt/linux...). An invalid value is refused when the client is created. (ArgumentError) On the web the browser sets the User-Agent, so only the X-Astro-App header is added; elsewhere plt/android, plt/ios or plt/other is added.

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.

0
likes
0
points
61
downloads

Documentation

Documentation

Publisher

verified publisher96astroapi.com

Weekly Downloads

Official client for the 96Astro astrology API (kundli, panchang, horoscope, matching, PDF and audio reports), with retries and idempotency keys.

Homepage
View/report issues

Topics

#astrology #horoscope #api-client

License

unknown (license)

Dependencies

http

More

Packages that depend on astro96_api