0.0.20240507 • Published 21 hours ago

@maxim_mazurok/gapi.client.places-v1 v0.0.20240507

Weekly downloads
-
License
MIT
Repository
github
Last release
21 hours ago

TypeScript typings for Places API (New) v1

For detailed description please check documentation.

Installing

Install typings for Places API (New):

npm install @types/gapi.client.places-v1 --save-dev

Usage

You need to initialize Google API client in your code:

gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:

gapi.client.load(
  'https://places.googleapis.com/$discovery/rest?version=v1',
  () => {
    // now we can use:
    // gapi.client.places
  }
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('places', 'v1', () => {
  // now we can use:
  // gapi.client.places
});

Don't forget to authenticate your client before sending any request to resources:

// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [
    // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
    'https://www.googleapis.com/auth/cloud-platform',

    // Private Service: https://www.googleapis.com/auth/maps-platform.places
    'https://www.googleapis.com/auth/maps-platform.places',

    // Private Service: https://www.googleapis.com/auth/maps-platform.places.autocomplete
    'https://www.googleapis.com/auth/maps-platform.places.autocomplete',

    // Private Service: https://www.googleapis.com/auth/maps-platform.places.details
    'https://www.googleapis.com/auth/maps-platform.places.details',

    // Private Service: https://www.googleapis.com/auth/maps-platform.places.nearbysearch
    'https://www.googleapis.com/auth/maps-platform.places.nearbysearch',

    // Private Service: https://www.googleapis.com/auth/maps-platform.places.textsearch
    'https://www.googleapis.com/auth/maps-platform.places.textsearch',
  ],
  immediate = true;
// ...

gapi.auth.authorize(
  {client_id: client_id, scope: scope, immediate: immediate},
  authResult => {
    if (authResult && !authResult.error) {
      /* handle successful authorization */
    } else {
      /* handle authorization error */
    }
  }
);

After that you can use Places API (New) resources:

/*
Returns predictions for the given input.
*/
await gapi.client.places.places.autocomplete({});

/*
Get the details of a place based on its resource name, which is a string in the `places/{place_id}` format.
*/
await gapi.client.places.places.get({name: 'name'});

/*
Search for places near locations.
*/
await gapi.client.places.places.searchNearby({});

/*
Text query based place search.
*/
await gapi.client.places.places.searchText({});
0.0.20240507

21 hours ago

0.0.20240430

8 days ago

0.0.20240429

9 days ago

0.0.20240428

10 days ago

0.0.20240424

14 days ago

0.0.20240423

15 days ago

0.0.20240422

16 days ago

0.0.20240421

17 days ago

0.0.20240417

21 days ago

0.0.20240414

24 days ago

0.0.20240410

29 days ago

0.0.20240409

30 days ago

0.0.20240407

1 month ago

0.0.20240403

1 month ago

0.0.20240402

1 month ago

0.0.20240331

1 month ago

0.0.20240401

1 month ago

0.0.20240328

1 month ago

0.0.20240326

1 month ago

0.0.20240325

1 month ago

0.0.20240324

1 month ago

0.0.20240320

2 months ago

0.0.20240319

2 months ago

0.0.20240318

2 months ago

0.0.20240317

2 months ago

0.0.20240314

2 months ago

0.0.20240310

2 months ago

0.0.20240312

2 months ago

0.0.20240306

2 months ago

0.0.20240305

2 months ago

0.0.20240304

2 months ago

0.0.20240303

2 months ago

0.0.20240228

2 months ago

0.0.20240226

2 months ago

0.0.20240227

2 months ago

0.0.20240225

2 months ago

0.0.20240221

3 months ago

0.0.20240219

3 months ago

0.0.20240214

3 months ago

0.0.20240213

3 months ago

0.0.20240211

3 months ago

0.0.20240207

3 months ago

0.0.20240205

3 months ago

0.0.20240204

3 months ago

0.0.20240131

3 months ago

0.0.20240130

3 months ago

0.0.20240129

3 months ago

0.0.20240128

3 months ago

0.0.20240123

4 months ago

0.0.20240121

4 months ago

0.0.20240114

4 months ago

0.0.20240115

4 months ago

0.0.20240110

4 months ago

0.0.20240109

4 months ago

0.0.20240103

4 months ago

0.0.20240102

4 months ago

0.0.20231213

5 months ago

0.0.20231212

5 months ago

0.0.20231211

5 months ago

0.0.20231210

5 months ago

0.0.20231207

5 months ago

0.0.20231205

5 months ago

0.0.20231204

5 months ago

0.0.20231203

5 months ago

0.0.20231127

5 months ago

0.0.20231122

5 months ago

0.0.20231121

6 months ago

0.0.20231120

6 months ago

0.0.20231119

6 months ago

0.0.20231115

6 months ago

0.0.20231114

6 months ago

0.0.20231113

6 months ago

0.0.20231112

6 months ago

0.0.20231108

6 months ago

0.0.20231107

6 months ago

0.0.20231106

6 months ago

0.0.20231105

6 months ago

0.0.20231101

6 months ago

0.0.20231031

6 months ago

0.0.20231030

6 months ago

0.0.20231029

6 months ago

0.0.20231025

7 months ago

0.0.20231024

7 months ago

0.0.20231023

7 months ago

0.0.20231022

7 months ago

0.0.20231017

7 months ago

0.0.20231016

7 months ago

0.0.20231011

7 months ago

0.0.20231009

7 months ago

0.0.20231008

7 months ago

0.0.20231004

7 months ago

0.0.20231003

7 months ago

0.0.20231002

7 months ago

0.0.20231001

7 months ago

0.0.20230927

7 months ago

0.0.20230926

7 months ago

0.0.20230925

8 months ago

0.0.20230920

8 months ago

0.0.20230918

8 months ago

0.0.20230917

8 months ago

0.0.20230913

8 months ago

0.0.20230912

8 months ago

0.0.20230911

8 months ago

0.0.20230910

8 months ago

0.0.20230906

8 months ago

0.0.20230905

8 months ago

0.0.20230904

8 months ago

0.0.20230903

8 months ago

0.0.20230830

8 months ago

0.0.20230829

8 months ago

0.0.20230828

8 months ago

0.0.20230827

8 months ago

0.0.20230823

9 months ago

0.0.20230822

9 months ago

0.0.20230816

9 months ago

0.0.20230814

9 months ago

0.0.20230813

9 months ago

0.0.20230809

9 months ago

0.0.20230808

9 months ago

0.0.20230806

9 months ago

0.0.20230802

9 months ago

0.0.20230801

9 months ago

0.0.20230731

9 months ago

0.0.20230729

9 months ago

0.0.20230726

10 months ago

0.0.20230725

10 months ago

0.0.20230724

10 months ago

0.0.20230723

10 months ago

0.0.20230719

10 months ago

0.0.20230718

10 months ago

0.0.20230716

10 months ago