Using Google Maps Geocoding API
API doc: Geocoding API overview | Google for Developers
Here's a step-by-step guide to using the Google Maps Geocoding API to get the latitude and longitude of an Indian pincode:
Get an API Key: Sign up for the Google Cloud Platform, enable the Geocoding API, and get an API key.
API Request Format: The request URL format for the Geocoding API is:
https://maps.googleapis.com/maps/api/geocode/json?address=PINCODE&key=YOUR_API_KEY
Replace PINCODE
with the actual pincode you are querying and YOUR_API_KEY
with your Google API key.
Example Request: For the pincode 110001 (Connaught Place, New Delhi):
https://maps.googleapis.com/maps/api/geocode/json?address=110001&key=YOUR_API_KEY
Parse the Response: The API will return a JSON response. You need to parse this response to extract the latitude and longitude. Here’s a simple example in Python:
import requests def get_lat_long(pincode, api_key): url = f"https://maps.googleapis.com/maps/api/geocode/json?address={pincode}&key={api_key}" response = requests.get(url) if response.status_code == 200: data = response.json() if data['results']: location = data['results'][0]['geometry']['location'] return location['lat'], location['lng'] else: return None, None else: return None, None api_key = 'YOUR_API_KEY' pincode = '110001' lat, lng = get_lat_long(pincode, api_key) print(f"Latitude: {lat}, Longitude: {lng}")
, multiple selections available,
Related content
Location API
Location API
More like this
Pincode Serviciability Flow:
Pincode Serviciability Flow:
More like this
Pincode serviceability BRD
Pincode serviceability BRD
More like this
Shopify Badges
Shopify Badges
More like this
Shipping Rate Calculator
Shipping Rate Calculator
More like this
Flipkart Notification Integration
Flipkart Notification Integration
More like this