Place / Google Places 서비스 문서

Google Places API 및 Place ID 기반 조회, 캐싱 전략 등 Place 관련 기능에 대한 상세 문서입니다.

# Place ID 검색 API

## 📍 Place ID로 검색

Google Places API Place ID를 사용하여 주소 정보를 조회합니다.

### 요청

```
GET /api/v1/zipcode/place/{placeId}
```

### 파라미터

| 파라미터 | 타입 | 필수 | 설명 | 예시 |
|---------|------|------|------|------|
| `placeId` | string | ✅ | Google Places API Place ID | `ChIJN1t_tDeuEmsRUsoyG83frY4` |

### 요청 예시

```bash
# Place ID로 검색
GET /api/v1/zipcode/place/ChIJN1t_tDeuEmsRUsoyG83frY4
```

### 응답 예시

```json
{
"success": true,
"message": "Place ID 정보를 조회했습니다.",
"data": {
"id": 3,
"country_code": "KR",
"zipcode": "06042",
"state": "서울특별시",
"state_en": "Seoul",
"city": "강남구",
"city_en": "Gangnam-gu",
"formatted_address": "서울특별시 강남구 테헤란로",
"latitude": 37.5010,
"longitude": 127.0394,
"place_id": "ChIJN1t_tDeuEmsRUsoyG83frY4",
"place_name": "테헤란로",
"place_types": ["route"],
"retrieved_from": "database"
}
}
```

### 동작 방식

1. 데이터베이스에서 Place ID로 검색
2. 데이터가 없으면 Google Places API Place Details API 호출
3. Place Details를 우편번호 데이터 형식으로 변환
4. 데이터베이스에 저장
5. 결과 반환

---

## 💻 사용 예시

### cURL

```bash
# Place ID로 검색
curl "http://localhost/api/v1/zipcode/place/ChIJN1t_tDeuEmsRUsoyG83frY4"
```

### JavaScript (Fetch API)

```javascript
// Place ID로 검색
async function searchByPlaceId(placeId) {
const response = await fetch(`/api/v1/zipcode/place/${encodeURIComponent(placeId)}`);
const data = await response.json();

if (data.success) {
console.log('검색 결과:', data.data);
return data.data;
} else {
console.error('오류:', data.message);
return null;
}
}

// 사용 예시
searchByPlaceId('ChIJN1t_tDeuEmsRUsoyG83frY4');
```

### PHP (Guzzle HTTP)

```php
use GuzzleHttp\Client;

$client = new Client(['base_uri' => 'http://localhost']);

// Place ID로 검색
$response = $client->get('/api/v1/zipcode/place/ChIJN1t_tDeuEmsRUsoyG83frY4');
$data = json_decode($response->getBody(), true);
```

### Python (Requests)

```python
import requests

base_url = 'http://localhost/api/v1/zipcode'

# Place ID로 검색
place_id = 'ChIJN1t_tDeuEmsRUsoyG83frY4'
response = requests.get(f'{base_url}/place/{place_id}')
data = response.json()
```

---

## 📝 참고사항

- Place ID는 Google Places API에서 제공하는 고유 식별자입니다
- 동일한 장소는 항상 동일한 Place ID를 가집니다
- Place ID를 사용하면 가장 정확한 결과를 얻을 수 있습니다
- Google Places API의 Place Details API를 사용합니다