@googlemaps/region-lookup
v0.0.0
Published
Axios based methods wrapping Region Lookup service
Downloads
277
Readme
Region Lookup Service
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