API reference
Geo Location API
Birth-place search for astrology apps: 5.2M+ places worldwide including villages, districts and Indian PIN codes, names in local scripts, and the UTC offset that applied on a birth date.
https://astrologyapis.ratnoveda.com/v1/geo/searchOverview
/v1/geo/searchAutosuggest places by name or PIN code, as the user typesGET/v1/geo/reverseThe nearest town or village to a latitude and longitudeGET/v1/geo/timezoneTimezone and UTC offset at a place on a given local date and timePOST/v1/geo/bulkThe best match for up to 100 place names in one call- • Base URL:
https://astrologyapis.ratnoveda.com. Send your key in theX-API-Keyheader. - • Every answer is JSON:
{"success": true, "data": …, "meta": {…}}, or{"success": false, "error": {"code": …, "message": …}}(see errors).meta.credits_chargedis what the call cost. - • Coordinates are decimal degrees, north and east positive.
Choose your setup
A birth form needs one thing from this API: the place the user means, with its coordinates and timezone. Pick the setup that fits you.
Then send the picked place's latitude, longitude and timezone name with the birth date and time to the chart APIs (how).
API key and website key
| API key | Website key | |
|---|---|---|
| Use it from | Your server only. Keep it secret. | Your web pages. Safe to show in the page. |
| Works for | Every API | Only the Geo Location API (/v1/geo/…) |
| Works from | Anywhere | Only the websites you listed (the browser's Origin) |
| Rate limit | Per key | Per key, and per visitor |
| Credits | Your balance | The same balance |
Get a website key
- 1. Open Dashboard → API keys and click Edit on your key.
- 2. Add the websites that may use it (up to 20):
https://example.com,https://*.example.comfor all subdomains, orhttp://localhost:3000while you develop. - 3. Save. The website key appears under your key and can be copied again at any time.
A call from a website that is not in the list is refused with 403 ORIGIN_NOT_ALLOWED; add the website and it works straight away. Calls without an Origin (servers, mobile apps, cURL) are refused too: use your API key from your server for those.
Search places
https://astrologyapis.ratnoveda.com/v1/geo/searchSuggestions as the user types. Call it after each pause in typing, with a session token, and show the label of each result.
| Parameter | Type | Description |
|---|---|---|
qrequired | string | What the user typed, 2–100 characters: the start of a place name in any script (varan, वारा), or a PIN / postcode (221001). Text after a comma narrows by state, district or country: rampur, bihar. |
limitoptional | int | Suggestions to return, 1–20. Default 8. |
countryoptional | string | Only these countries: ISO-2 codes, comma separated, e.g. IN or IN,NP (up to 20). Omit for the whole world. |
langoptional | string | Also return each name in this language as local_name: ISO 639-1, e.g. hi, ta, bn, mr, ur, ar. |
sessionoptional | string | Your token for this search, 8–64 characters of A-Z a-z 0-9 _ -. Strongly recommended: see search sessions. |
How matching works
bara finds Bara Banki. Spaces do not matter: barabanki finds it too.budhiyapur finds Budhiapur.वारा finds Varanasi.221001 returns the post-office areas with that PIN, as kind: postcode.rampur, bihar puts the Rampurs of Bihar first; a district (budhiyapur, barabanki) or a country works too.# One session token per search box: only the first search of the session is charged. curl 'https://astrologyapis.ratnoveda.com/v1/geo/search?q=varan&country=IN&lang=hi&limit=8&session=4f9c2a7e1b' \ -H 'X-API-Key: YOUR_API_KEY' # A PIN code works too curl 'https://astrologyapis.ratnoveda.com/v1/geo/search?q=221001&session=4f9c2a7e1b' -H 'X-API-Key: YOUR_API_KEY'
{
"success": true,
"data": {
"query": "varan",
"results": [
{
"id": "gn:1253405",
"name": "Varanasi",
"local_name": "वाराणसी",
"ascii_name": "Varanasi",
"kind": "city",
"district": "Varanasi",
"state": "Uttar Pradesh",
"country_code": "IN",
"country": "India",
"postcode": null,
"label": "Varanasi, Uttar Pradesh, India",
"latitude": 25.3167,
"longitude": 83.0104,
"timezone": "Asia/Kolkata",
"utc_offset": 5.5,
"utc_offset_text": "+05:30",
"population": 1164404
},
{
"id": "gn:1252948",
"name": "Warangal",
"local_name": "वरंगल",
"ascii_name": "Warangal",
"kind": "city",
"district": "Hanamkonda",
"state": "Telangana",
"country_code": "IN",
"country": "India",
"postcode": null,
"label": "Warangal, Telangana, India",
"latitude": 18,
"longitude": 79.5833,
"timezone": "Asia/Kolkata",
"utc_offset": 5.5,
"utc_offset_text": "+05:30",
"population": 704570
},
{
"id": "gn:1253403",
"name": "Varangaon",
"local_name": null,
"ascii_name": "Varangaon",
"kind": "town",
"district": "Jalgaon",
"state": "Maharashtra",
"country_code": "IN",
"country": "India",
"postcode": null,
"label": "Varangaon, Jalgaon, Maharashtra, India",
"latitude": 21.0177,
"longitude": 75.9104,
"timezone": "Asia/Kolkata",
"utc_offset": 5.5,
"utc_offset_text": "+05:30",
"population": 44067
}
],
"session_charged": true
}
}session_charged is true when this search was charged: the first of a session, or any search without a token. No match is an empty results list, not an error.
The Place object
Search, reverse and bulk return places in this shape.
{
"id": "gn:1253405",
"name": "Varanasi",
"local_name": "वाराणसी",
"ascii_name": "Varanasi",
"kind": "city",
"district": "Varanasi",
"state": "Uttar Pradesh",
"country_code": "IN",
"country": "India",
"postcode": null,
"label": "Varanasi, Uttar Pradesh, India",
"latitude": 25.3167,
"longitude": 83.0104,
"timezone": "Asia/Kolkata",
"utc_offset": 5.5,
"utc_offset_text": "+05:30",
"population": 1164404
}| Parameter | Type | Description |
|---|---|---|
idrequired | string | gn:<number> for a place, pc:<number> for a postcode area. Use it to tell results apart. Store the coordinates and timezone with the birth details, not only the id: pc: ids can change when the data is refreshed. |
namerequired | string | Name in Latin script. |
local_namerequired | string | null | Name in the lang you asked for; null without lang, or when the place has no name in that language. |
ascii_namerequired | string | Name without accents. |
kindrequired | string | city, town, village, locality, district, state or postcode. |
districtrequired | string | null | District, when known. |
staterequired | string | null | State or province, when known. |
country_coderequired | string | ISO-2 country code. |
countryrequired | string | Country name. |
postcoderequired | string | null | The PIN / postcode; only for kind: postcode. |
labelrequired | string | Ready to show: name, district (for villages and localities), state and country, e.g. “Budhiapur, Bara Banki, Uttar Pradesh, India”. |
latituderequired | number | Decimal degrees, north positive, 4 decimals (about 11 m). |
longituderequired | number | Decimal degrees, east positive, 4 decimals. |
timezonerequired | string | null | IANA timezone, e.g. Asia/Kolkata. Send this name as the timezone to the chart APIs. |
utc_offsetrequired | number | null | UTC offset in hours now, e.g. 5.5. Not the offset of a birth date: see chart APIs. |
utc_offset_textrequired | string | null | The same as text, e.g. +05:30. |
populationrequired | int | Population; 0 when unknown (most villages and all postcode areas). |
Reverse geocoding
https://astrologyapis.ratnoveda.com/v1/geo/reverse?lat=25.3176&lon=82.9739&lang=hiThe nearest town, village or locality to a point (e.g. the phone's location), within about 330 km. lat and lon are required, lang is optional. distance_km is how far the place is from the point. With nothing within reach (open sea) the answer is 404 NOT_FOUND, not charged.
{
"success": true,
"data": {
"place": {
"id": "gn:10547153",
"name": "Lahartara",
"local_name": null,
"ascii_name": "Lahartara",
"kind": "locality",
"district": "Varanasi",
"state": "Uttar Pradesh",
"country_code": "IN",
"country": "India",
"postcode": null,
"label": "Lahartara, Varanasi, Uttar Pradesh, India",
"latitude": 25.3171,
"longitude": 82.9751,
"timezone": "Asia/Kolkata",
"utc_offset": 5.5,
"utc_offset_text": "+05:30",
"population": 0
},
"distance_km": 0.13
}
}Timezone for a birth date
https://astrologyapis.ratnoveda.com/v1/geo/timezone?lat=28.6139&lon=77.209&datetime=1943-05-10T10:30The UTC offset in force at a place at a local date and time, from the timezone history of that place: daylight saving, war time and changes of zone are counted. Use it when you need the offset itself; the chart APIs can work it out for you from the timezone name (see below).
| Parameter | Type | Description |
|---|---|---|
latrequired | number | Latitude, −90 to 90. |
lonrequired | number | Longitude, −180 to 180. |
datetimeoptional | string | The local clock time at that place, YYYY-MM-DDTHH:MM (seconds optional), e.g. the birth date and time. Default: now. |
curl 'https://astrologyapis.ratnoveda.com/v1/geo/timezone?lat=28.6139&lon=77.209&datetime=1943-05-10T10:30' \ -H 'X-API-Key: YOUR_API_KEY'
{
"success": true,
"data": {
"timezone": "Asia/Kolkata",
"datetime_local": "1943-05-10T10:30:00",
"datetime_utc": "1943-05-10T04:00:00Z",
"utc_offset": 6.5,
"utc_offset_text": "+06:30",
"utc_offset_seconds": 23400,
"is_dst": true,
"abbreviation": "+0630",
"local_mean_time_offset": 5.1473,
"local_mean_time_offset_text": "+05:08:50",
"notes": [
"Clocks were 01:00 ahead of standard time on this date (daylight saving or war time)"
]
}
}| Parameter | Type | Description |
|---|---|---|
timezonerequired | string | IANA timezone of the point. At sea, a fixed zone such as Etc/GMT+10. |
datetime_localrequired | string | The local date-time you sent (or now). |
datetime_utcrequired | string | The same moment in UTC. |
utc_offsetrequired | number | Hours east of UTC at that local time, e.g. 6.5. |
utc_offset_textrequired | string | e.g. +06:30. |
utc_offset_secondsrequired | int | The offset in seconds. |
is_dstrequired | boolean | True when clocks were ahead of standard time: daylight saving, or war time such as India 1942–45. |
abbreviationrequired | string | Zone abbreviation, e.g. IST, EDT, +0630 or LMT. |
local_mean_time_offsetrequired | number | Local mean time of this longitude (longitude ÷ 15), in hours. |
local_mean_time_offset_textrequired | string | e.g. +05:08:50. |
notesrequired | string[] | Plain-language notes on anything unusual; empty when there is nothing to say. |
Unusual times
- • A local time that did not exist (clocks jumped forward): the offset in force just before the jump is used, and
notessays so. - • A local time that happened twice (clocks went back): the first one is used, and
notessays so. - • Old dates follow the history too: in India, Madras time (
+05:21:10) until 1905. Before a place kept any standard time,abbreviationisLMTand the offset is the local mean time of the zone's main city;local_mean_time_offsetis the one for your exact coordinates, if your astrologer prefers it.
Bulk lookup
https://astrologyapis.ratnoveda.com/v1/geo/bulkThe best match for each of up to 100 place names, e.g. to geocode birth places you already have. Each item gets the first result that search would give, or null. Call it from your server.
| Parameter | Type | Description |
|---|---|---|
queriesrequired | object[] | 1–100 items. Each has q (2–100 characters, as in search) and an optional country (one ISO-2 code). |
langoptional | string | As in search: also return local_name in this language. |
{
"queries": [
{
"q": "Varanasi",
"country": "IN"
},
{
"q": "Madurai"
},
{
"q": "Nowhere-at-all"
}
],
"lang": "hi"
}{
"success": true,
"data": {
"results": [
{
"q": "Varanasi",
"place": {
"id": "gn:1253405",
"label": "Varanasi, Uttar Pradesh, India",
"latitude": 25.3167,
"longitude": 83.0104,
"timezone": "Asia/Kolkata",
"…": "…"
}
},
{
"q": "Madurai",
"place": {
"id": "gn:1264521",
"label": "Madurai, Tamil Nadu, India",
"latitude": 9.919,
"longitude": 78.1195,
"timezone": "Asia/Kolkata",
"…": "…"
}
},
{
"q": "Nowhere-at-all",
"place": null
}
],
"charged_items": 2
}
}Charged per place found (charged_items). Before it runs, your balance must cover every name in the request; otherwise the answer is 402 INSUFFICIENT_CREDITS and nothing is charged.
How you are charged
Each call spends credits from your balance. These are today's prices.
| Endpoint | You are charged | Price | Not charged |
|---|---|---|---|
GET /v1/geo/search | Once per search session (one person, one place). Without a session token: every search. | … | The other searches of the same session. |
GET /v1/geo/timezone | Every lookup. | … | — |
GET /v1/geo/reverse | Every lookup that finds a place. | … | No place nearby (404). |
POST /v1/geo/bulk | Every place found. | … | Names not found. Your balance must cover all the names of the request before it runs. |
- • Credits come from the same balance as every other API. Plans and top-ups are on the Pricing page.
- • Failed calls are never charged:
401,402,403,422,429and server errors. - • Every answer says what it cost in
meta.credits_charged; a search also saysdata.session_charged. Every call is listed in Dashboard → Usage. - • Chart APIs take the place's
timezonename and work out the offset for the birth date themselves, so you do not need a timezone lookup per birth.
Examples
Search sessions
An autosuggest box searches on every keystroke, but the user is looking for one place. A session groups those searches so you pay once. It is just a token you make and send as session: we never see your page or your users, only the searches that arrive with the same token from the same key. The widget does all of this for you.
A-Z a-z 0-9 _ -; a UUID is ideal. You make it in your page or app: there is no call to create one.geo.search), even if it finds nothing.var for Varanasi). A search that starts with other letters (mad) is a new place and starts a new, charged session. Typing on, or fixing a typo at the end, stays in the session./v1/geo/search has sessions. Timezone, reverse and bulk are charged per call.Example: one user, two searches
| The user | Request | session_charged |
|---|---|---|
| Opens the birth-place field | makes token a1b2c3d4 | — |
| Types va | q=va&session=a1b2c3d4 | true |
| Types r, a, n | 3 searches: var, vara, varan | false |
| Picks Varanasi | drops the token | — |
| Changes the place later | makes token e5f6a7b8 | — |
| Types ma | q=ma&session=e5f6a7b8 | true |
| Types d, u, r | 3 searches: mad, madu, madur | false |
8 searches, 2 charges. Without tokens the same 8 searches are 8 charges.
When to make a new token
Widget
One script tag turns any text box into a birth-place search: suggestions as the user types, keyboard and screen-reader support, and one session per search. It needs a website key. When the user picks a place, it fills the fields you name and fires geo:select.
<!-- Your website key: works only for the Geo API, only from the websites you listed. --> <input id="birth-place" placeholder="Birth place"> <input type="hidden" id="lat" name="latitude"> <input type="hidden" id="lon" name="longitude"> <input type="hidden" id="tz" name="timezone"> <script src="https://astrologyapis.ratnoveda.com/geo-widget.js" data-key="YOUR_WEBSITE_KEY" data-input="#birth-place" data-lang="hi" data-country="IN" data-lat="#lat" data-lon="#lon" data-tz="#tz"></script> <script> document.querySelector("#birth-place").addEventListener("geo:select", (e) => { console.log(e.detail); // the chosen Place }); </script>
| Parameter | Type | Description |
|---|---|---|
data-key · keyrequired | string | Your website key. |
data-inputoptional | selector | The input(s) to turn into a search, when you use the script tag alone. |
data-lang · langoptional | string | Also show names in this language. |
data-country · countryoptional | string | Only these countries: ISO-2 codes, comma separated. |
data-limit · limitoptional | int | Suggestions to show, 1–20 (default 8). |
data-lat / data-lon / data-tzoptional | selector | Fields to fill with the latitude, longitude and IANA timezone of the chosen place. |
data-api · apiUrloptional | string | API base URL. Default: the address the script was loaded from. |
onSelectoptional | function | Called with the chosen Place (JavaScript only). The input also fires a bubbling geo:select event with the Place in event.detail. |
Your own search box
Your own design, calling /v1/geo/search straight from the browser with your website key. Never put your API key in a page.
- • Wait for a pause in typing (about 150 ms) and cancel the previous request, so only the latest answer is shown.
- • Send one
sessiontoken per search and make a new one after the user picks a place. - • Keep the picked place's
latitude,longitudeandtimezonefor the chart APIs.
// usePlaceSearch.ts: your own search UI, calling the API from the browser with your website key. import { useEffect, useRef, useState } from "react"; export interface Place { id: string; label: string; local_name: string | null; latitude: number; longitude: number; timezone: string } const API = "https://astrologyapis.ratnoveda.com/v1/geo/search"; const WEBSITE_KEY = "YOUR_WEBSITE_KEY"; // safe in the page: Geo API only, only from your websites const newSession = () => crypto.randomUUID().replaceAll("-", ""); export function usePlaceSearch(q: string, { lang = "hi", country = "IN" } = {}) { const [results, setResults] = useState<Place[]>([]); const [error, setError] = useState<string | null>(null); const session = useRef(newSession()); // the keystrokes of one search are charged once useEffect(() => { if (q.trim().length < 2) return setResults([]); const ctrl = new AbortController(); const timer = setTimeout(async () => { const params = new URLSearchParams({ q, lang, country, limit: "8", session: session.current }); try { const res = await fetch(API + "?" + params, { headers: { "X-API-Key": WEBSITE_KEY }, signal: ctrl.signal }); const body = await res.json(); if (!body.success) throw new Error(body.error.message); // e.g. ORIGIN_NOT_ALLOWED setResults(body.data.results); setError(null); } catch (e) { if (!ctrl.signal.aborted) setError((e as Error).message); } }, 150); // wait for a pause in typing return () => { clearTimeout(timer); ctrl.abort(); }; }, [q, lang, country]); // After a pick: the next search is a new session. const reset = () => { session.current = newSession(); setResults([]); }; return { results, error, reset }; } // BirthPlaceSearch.tsx import { useState } from "react"; import { type Place, usePlaceSearch } from "./usePlaceSearch"; export function BirthPlaceSearch({ onSelect }: { onSelect: (place: Place) => void }) { const [q, setQ] = useState(""); const [picked, setPicked] = useState(false); const { results, error, reset } = usePlaceSearch(picked ? "" : q); return ( <div className="birth-place"> <input value={q} onChange={(e) => { setQ(e.target.value); setPicked(false); }} placeholder="Birth place" autoComplete="off" /> {error && <p role="alert">{error}</p>} <ul> {results.map((p) => ( <li key={p.id}> <button type="button" onClick={() => { setQ(p.label); setPicked(true); reset(); onSelect(p); }}> {p.label} {p.local_name && <small>{p.local_name}</small>} </button> </li> ))} </ul> </div> ); }
Through your server
For mobile apps, and websites that send every call through their own server. Your page or app calls your server; your server calls /v1/geo/search with your API key. The page or app makes the session token and sends it with each search, and your server passes it on unchanged. A new token made on the server for each request would make every search a charged one.
// In your web page: one token per place search. let session = null; placeInput.addEventListener("focus", () => { session ??= crypto.randomUUID().replaceAll("-", ""); // a new search starts }); placeInput.addEventListener("input", async () => { // Your own server, not ours: it adds your API key and passes the token through. const res = await fetch("/api/places?" + new URLSearchParams({ q: placeInput.value, session })); showSuggestions(await res.json()); }); function onPick(place) { session = null; // the next search is a new session // keep place.latitude, place.longitude, place.timezone } // Android / iOS / Flutter: the same idea. Make the token when the place field opens, // send it to your server with every search, and drop it when the user picks or leaves.
Send the place to the chart APIs
Send the picked place's latitude, longitude and timezone name with the birth date and time. The chart APIs apply the offset that was in force on that date: +06:30 for Delhi in 1943, +05:30 today, and daylight saving abroad.
{
"day": 10,
"month": 5,
"year": 1943,
"hour": 10,
"min": 30,
"latitude": 28.6139,
"longitude": 77.209,
"timezone": "Asia/Kolkata",
"place": "New Delhi, India"
}Do not send the place's utc_offset from search: it is today's offset and is wrong for many birth dates. If you send a number, take it from /v1/geo/timezone for the birth date and time.
astrologyapi-compatible calls
Already using geo_details and timezone_with_dst? They keep their request and answer format and use the same place data. They are priced like the other compatible calls (see Dashboard → Pricing); for new code, use the endpoints above.
curl -X POST 'https://astrologyapis.ratnoveda.com/v1/geo_details' \ -H 'X-API-Key: YOUR_API_KEY' -H 'Content-Type: application/json' \ -d '{"place": "Varanasi", "maxRows": 6}' # {"geonames": [{"place_name": "Varanasi, Uttar Pradesh, India", "latitude": 25.3167, # "longitude": "83.0104", "timezone_id": "Asia/Kolkata", "country_code": "IN"}, …]}
curl -X POST 'https://astrologyapis.ratnoveda.com/v1/timezone_with_dst' \ -H 'X-API-Key: YOUR_API_KEY' -H 'Content-Type: application/json' \ -d '{"latitude": 28.6139, "longitude": 77.209, "date": "05-10-1943"}' # {"status": true, "timezone": 6.5, "timezone_in_ms": 23400000, "date": "05-10-1943"}
timezone_with_dst gives the offset at noon on that date. For the exact birth time, use /v1/geo/timezone.
Rate limits
429 RATE_LIMIT_EXCEEDED, not charged. Wait for the seconds in the Retry-After header.Errors
Failed calls are never charged.
| Status | Code | Meaning |
|---|---|---|
| 401 | AUTHENTICATION_REQUIRED | No key sent |
| 401 | INVALID_API_KEY | Wrong, revoked or expired key |
| 402 | INSUFFICIENT_CREDITS | Not enough credits; top up and retry |
| 403 | ORIGIN_NOT_ALLOWED | A website key used from a website not in its list, or without an Origin (server, app) |
| 403 | BROWSER_KEY_GEO_ONLY | A website key used for an API other than /v1/geo/… |
| 404 | NOT_FOUND | Reverse geocoding: no place within about 330 km |
| 422 | VALIDATION_ERROR | A parameter is missing or invalid: q length, coordinates, datetime, country, lang, session or bulk size |
| 429 | RATE_LIMIT_EXCEEDED | Too many calls; wait for the Retry-After seconds |
| 503 | GEO_DATA_NOT_LOADED | The place data is being installed; retry shortly |