Go using net/http
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Get("https://api.pincodeapi.in/api/v1/pincode/751001")
if err != nil { log.Fatal(err) }
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
log.Fatalf("HTTP %d", resp.StatusCode)
}
var result struct {
Success bool `json:"success"`
Data struct {
Pincode string `json:"pincode"`
PostOffices []struct {
OfficeName string `json:"office_name"`
Pincode string `json:"pincode"`
} `json:"post_offices"`
} `json:"data"`
}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { log.Fatal(err) }
if !result.Success { log.Fatal("API request failed") }Always close the response body and use a client timeout.
V1 response contract
Successful responses use success, endpoint-specific data and a meta object. Postal records use snake_case fields such as office_name, office_type, delivery_status, district and state.
Handling 404 and 429 responses
The current public limit is 6 API calls per 10 seconds per IP address. A 404 means the requested record was not found and should not be retried unchanged. A 429 means the rate limit was reached; respect Retry-After when the API supplies it. Limit retries and add jitter so many clients do not retry at exactly the same moment.
See the complete API documentation, response guide and Abuse Policy.