Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gojob/google-place

Package Overview
Dependencies
Maintainers
8
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gojob/google-place

A small node module to use the Google Place API written in typescript

  • 1.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
780
increased by18.72%
Maintainers
8
Weekly downloads
 
Created
Source

@gojob/google-place

travis build Coverage Status

Description

This package is a library for Node.js to consume the Google Place autocomplete & details API. It returns a small subset of their data.

Installation

yarn add @gojob/google-place

Usage

import * as gp from '@gojob/google-place';

Autocomplete API

const results = await gp.autocomplete({
    key: 'YOUR_API_KEY',
    input: 'Port-de-Bouc',
    language: 'fr',
    countries: ['fr'],
});
gp.autocomplete(query)
NameTypeDescription
keystringGoogle API Key
inputstringSearched entry
languagestringLanguage to use (optional) Google Code
countriesstring[]Filter on a country (optional) ISO 3166-1 Alpha-2

Returns a list of prediction or throw if an error occurred.

interface IPrediction {
  id: string;
  name: string;
}

As:

NameTypeDescription
idstringPlace id
namestringPlace name
gp.retrieve(query)
const place = gp.retrieve({
    key: 'YOUR_API_KEY',
    id: 'ChIJ-RzUxt8ethIRksIaOl-0tJY',
    language: 'fr',
});

As:

NameTypeDescription
keystringGoogle API Key
idstringSearched entry
languagestringLanguage to use (optional) Google Code

Returns a place or throw if an error occurred.

export interface ILocation {
  lat: number;
  lng: number;
}

export interface IPlace {
  id: string;
  address: string;
  location: ILocation;
  postalCode: string;
  locality: string;
  administrativeAreaLevel1: string;
  administrativeAreaLevel2: string;
  countryCode: string;
  country: string;
}

As:

NameTypeDescription
idstringPlace id
addressstringFormatted address
locationobjectLatitude and longitude coordinates
postalCodestringPostal code
localitystringLocality name (long or short name)
administrativeAreaLevel1stringAdministrative Area Level 1 (long or short name)
administrativeAreaLevel2stringAdministrative Area Level 2 (long or short name)
countryCodestringCountry short name
stateCodestringAdministrative Area Level 1 (short name)
countrystringCountry name (long name)

postalCode, administrativeAreaLevel1 or administrativeAreaLevel2 may be empty string

gp.reverseGeocode(opts)
const place = gp.reverseGeocode({
    key: 'YOUR_API_KEY',
    latlng: 'XXX,YYY',
    language: 'fr',
});

As:

NameTypeDescription
keystringGoogle API Key
latlngstringLatitude and longitude coordinates (coma separated)
languagestringLanguage to use (optional) Google Code

Find an address from a location coordinates. Returns a IPlace.

FAQs

Package last updated on 20 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc