@googlemaps/region-lookup
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

Region Lookup Service

npm CI Release codecov GitHub contributors semantic-release Discord

Note: This library wraps a service that is in Experimental status.

Install

npm install @googlemaps/region-lookup

# optionally if not already installed
npm install axios

Usage

For complete documentation of this library, see Use the Region Lookup API in the Google Maps Platform documentation.

Below is a simple example calling the lookupRegion method of the service.

import { 
  lookupRegion, 
  LookupRegionRequestData, 
  LookupRegionResponseData, 
  LookupRegionResponse, 
  RegionIdentifier 
} from "@googlemaps/region-lookup";

const headers = {
    "X-Goog-Api-Key": "YOUR API KEY",
  };

const data: LookupRegionRequestData = {
  identifiers: [
    {
      place: "newark",
      place_type: "locality" as const,
      region_code: "us",
      language: "en",
    },
  ],
};

try {
  const response: LookupRegionResponse = await lookupRegion({ headers, data });
  console.log(response.data);
} catch (e) {
  console.log(e.response);
  throw e;
}

See the reference documentation for more information on the request and response interfaces.

Developing

In order to run the end-to-end tests, you'll need to supply your API key via an environment variable.

$ export GOOGLE_MAPS_API_KEY=AIza-your-api-key
$ npm test

Package Sidebar

Install

npm i @googlemaps/region-lookup

Weekly Downloads

72

Version

0.0.0

License

Apache-2.0

Unpacked Size

51.2 kB

Total Files

9

Last publish

Collaborators

  • wangela
  • google-wombot