Code example

Pincode API in Dart

A practical Dart example for retrieving Indian postal information by PIN code.

Dart with package:http

import 'dart:convert';
import 'package:http/http.dart' as http;

final uri = Uri.parse('https://api.pincodeapi.in/api/v1/pincode/751001');
final response = await http.get(uri).timeout(const Duration(seconds: 10));
if (response.statusCode < 200 || response.statusCode >= 300) {
  throw Exception('HTTP ${response.statusCode}');
}
final result = jsonDecode(response.body) as Map<String, dynamic>;
if (result['success'] != true) throw Exception('API request failed');
print(result['data']['pincode']);

This example uses the commonly used http package. Flutter applications can use the same package.

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.