Check Nearby
Check Nearby
Verify if a location is within a specified radius. Returns "Inside geo fence" or "Outside geo fence" status. Perfect for delivery notifications, driver alerts, and proximity triggers.
Usage
import { createBarikoiClient } from "barikoiapis";
const barikoi = createBarikoiClient({
apiKey: "YOUR_BARIKOI_API_KEY",
});
const result = await barikoi.checkNearby({
current_latitude: 23.8103,
current_longitude: 90.4125,
destination_latitude: 23.8,
destination_longitude: 90.4,
radius: 100,
});
const isInside = result.data?.message === "Inside geo fence";
Response
This API returns:
message ("Inside geo fence" or "Outside geo fence"), status, data
Parameters
| Parameter | Type | Description |
|---|---|---|
current_latitude | number | Required. Current position latitude |
current_longitude | number | Required. Current position longitude |
destination_latitude | number | Required. Destination/target latitude |
destination_longitude | number | Required. Destination/target longitude |
radius | number | Required. Radius in meters to check |
Example for Delivery Notification
const result = await barikoi.checkNearby({
current_latitude: 23.8103, // Driver's current location
current_longitude: 90.4125,
destination_latitude: 23.81, // Delivery destination
destination_longitude: 90.413,
radius: 500, // 500 meters radius
});
const isInside = result.data?.message === "Inside geo fence";
if (isInside) {
console.log("Driver is within 500m of delivery location!");
// Trigger notification to customer
} else {
console.log("Driver is still outside the delivery zone.");
}
Type Definitions
export type CheckNearbyParams = {
destination_latitude: number;
destination_longitude: number;
radius: number;
current_latitude: number;
current_longitude: number;
};
export type CheckNearbySuccess = {
message?: string;
status?: number;
data?: {
id?: string;
name?: string;
radius?: string;
latitude?: string;
longitude?: string;
user_id?: number;
};
};