Place Details
Place Details
Get detailed place information using a place code and session ID. Returns complete address and coordinates. Use after Search Place to fetch full location data.
note
Requires place code and session ID from Search Place request.
Usage
import { createBarikoiClient } from "barikoiapis";
const barikoi = createBarikoiClient({
apiKey: "YOUR_BARIKOI_API_KEY",
});
// First, get the session_id and place_code from Search Place
const searchResult = await barikoi.searchPlace({ q: "barikoi" });
const sessionId = searchResult.data?.session_id;
const placeCode = searchResult.data?.places?.[0]?.place_code;
// Then, get the place details
const details = await barikoi.placeDetails({
place_code: placeCode,
session_id: sessionId,
});
const place = details.data?.place;
Response
This API returns:
place (with address, place_code, latitude, longitude), session_id, status
Parameters
| Parameter | Type | Description |
|---|---|---|
place_code | string | Required. Place code from Search Place results |
session_id | string | Required. Session ID from Search Place results |
Complete Example with Search Place
// Step 1: Search for a place
const searchResult = await barikoi.searchPlace({ q: "barikoi" });
const sessionId = searchResult.data?.session_id;
const places = searchResult.data?.places || [];
if (places.length > 0 && sessionId) {
// Step 2: Get details for the first result
const details = await barikoi.placeDetails({
place_code: places[0].place_code,
session_id: sessionId,
});
const place = details.data?.place;
console.log(`Address: ${place?.address}`);
console.log(`Coordinates: ${place?.latitude}, ${place?.longitude}`);
}
Type Definitions
export type PlaceDetailsParams = {
place_code: string; // Place code from search place results
session_id: string; // Session ID from search place results
};
export type PlaceDetailsSuccess = {
place?: {
address?: string;
place_code?: string;
latitude?: string;
longitude?: string;
};
session_id?: string;
status?: number;
};