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.

GEThttps://astrologyapis.ratnoveda.com/v1/geo/search

Overview

  • • Base URL: https://astrologyapis.ratnoveda.com. Send your key in the X-API-Key header.
  • • Every answer is JSON: {"success": true, "data": …, "meta": {…}}, or {"success": false, "error": {"code": …, "message": …}} (see errors). meta.credits_charged is 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.

WidgetA website, with no coding: paste one script tag. Uses your website key.
Your own search boxA website with your own design (React, Angular, plain JavaScript): the page calls the API with your website key.
Through your serverA mobile app, or a website that sends every call through its own server: the server calls the API with your API key.
Bulk lookupBirth places you already have as text: up to 100 per call, from your server.

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 keyWebsite key
Use it fromYour server only. Keep it secret.Your web pages. Safe to show in the page.
Works forEvery APIOnly the Geo Location API (/v1/geo/…)
Works fromAnywhereOnly the websites you listed (the browser's Origin)
Rate limitPer keyPer key, and per visitor
CreditsYour balanceThe same balance

Get a website key

  1. 1. Open Dashboard → API keys and click Edit on your key.
  2. 2. Add the websites that may use it (up to 20): https://example.com, https://*.example.com for all subdomains, or http://localhost:3000 while you develop.
  3. 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.

The Place object

Search, reverse and bulk return places in this shape.

Place
{
  "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
}
ParameterTypeDescription
idrequiredstringgn:<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.
namerequiredstringName in Latin script.
local_namerequiredstring | nullName in the lang you asked for; null without lang, or when the place has no name in that language.
ascii_namerequiredstringName without accents.
kindrequiredstringcity, town, village, locality, district, state or postcode.
districtrequiredstring | nullDistrict, when known.
staterequiredstring | nullState or province, when known.
country_coderequiredstringISO-2 country code.
countryrequiredstringCountry name.
postcoderequiredstring | nullThe PIN / postcode; only for kind: postcode.
labelrequiredstringReady to show: name, district (for villages and localities), state and country, e.g. “Budhiapur, Bara Banki, Uttar Pradesh, India”.
latituderequirednumberDecimal degrees, north positive, 4 decimals (about 11 m).
longituderequirednumberDecimal degrees, east positive, 4 decimals.
timezonerequiredstring | nullIANA timezone, e.g. Asia/Kolkata. Send this name as the timezone to the chart APIs.
utc_offsetrequirednumber | nullUTC offset in hours now, e.g. 5.5. Not the offset of a birth date: see chart APIs.
utc_offset_textrequiredstring | nullThe same as text, e.g. +05:30.
populationrequiredintPopulation; 0 when unknown (most villages and all postcode areas).

Reverse geocoding

GEThttps://astrologyapis.ratnoveda.com/v1/geo/reverse?lat=25.3176&lon=82.9739&lang=hi

The 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.

200 OK
{
  "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

GEThttps://astrologyapis.ratnoveda.com/v1/geo/timezone?lat=28.6139&lon=77.209&datetime=1943-05-10T10:30

The 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).

ParameterTypeDescription
latrequirednumberLatitude, −90 to 90.
lonrequirednumberLongitude, −180 to 180.
datetimeoptionalstringThe 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'
200 OK · Delhi, 10 May 1943, 10:30
{
  "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)"
    ]
  }
}
ParameterTypeDescription
timezonerequiredstringIANA timezone of the point. At sea, a fixed zone such as Etc/GMT+10.
datetime_localrequiredstringThe local date-time you sent (or now).
datetime_utcrequiredstringThe same moment in UTC.
utc_offsetrequirednumberHours east of UTC at that local time, e.g. 6.5.
utc_offset_textrequiredstringe.g. +06:30.
utc_offset_secondsrequiredintThe offset in seconds.
is_dstrequiredbooleanTrue when clocks were ahead of standard time: daylight saving, or war time such as India 1942–45.
abbreviationrequiredstringZone abbreviation, e.g. IST, EDT, +0630 or LMT.
local_mean_time_offsetrequirednumberLocal mean time of this longitude (longitude ÷ 15), in hours.
local_mean_time_offset_textrequiredstringe.g. +05:08:50.
notesrequiredstring[]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 notes says so.
  • • A local time that happened twice (clocks went back): the first one is used, and notes says so.
  • • Old dates follow the history too: in India, Madras time (+05:21:10) until 1905. Before a place kept any standard time, abbreviation is LMT and the offset is the local mean time of the zone's main city; local_mean_time_offset is the one for your exact coordinates, if your astrologer prefers it.

Bulk lookup

POSThttps://astrologyapis.ratnoveda.com/v1/geo/bulk

The 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.

ParameterTypeDescription
queriesrequiredobject[]1–100 items. Each has q (2–100 characters, as in search) and an optional country (one ISO-2 code).
langoptionalstringAs in search: also return local_name in this language.
Request body
{
  "queries": [
    {
      "q": "Varanasi",
      "country": "IN"
    },
    {
      "q": "Madurai"
    },
    {
      "q": "Nowhere-at-all"
    }
  ],
  "lang": "hi"
}
200 OK · places shortened
{
  "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.

EndpointYou are chargedPriceNot charged
GET /v1/geo/searchOnce per search session (one person, one place). Without a session token: every search.…The other searches of the same session.
GET /v1/geo/timezoneEvery lookup.…—
GET /v1/geo/reverseEvery lookup that finds a place.…No place nearby (404).
POST /v1/geo/bulkEvery 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, 429 and server errors.
  • • Every answer says what it cost in meta.credits_charged; a search also says data.session_charged. Every call is listed in Dashboard → Usage.
  • • Chart APIs take the place's timezone name and work out the offset for the birth date themselves, so you do not need a timezone lookup per birth.

Examples

A user types “varanasi” in your birth form and picks it1 search session…
The same typing without a session token7 searches (va … varanasi)…
10,000 users a month, each picking a birth place once10,000 search sessions…
100 stored birth places sent to bulk, 92 found92 places found…

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.

The tokenAny random text of 8–64 characters 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.
First searchThe first search with a new token is charged once (geo.search), even if it finds nothing.
Then freeLater searches for the same place with the same token are free, for 5 minutes from the first search or 20 searches, whichever comes first.
One placeA session is one place. It remembers how its first search starts (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.
After thatThe same token starts a new session, charged once again. A token reused by mistake never causes an error.
One token for all usersGains nothing: each user looks for another place, so each search starts a new session and is charged, as without a token.
Per keySessions belong to the key that sent them. Your API key and your website key never share a session, and nobody else can use yours.
No tokenEvery search is charged. Fine when the user types the whole name and presses Search once.
Other endpointsOnly /v1/geo/search has sessions. Timezone, reverse and bulk are charged per call.

Example: one user, two searches

The userRequestsession_charged
Opens the birth-place fieldmakes token a1b2c3d4—
Types vaq=va&session=a1b2c3d4true
Types r, a, n3 searches: var, vara, varanfalse
Picks Varanasidrops the token—
Changes the place latermakes token e5f6a7b8—
Types maq=ma&session=e5f6a7b8true
Types d, u, r3 searches: mad, madu, madurfalse

8 searches, 2 charges. Without tokens the same 8 searches are 8 charges.

When to make a new token

WebsiteWhen the place box gets focus or the first letter is typed. Drop it when the user picks a place, so a later change is a new search.
Mobile appWhen the place field or screen opens. Drop it when the user picks a place or leaves the screen.
Several place fieldsOne token per field, e.g. the boy's and the girl's birth place in a matching form.
A place typed in fullA form or chatbot that searches once, after the user presses Search: no token is needed.
Places you already haveFrom a file or a database: use bulk lookup instead.

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>
ParameterTypeDescription
data-key · keyrequiredstringYour website key.
data-inputoptionalselectorThe input(s) to turn into a search, when you use the script tag alone.
data-lang · langoptionalstringAlso show names in this language.
data-country · countryoptionalstringOnly these countries: ISO-2 codes, comma separated.
data-limit · limitoptionalintSuggestions to show, 1–20 (default 8).
data-lat / data-lon / data-tzoptionalselectorFields to fill with the latitude, longitude and IANA timezone of the chosen place.
data-api · apiUrloptionalstringAPI base URL. Default: the address the script was loaded from.
onSelectoptionalfunctionCalled with the chosen Place (JavaScript only). The input also fires a bubbling geo:select event with the Place in event.detail.

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.

Kundli Report body (birth part)
{
  "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.

POST /v1/geo_details · place, maxRows (1–50, default 6)
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"}, …]}
POST /v1/timezone_with_dst · latitude, longitude, date (mm-dd-yyyy, default today)
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

Per key1,200 calls a minute, 30,000 an hour and 300,000 a day, unless your key has its own limits.
Per website visitorWith a website key, each visitor (IP address) can make up to 120 calls a minute, 2,000 an hour and 10,000 a day.
When exceeded429 RATE_LIMIT_EXCEEDED, not charged. Wait for the seconds in the Retry-After header.

Errors

Failed calls are never charged.

StatusCodeMeaning
401AUTHENTICATION_REQUIREDNo key sent
401INVALID_API_KEYWrong, revoked or expired key
402INSUFFICIENT_CREDITSNot enough credits; top up and retry
403ORIGIN_NOT_ALLOWEDA website key used from a website not in its list, or without an Origin (server, app)
403BROWSER_KEY_GEO_ONLYA website key used for an API other than /v1/geo/…
404NOT_FOUNDReverse geocoding: no place within about 330 km
422VALIDATION_ERRORA parameter is missing or invalid: q length, coordinates, datetime, country, lang, session or bulk size
429RATE_LIMIT_EXCEEDEDToo many calls; wait for the Retry-After seconds
503GEO_DATA_NOT_LOADEDThe place data is being installed; retry shortly