The Pincode Locator API is a powerful tool for finding the nearest pincode based on a given pincode, now with the added capability to calculate the distance between two pincodes. This can be particularly useful for tasks such as warehouse allocation, where proximity is a key factor.
- Find the nearest pincode from a given list.
- Calculate the distance between two pincodes.
- Easily integrate into your application for warehouse allocation or similar tasks.
- Built on Express and Node.js for efficiency and scalability.
Make sure you have the following installed:
- Node.js
- npm (Node Package Manager)
-
Clone the repository:
git clone https://github.com/21CEUOS101/inventory-navigatorAPI.git
-
Navigate to the project directory:
cd inventory-navigatorAPI
-
Install dependencies:
npm install
Send a POST request to the /api/find-nearest
endpoint with the following JSON format:
{
"pincode": 387002,
"pincodes": [362001, 390002, 387001]
}
Send a POST request to the /api/get-distance
endpoint with the following JSON format:
{
"source": 387002,
"destination": 392001
}
The API will respond with a JSON object containing the nearest pincode or the distance between the two pincodes, depending on the endpoint.
{
"nearest_pincode": 387001
}
{
"distance": 110.859
}
const axios = require('axios');
// Example for finding the nearest pincode
const findNearestRequestData = {
pincode: 387002,
pincodes: [362001, 390002, 387001]
};
axios.post('https://inventory-navigatorapi.onrender.com/api/find-nearest', findNearestRequestData)
.then(response => {
console.log('Nearest Pincode:', response.data.nearest_pincode);
})
.catch(error => {
console.error('Error:', error.message);
});
// Example for getting distance between two pincodes
const getDistanceRequestData = {
source: 387002,
destination: 392001
};
axios.post('https://inventory-navigatorapi.onrender.com/api/get-distance', getDistanceRequestData)
.then(response => {
console.log('Distance:', response.data.distance);
})
.catch(error => {
console.error('Error:', error.message);
});
- Special thanks to the Express and Node.js communities for their awesome contributions.