Skip to content

fix: migrate to new Google Places API (New) to resolve HTTP 403 errors#19

Merged
cablate merged 5 commits intocablate:mainfrom
david-pivonka:fix/places-api-new
Oct 16, 2025
Merged

fix: migrate to new Google Places API (New) to resolve HTTP 403 errors#19
cablate merged 5 commits intocablate:mainfrom
david-pivonka:fix/places-api-new

Conversation

@david-pivonka
Copy link
Copy Markdown
Contributor

@david-pivonka david-pivonka commented Sep 30, 2025

Google Places API Migration Fix

Problem

The get_place_details tool was returning HTTP 403 errors with the message:

Failed to get place details for ChIJQ2BmJhVwhlQRPkt6FWiet90: You're calling a legacy API, which is not enabled for your project. To get newer features and more functionality, switch to the Places API (New) or Routes API.

Solution

Migrated from the legacy Google Places API to the new Places API (New) to resolve the HTTP 403 errors and ensure continued functionality.

Changes Made

1. Added New Dependency

  • Added @googlemaps/places package (v2.1.0) to package.json
  • This is the official Google client library for the new Places API

2. Created New Service Class

  • File: src/services/NewPlacesService.ts
  • Implements the new Places API client
  • Maintains backward compatibility by transforming the new API response format to match the legacy format
  • Handles field mapping and data transformation

3. Updated PlacesSearcher

  • File: src/services/PlacesSearcher.ts
  • Modified getPlaceDetails() method to use the new NewPlacesService
  • Maintains the same interface and response format for existing code

4. Key Features of the New Implementation

  • Uses the new Places API (New) endpoint
  • Proper field mask handling to avoid unnecessary billing
  • Maintains backward compatibility with existing response structure
  • Enhanced error handling for the new API
  • Support for all existing place details fields (name, address, rating, reviews, etc.)

5. Testing

  • Created test-new-api.js script to verify the new implementation
  • Build process verified to work correctly
  • Maintains existing functionality while using the new API

- Add @googlemaps/places dependency for new Places API
- Create NewPlacesService class to handle new API integration
- Update PlacesSearcher to use new API for getPlaceDetails
- Maintain backward compatibility with existing response format
- Add test script to verify new implementation
- Update README with information about the API migration

Fixes the error: 'You're calling a legacy API, which is not enabled for your project'
- Clean up NewPlacesService.ts by removing all comments
- Clean up PlacesSearcher.ts by removing inline comments
- Clean up test-new-api.js by removing documentation comments
- Clean up create-pr.sh by removing comment blocks
- Maintain clean, comment-free codebase
@cablate
Copy link
Copy Markdown
Owner

cablate commented Oct 1, 2025

Thanks for the contribution!
The changes are quite extensive, so I’ll need a bit more time to review carefully.
I’ll get back to you as soon as possible.

Copy link
Copy Markdown
Owner

@cablate cablate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I've improved New Place API work and remove obsolete Places API migration artifacts.

@cablate cablate merged commit 49c1620 into cablate:main Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants