cURL - POST with Header (Recommended)
curl -X POST "https://geoloc.in/api/pincode" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"pincode": "395007"}'
cURL - GET Request
curl -X GET "https://geoloc.in/api/pincode?pincode=395007&api_key=YOUR_API_KEY"
PHP Code
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://geoloc.in/api/pincode',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['pincode' => '395007']),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer YOUR_API_KEY'
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
JavaScript Fetch
fetch('https://geoloc.in/api/pincode', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({pincode: '395007'})
})
.then(response => response.json())
.then(data => console.log(data));