A simple Node.js library to fetch Google Maps reviews.
To install the library, run the following command:
npm install google-reviews-api
const { fetchGoogleMapsReviews } = require('google-reviews-library');
(async () => {
const placeId = '0x47e66e2964e34e2d:0x8ddca9ee380ef7e0';
const options = {
hl: 'en', // Language (e.g., 'en' for English)
gl: 'tr', // Region (e.g., 'tr' for Turkey)
targetReviews: 50 // The total number of reviews you want to fetch
};
const result = await fetchGoogleMapsReviews(placeId, '', options);
console.log(result.reviews);
})();
Sample Place ID For example, to fetch reviews for the Eiffel Tower, the Place ID can be found in the Google Maps URL:
The Place ID for the Eiffel Tower is: 0x47e66e2964e34e2d:0x8ddca9ee380ef7e0
placeId: The Google Maps Place ID for the location.
nextPageToken: For pagination. You can leave it as an empty string ('') to start from the first page.
hl: Language for the reviews (default: 'en').
gl: Region for the reviews (default: 'us').
targetReviews: The maximum number of reviews to fetch. This will stop fetching once the target number is reached (default: 50).