Using an API to get the Location based on ZIP Code
For India, You can use below API
http://postalpincode.in/api/pincode/<your_pin_code>
Response :
{
"Message": "Number of Post office(s) found: 2",
"Status": "Success",
"PostOffice": [
{
"Name": "ISRO Anthariksha Bhavan",
"Description": "",
"BranchType": "Sub Post Office",
"DeliveryStatus": "Non-Delivery",
"Taluk": "Bangalore North",
"Circle": "Bangalore North",
"District": "Bangalore",
"Division": "Bangalore East",
"Region": "Bangalore HQ",
"State": "Karnataka",
"Country": "India"
},
{
"Name": "R.M.V. Extension II Stage",
"Description": "",
"BranchType": "Sub Post Office",
"DeliveryStatus": "Delivery",
"Taluk": "Bangalore North",
"Circle": "Bangalore North",
"District": "Bangalore",
"Division": "Bangalore East",
"Region": "Bangalore HQ",
"State": "Karnataka",
"Country": "India"
}
]
}
for international postal pincode locations use this
https://api.worldpostallocations.com/pincode?postalcode=<your_pin_code_eg: 560094>&countrycode=<two_digit_country_code_eg:IN>
Response
{
"status": true,
"result": [
{
"id": "305160",
"country": "IN",
"postalCode": "560094",
"postalLocation": "ISRO Anthariksha Bhavan",
"state": "Karnataka",
"stateId": "19",
"district": "Bengaluru",
"districtId": "583",
"province": "Bangalore North",
"provinceId": "",
"latitude": "13.1077",
"longitude": "77.581"
},
{
"id": "305159",
"country": "IN",
"postalCode": "560094",
"postalLocation": "R.M.V. Extension II Stage",
"state": "Karnataka",
"stateId": "19",
"district": "Bengaluru",
"districtId": "583",
"province": "Bangalore North",
"provinceId": "",
"latitude": "13.1077",
"longitude": "77.581"
}
]
}
You can use Google Geocoding API, simple HTTP request with JSON response.
Example: http://maps.googleapis.com/maps/api/geocode/json?address=94085®ion=us
{
long_name: "California",
short_name: "CA",
types: [
"administrative_area_level_1",
"political"
]
}
But note that the free tier will support only:
- 2,500 requests per 24 hour period.
- 5 requests per second.