โ† Integrations

No-code / CMS ยท JavaScript, JSON

A choghadiya planner in Retool: REST resource, query, table

Puja-booking desks, event planners and astrologers' assistants often want one screen: pick a city and a date, see the day's sixteen choghadiya windows. In Retool that is a resource, a query and a table - and the key stays in the resource, never in the app's JavaScript.

Updated

How this page was checked: Retool was not run. The request the query sends was executed with Node fetch against the in-memory API, and the transformer was executed on Node 24 with data bound to that real response, the way Retool binds it. The rows below are its output.

The resource holds the key

Create a REST API resource named AstroNode with base URL https://api.astronode.dev and one header, Authorization: Bearer aie_live_.... Queries that use a resource are sent from Retool's backend with the resource's configuration, so app users - who can open the browser's developer tools - never see the header. Only people allowed to edit resources can read it.

The way to undo that is a JavaScript query that calls fetch with the key in it: JavaScript queries run in each user's browser, so the key travels to every session. Keep AstroNode calls in resource queries.

The query

  • Components: a date input dateInput and a select city whose options carry lat, lng and tz (offset in minutes).
  • A query choghadiya on the AstroNode resource: method POST, path /v1/muhurta/choghadiya, JSON body as below. Let it run automatically when its inputs change, so the table follows the pickers.
  • A table whose data is {{ choghadiya.data }} - with a transformer enabled, that is the transformer's output, not the raw response.

Body - the {{ }} parts are evaluated by Retool; numbers stay unquoted:

json
{
  "date": "{{ dateInput.value }}",
  "tz_offset_minutes": {{ city.selectedItem.tz }},
  "lat": {{ city.selectedItem.lat }},
  "lng": {{ city.selectedItem.lng }}
}

The transformer

The response has two arrays, day and night, of eight windows each, with start and end as UTC instants. The transformer merges them and converts the times to the chosen place's clock - not the browser's, since an operator in Dubai may be planning a ceremony in Bengaluru:

Transformer on the choghadiya query:

js
// Query transformer: `data` is the parsed response body.
const offset = {{ city.selectedItem.tz }}; // the place's offset, the same number sent in the body
const hhmm = (iso) => new Date(Date.parse(iso) + offset * 60000).toISOString().slice(11, 16);

return [...data.data.day.map((w) => ({ ...w, half: "Day" })), ...data.data.night.map((w) => ({ ...w, half: "Night" }))].map((w) => ({
  half: w.half,
  name: w.name,
  from: hhmm(w.start),
  to: hhmm(w.end),
  quality: w.quality,
  lord: w.lord,
}));
Bengaluru, Monday 7 December 2026 (IST), first ten of sixteen rows
halfnamefromtoqualitylord
DayAmrit06:2907:54auspiciousMoon
DayKaal07:5409:20inauspiciousSaturn
DayShubh09:2010:45auspiciousJupiter
DayRog10:4512:10inauspiciousMars
DayUdveg12:1013:36inauspiciousSun
DayChar13:3615:01neutralVenus
DayLabh15:0116:27auspiciousMercury
DayAmrit16:2717:52auspiciousMoon
NightChar17:5219:27neutralVenus
NightRog19:2721:01inauspiciousMars

Day windows are an eighth of sunrise-to-sunset (about 85 minutes here, in December), night windows an eighth of sunset to the next sunrise (about 95), so the last night window ends at the next morning's sunrise, 06:29. Colour rows by quality in the table's row colour setting. Window rules: muhurta time windows.

The mistakes that bite first

  • A date with a time. If the date component's value includes a time or offset (2026-12-07T00:00:00.000+05:30), the API returns 400 with date must be ISO YYYY-MM-DD. Set the component's value format to a plain date, or send only the first ten characters.
  • Hard-coding the offset in the transformer. The run above used 330 for Bengaluru; a city list with a London entry needs 0. Read it from the same selected item the body uses, as shown.
  • The plan. /v1/muhurta/choghadiya is a Hobby endpoint; a Free key's query fails with 403 PLAN_REQUIRED. Retool shows that as a query error, so put the API's error.message in the failure notification rather than a generic "query failed".

Questions

Which AstroNode endpoints does the Retool example call?
1 endpoint: Choghadiya (POST /v1/muhurta/choghadiya).
Was the Retool code on this page actually run?
Retool was not run. The request the query sends was executed with Node fetch against the in-memory API, and the transformer was executed on Node 24 with data bound to that real response, the way Retool binds it. The rows below are its output.