npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

google-places-web

v2.0.1

Published

A simple wrapper for the Google Places Web API

Downloads

4,027

Readme

Welcome to V2!

V2 is a complete rewrite to provide better TypeScript support and infrastructure for validations with more flexibility. Google Places Web provides a singleton (default) and exported class to make it flexible and easy to use. There are breaking changes so please read through the readme below.

What is this?

A promise-based integration with Google Places for Node or server-side JS platforms. This cannot be used as a front-end solution (Angular/React/Vue/Vanilla, etc) because Google has provided their own client JS SDK

Implemented Searches

Deprecation Notice

Radar Search and Find Place Search have been deprecated and removed from the library.

TypeScript

Please note that the google docs aren't always thorough at describing the format of results you get from each endpoint. I have spend a good amount of time trying to make sure the response types are as accurate as possible. If something is not accurate, feel free to open a pull request explaining the inconsistency with the correction.

Installation

# with yarn
yarn add google-places-web

# with npm
npm i google-places-web -S

Usage

// ES6
import Places from 'google-places-web';

Places.apiKey = 'your-api-key';

const search = await Places.nearbysearch({...});
const search2 = await Places.details({...});

Running Examples

Make sure you have the dependencies installed (yarn) and have built it with yarn build.

create a .env with your PLACES_API_KEY to make testing and development easier.

# uses the PLACES_API_KEY from .env file and is required
> yarn run:example examples/{search}-example.ts

Troubleshooting/Contributing

create a .env with your PLACES_API_KEY to make testing and development easier.

Feel free to file issues as you see fit, and always looking for collaborators to help make this better. If you are interested in contributing, you may clone the repository, and create a .ts file for an example you think would benefit to share.

Errors

  • INVALID_REQUEST - Google is respondig saying that your parameters provided is invalid.
  • Invalid API Key - The instance of the GooglePlaces object does not have a valid API key from Google. Make sure you are either using import Places from... or import {GooglePlaces} from.... GooglePlaces is the base class so you would need to make an instance of it first.
  • STATUS_MESSAGE - Google responds with HTTP 200 but JSON contains an "error". This is parsed from the Google API response, ex. ZERO_RESULTS
  • Missing required params: [<PARAM1>, <PARAM2>] - Required params PARAM1 & PARAM2 are undefined or null
  • No parameters provided - A method was called without passing a parameters object to the method, most likely passed null, undefined or nothing. ex. Places.autocomplete(); instead of Places.autcomplete({foo: 'bar'});

Important Notes

Google states that you can use Place Autocomplete even without a map. If you do show a map, it must be a Google map. When you display predictions from the Place Autocomplete service without a map, you must include the Powered by Google logo.