Developers
Embeddable widgets
Put the Panchang, the daily horoscope or a birth chart form on your own website with one iframe. Widgets are part of the API plans: you create and manage them on your widgets page in the member area, and the plan sets how many you can have.
Get started
- Subscribe to an API plan on the pricing page.
- Create a widget (Panchang, horoscope or chart) and choose its settings.
- Add the domain where it will appear and verify it with a DNS record (below).
- Activate the widget, copy its embed code and paste it into your page.
Verify your domain
A widget only appears on domains you have verified. Add a DNS TXT record, then press Verify on the widget's page:
Name: _astratva-widget.<host>
Type: TXT
Value: astratva-widget-verification=<token>
<host> is your domain, for example temple.example.com, and <token> is the value the widget's page shows you. The domain must be a full domain name (not an IP address or a single word such as localhost) served on the standard HTTPS port 443: a port other than 443 is refused.
Embed it
Paste the iframe where the widget should appear. The code on your widget's page has your widget's own public id; this one is an example.
<iframe src="https://astratva.com/embed/v1/wgt_example123/frame" title="Daily Panchang" width="100%" height="480" style="border:0" loading="lazy" referrerpolicy="strict-origin-when-cross-origin" data-astratva-widget="wgt_example123"></iframe>
Keep the referrerpolicy attribute. The frame checks the address of the page that contains it against your verified domains. Without the attribute the browser may send no referrer, and the widget then shows the unavailable panel on your page instead of the content (this is not charged). A widget that is still a draft, or that has no verified domain yet, cannot be framed at all, so the browser shows its own blocked-frame message.
Optionally add the resize script, which fits the iframe to the height of the widget. It works for iframes that carry the data-astratva-widget attribute. Without it the iframe keeps the fixed height in the code.
<script src="https://astratva.com/embed/v1/resize.js" async></script>
If your page sets a Content-Security-Policy
Your page must allow the frame. Add this to its policy:
Content-Security-Policy: frame-src https://astratva.com
If you also use resize.js, add script-src https://astratva.com as well.
What a widget costs
Each successful widget view, date change, sign change or chart calculation costs 1 unit from the monthly quota of your API plan. It is the same quota as API requests. A refused or failed view is not charged.
Previews in the member area are free.
A view is charged to you when the request names one of your verified domains as the page it came from. Browsers set that referrer, but a script outside a browser can forge it, so someone could request your widget directly and spend your units. Each widget answers at most 120 views a minute from one IP address. Watch the view counts on your widget's page; if usage looks wrong, pause the widget and contact support.
When your plan has lapsed or the monthly quota is used up, your widgets show an "unavailable" panel instead of the content, and they work again when a plan is active or the quota resets on the 1st (UTC). The pricing page lists the quota, the number of widgets and the domains per widget for each plan.