Autocomplete Indian PIN Codes as users type
Send the first digits, get matching PIN Codes with their city and state, as 400001, Mumbai, Maharashtra, or with each post office area. One REST call for any PIN Code field.
What comes back
PIN Codes that start with the digits sent, each with its city and state, and with the post office area in formats 2 and 3.
"400001, Mumbai, Maharashtra" "400002, Mumbai, Maharashtra" "400003, Mumbai, Maharashtra" "400004, Mumbai, Maharashtra" "400005, Mumbai, Maharashtra"
"400001, Bazargate, Mumbai, Maharashtra" "400001, Mpt, Mumbai, Maharashtra" "400001, Mumbai Gpo, Mumbai, Maharashtra" "400001, Mumbai, Mumbai G.P.O., Mumbai, Maharashtra"
What you get
A valid PIN Code with its city and state, picked from a list instead of typed by hand.
Four formats
Post office areas
From the first digits
One plan, three lookups
Common use cases
Two calls, any language
Get a token, then send what the user typed. Every example is a complete program, tested against the live API.
# Step 1: Get your auth token (uses jq to read Result.access_token) TOKEN=$(curl -s "https://api.sthan.io/Auth/Token" \ -H "profileName: YOUR_PROFILE_NAME" \ -H "profilePassword: YOUR_PROFILE_PASSWORD" | jq -r '.Result.access_token') # Step 2: Make the API call curl -s "https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000" \ -H "Authorization: Bearer $TOKEN"
// Node.js 18+ (save as example.mjs, run: node example.mjs) // Step 1: Get your auth token const auth = await fetch("https://api.sthan.io/Auth/Token", { headers: { profileName: "YOUR_PROFILE_NAME", profilePassword: "YOUR_PROFILE_PASSWORD" } }); if (!auth.ok) throw new Error(`Auth failed: ${auth.status}`); const { access_token } = (await auth.json()).Result; // Step 2: Make the API call const response = await fetch("https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000", { headers: { Authorization: `Bearer ${access_token}` } }); console.log(await response.json());
import requests # Step 1: Get your auth token auth = requests.get( "https://api.sthan.io/Auth/Token", headers={"profileName": "YOUR_PROFILE_NAME", "profilePassword": "YOUR_PROFILE_PASSWORD"}, timeout=10, ) auth.raise_for_status() token = auth.json()["Result"]["access_token"] # Step 2: Make the API call response = requests.get("https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000", headers={"Authorization": f"Bearer {token}"}, timeout=10) response.raise_for_status() print(response.json())
// .NET 6+ console app (Program.cs) using System.Net.Http.Headers; using System.Text.Json; using var client = new HttpClient(); // Step 1: Get your auth token var authRequest = new HttpRequestMessage(HttpMethod.Get, "https://api.sthan.io/Auth/Token"); authRequest.Headers.Add("profileName", "YOUR_PROFILE_NAME"); authRequest.Headers.Add("profilePassword", "YOUR_PROFILE_PASSWORD"); using var authResponse = await client.SendAsync(authRequest); authResponse.EnsureSuccessStatusCode(); using var authJson = JsonDocument.Parse(await authResponse.Content.ReadAsStringAsync()); var token = authJson.RootElement.GetProperty("Result").GetProperty("access_token").GetString(); // Step 2: Make the API call client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var response = await client.GetStringAsync("https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000"); Console.WriteLine(response);
// Java 11+, no extra libraries. Save as Example.java, run: java Example.java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example { public static void main(String[] args) throws Exception { HttpClient client = HttpClient.newHttpClient(); // Step 1: Get your auth token HttpRequest authRequest = HttpRequest.newBuilder(URI.create("https://api.sthan.io/Auth/Token")) .header("profileName", "YOUR_PROFILE_NAME") .header("profilePassword", "YOUR_PROFILE_PASSWORD") .build(); String authBody = client.send(authRequest, HttpResponse.BodyHandlers.ofString()).body(); // The token is at Result.access_token (read it with your JSON library, or like this) Matcher m = Pattern.compile("\"access_token\"\\s*:\\s*\"([^\"]+)\"").matcher(authBody); if (!m.find()) throw new IllegalStateException("No token in: " + authBody); String token = m.group(1); // Step 2: Make the API call HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000")) .header("Authorization", "Bearer " + token) .build(); System.out.println(client.send(request, HttpResponse.BodyHandlers.ofString()).body()); } }
<?php // PHP 7.4+ with the curl extension // Step 1: Get your auth token $ch = curl_init("https://api.sthan.io/Auth/Token"); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ["profileName: YOUR_PROFILE_NAME", "profilePassword: YOUR_PROFILE_PASSWORD"], CURLOPT_RETURNTRANSFER => true, ]); $auth = json_decode(curl_exec($ch), true); $token = $auth["Result"]["access_token"]; // Step 2: Make the API call $ch = curl_init("https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000"); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ["Authorization: Bearer " . $token], CURLOPT_RETURNTRANSFER => true, ]); echo curl_exec($ch), PHP_EOL;
require "net/http" require "json" # Step 1: Get your auth token uri = URI("https://api.sthan.io/Auth/Token") req = Net::HTTP::Get.new(uri) req["profileName"] = "YOUR_PROFILE_NAME" req["profilePassword"] = "YOUR_PROFILE_PASSWORD" res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) } token = JSON.parse(res.body)["Result"]["access_token"] # Step 2: Make the API call uri = URI("https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000") req = Net::HTTP::Get.new(uri) req["Authorization"] = "Bearer #{token}" res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) } puts JSON.parse(res.body)
package main import ( "encoding/json" "fmt" "io" "net/http" ) func main() { // Step 1: Get your auth token authReq, _ := http.NewRequest("GET", "https://api.sthan.io/Auth/Token", nil) authReq.Header.Set("profileName", "YOUR_PROFILE_NAME") authReq.Header.Set("profilePassword", "YOUR_PROFILE_PASSWORD") authResp, err := http.DefaultClient.Do(authReq) if err != nil { panic(err) } defer authResp.Body.Close() var auth struct { Result struct { AccessToken string `json:"access_token"` } } if err := json.NewDecoder(authResp.Body).Decode(&auth); err != nil { panic(err) } // Step 2: Make the API call req, _ := http.NewRequest("GET", "https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000", nil) req.Header.Set("Authorization", "Bearer "+auth.Result.AccessToken) resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }
// Cargo.toml: reqwest = { version = "0.12", features = ["json"] } // tokio = { version = "1", features = ["full"] }, serde_json = "1" #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let client = reqwest::Client::new(); // Step 1: Get your auth token let auth: serde_json::Value = client .get("https://api.sthan.io/Auth/Token") .header("profileName", "YOUR_PROFILE_NAME") .header("profilePassword", "YOUR_PROFILE_PASSWORD") .send() .await? .error_for_status()? .json() .await?; let token = auth["Result"]["access_token"].as_str().ok_or("no token in response")?; // Step 2: Make the API call let body = client .get("https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000") .bearer_auth(token) .send() .await? .text() .await?; println!("{body}"); Ok(()) }
// Kotlin (JVM 11+), no extra libraries import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse fun main() { val client = HttpClient.newHttpClient() // Step 1: Get your auth token val authRequest = HttpRequest.newBuilder(URI.create("https://api.sthan.io/Auth/Token")) .header("profileName", "YOUR_PROFILE_NAME") .header("profilePassword", "YOUR_PROFILE_PASSWORD") .build() val authBody = client.send(authRequest, HttpResponse.BodyHandlers.ofString()).body() // The token is at Result.access_token (read it with your JSON library, or like this) val token = Regex("\"access_token\"\\s*:\\s*\"([^\"]+)\"").find(authBody)?.groupValues?.get(1) ?: error("No token in: $authBody") // Step 2: Make the API call val request = HttpRequest.newBuilder(URI.create("https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000")) .header("Authorization", "Bearer $token") .build() println(client.send(request, HttpResponse.BodyHandlers.ofString()).body()) }
# Run as a script: elixir example.exs # (in a Mix project, add {:req, "~> 0.5"} to deps and drop the next line) Mix.install([{:req, "~> 0.5"}]) # Step 1: Get your auth token auth = Req.get!("https://api.sthan.io/Auth/Token", headers: [{"profileName", "YOUR_PROFILE_NAME"}, {"profilePassword", "YOUR_PROFILE_PASSWORD"}] ) token = auth.body["Result"]["access_token"] # Step 2: Make the API call response = Req.get!("https://api.sthan.io/AutoComplete/Ind/PinCode/DisplayType/0/4000", auth: {:bearer, token}) IO.inspect(response.body)
{
"Result": [
"400001, Mumbai, Maharashtra",
"400002, Mumbai, Maharashtra",
"400003, Mumbai, Maharashtra",
"400004, Mumbai, Maharashtra",
"400005, Mumbai, Maharashtra"
],
"StatusCode": 200,
"IsError": false
}
Start free, scale when you need to
10,000 free requests a month (up to 1,000 a day), no credit card. Paid plans start at $2 a month for 50,000 requests.
One India plan covers City, Locality and PIN Code autocomplete. Free tier limits: 120 a minute, 500 an hour, 1,000 a day. Higher volumes and annual discounts on the plans page.
Questions developers ask
/AutoComplete/Ind/PinCode/DisplayType/0/4000.Add PIN Code autocomplete in two minutes
Sign up, copy your key, make the call. 10,000 requests a month, free.
Get your free API key