This Node.js package allows you to search for places using the Google Maps Places API and export the search results to an Excel file. It's useful for quickly gathering information about various places based on keywords and locations.
- Search for places using a keyword and city name.
- Retrieve detailed information such as name, address, rating, reviews, and phone number for the top 20 results.
- Export the search results to an Excel file for easy reporting and sharing.
- Handles API rate-limiting with delays between requests.
To use this package, you need to have Node.js installed. You can then install the package via npm:
npm i nodejs-automation
You need a valid Google Maps API Key to use the Google Maps Places API. Set up your API key in a .env
file.
GOOGLE_MAPS_API_KEY=your_google_maps_api_key
Replace your_google_maps_api_key
with your actual API key.
You can use the package in your code like this:
const main = require('nodejs-automation');
const keyword = 'restaurants';
const city = 'New York';
main(keyword, city);
The search results will be saved as an Excel file named <keyword>_in_<city>.xlsx
in the current directory.
For example, if you search for restaurants
in New York
, the file will be named restaurants_in_new_york.xlsx
.
The package uses the following Google Maps APIs:
- Text Search API: To search for places based on a keyword and location.
- Place Details API: To fetch detailed information about each place.
- If no results are found for a search, the script will attempt a broader search.
- Any API errors or issues are logged to the console.
To avoid exceeding API rate limits, the script adds a 1-second delay between requests for place details.
Example data for a search result:
Name | Address | Description | Rating | Reviews | Phone |
---|---|---|---|---|---|
Example Restaurant | 123 Main St, New York, NY | OPERATIONAL | 4.5 | 120 | +1-234-567-8900 |
Contributions are welcome! Feel free to open an issue or submit a pull request with improvements or bug fixes.
This package is licensed under the MIT License.
If you encounter any issues or have questions, feel free to open an issue on the GitHub repository.
This package uses the Google Maps API, and you are responsible for any associated costs or compliance with the Google Maps Platform Terms of Service.