Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update README per template #1294

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 96 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
Node.js Client for Google Maps Services
=======================================

[![npm](https://img.shields.io/npm/v/@googlemaps/google-maps-services-js.svg)](https://www.npmjs.com/package/@googlemaps/google-maps-services-js)
![Test](https://github.com/googlemaps/google-maps-services-js/workflows/Test/badge.svg)
[![npm](https://img.shields.io/npm/v/@googlemaps/google-maps-services-js)][npm-pkg]
![Release](https://github.com/googlemaps/google-maps-services-js/workflows/Release/badge.svg)
![Stable](https://img.shields.io/badge/stability-stable-green)
[![Tests/Build Status](https://github.com/googlemaps/google-maps-services-js/actions/workflows/test.yml/badge.svg)](https://github.com/googlemaps/google-maps-services-js/actions/workflows/test.yml)

[![codecov](https://codecov.io/gh/googlemaps/google-maps-services-js/branch/master/graph/badge.svg)](https://codecov.io/gh/googlemaps/google-maps-services-js)
![GitHub contributors](https://img.shields.io/github/contributors/googlemaps/google-maps-services-js?color=green)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Discord](https://img.shields.io/discord/676948200904589322)](https://discord.gg/jRteCzP)

![GitHub contributors](https://img.shields.io/github/contributors/googlemaps/google-maps-services-js?color=green)
[![GitHub License](https://img.shields.io/github/license/googlemaps/google-maps-services-js?color=blue)][license]
[![Discord](https://img.shields.io/discord/676948200904589322?color=6A7EC2&logo=discord&logoColor=ffffff)][Discord server]
[![StackOverflow](https://img.shields.io/stackexchange/stackoverflow/t/google-maps?color=orange&label=google-maps&logo=stackoverflow)](https://stackoverflow.com/questions/tagged/google-maps)

# Node.js Client for Google Maps Services

> [!NOTE]
> This library is a refactor of the older [@google/maps](https://npmjs.com/package/@google/maps) package. This replacement library is published to [@googlemaps/google-maps-services-js][npm-pkg].

## Description

Use Node.js? Want to [geocode][Geocoding API] something? Looking for [directions][Directions API]? This client library brings the following [Google Maps Web Services APIs] to your server-side Node.js applications:

- [Maps Static API]
- [Directions API]
- [Distance Matrix API]
- [Elevation API]
- [Geocoding API]
- [Places API]
- [Roads API]
- [Time Zone API]

> This library is a refactor of a previous version published to [@google/maps](https://www.npmjs.com/package/@google/maps). It is now being published to [@googlemaps/google-maps-services-js](https://www.npmjs.com/package/@googlemaps/google-maps-services-js).
## Requirements

Use Node.js? Want to [geocode][Geocoding API] something? Looking
for [directions][Directions API]?
This library brings the [Google Maps API Web Services] to your Node.js
application.
* [Sign up with Google Maps Platform]
* A Google Maps Platform [project] with the desired API(s) from the above list enabled
* An [API key] associated with the project above

The Node.js Client for Google Maps Services is a Node.js Client library
for the following Google Maps APIs:
## API Key Security

- [Directions API]
- [Distance Matrix API]
- [Elevation API]
- [Geocoding API]
- [Places API]
- [Roads API]
- [Time Zone API]
This client library is designed for use in server-side applications.

Keep in mind that the same [terms and conditions](https://developers.google.com/maps/terms)
apply to usage of the APIs when they're accessed through this library.
In either case, it is important to add [API key restrictions](https://developers.google.com/maps/api-security-best-practices#restricting-api-keys) to improve its security. Additional security measures, such as hiding your key
from version control, should also be put in place to further improve the security of your API key.

## Attention!
Check out the [API Security Best Practices](https://developers.google.com/maps/api-security-best-practices) guide to learn more.

This library is designed for server-side Node.js applications. Attempting to use it client-side, in either the browser or any other environment like React Native, may in some cases work, but mostly will not. Please refrain from reporting issues with these environments when attempting to use them, since **server-side Node.js applications is the only supported environment for this library**. For other environments, try the [Maps JavaScript API], which contains a comparable feature set, and is explicitly intended for use with client-side JavaScript.
> [!NOTE] **This library for server-side only**
> Attempting to use it client-side, in either the browser or any other environment like React Native, may in some cases work, but mostly will not. Please refrain from reporting issues with these environments when attempting to use them, since **server-side Node.js applications is the only supported environment for this library**.
> For other environments, try the [Maps JavaScript API], which contains a comparable feature set, and is explicitly intended for use with client-side JavaScript.

## Quick Start
## Usage

$ npm install @googlemaps/google-maps-services-js

Expand All @@ -61,7 +74,7 @@ client
.elevation({
params: {
locations: [{ lat: 45, lng: -110 }],
key: process.env.GOOGLE_MAPS_API_KEY,
key: process.env.MAPS_API_KEY,
},
timeout: 1000, // milliseconds
})
Expand All @@ -73,27 +86,28 @@ client
});
```

## Reference Documentation
## Documentation

The generated reference documentation can be found [here](https://googlemaps.github.io/google-maps-services-js/). The TypeScript types are the authoritative documentation for this library and may differ slightly from the descriptions.
For more information, see the reference [documentation]. The TypeScript types are the authoritative documentation for this library and may differ slightly from the descriptions.

## 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
$ export MAPS_API_KEY=YOUR_API_KEY
$ npm test

## Migration

This section discusses the migration from [@google/maps](https://www.npmjs.com/package/@google/maps) to [@googlemaps/google-maps-services-js](https://www.npmjs.com/package/@googlemaps/google-maps-services-js) and the differences between the two.
This section discusses the migration from [@google/maps](https://npmjs.com/package/@google/maps) to [@googlemaps/google-maps-services-js][npm-pkg] and the differences between the two.

> **Note**: The two libraries do not share any methods or interfaces.

The primary difference is `@google/maps` exposes a public method that takes individual parameters as arguments while `@googlemaps/google-maps-services-js` exposes methods that take `params`, `headers`, `body`, `instance`(see [Axios](https://github.com/axios/axios)). This allows direct access to the transport layer without the complexity that was inherent in the old library. Below are two examples.

### Old (`@google/maps`):
### Old (`@google/maps`)

```js
const googleMapsClient = require('@google/maps').createClient({
key: 'your API key here'
Expand All @@ -120,7 +134,7 @@ client
.elevation({
params: {
locations: [{ lat: 45, lng: -110 }],
key: process.env.GOOGLE_MAPS_API_KEY
key: process.env.MAPS_API_KEY
},
timeout: 1000 // milliseconds
}, axiosInstance)
Expand All @@ -138,9 +152,9 @@ The primary differences are in the following table.
| ------------- |:-------------:|
| Can provide params | Can provide params, headers, instance, timeout (see [Axios Request Config](https://github.com/axios/axios#request-config)) |
| API key configured at Client | API key configured per method in params object|
| Retry is supported | Retry is configurable via [axios-retry](https://www.npmjs.com/package/axios-retry) or [retry-axios](https://www.npmjs.com/package/retry-axios) |
| Retry is supported | Retry is configurable via [axios-retry](https://npmjs.com/package/axios-retry) or [retry-axios](https://npmjs.com/package/retry-axios) |
| Does not use promises by default | Promises are default |
| Typings are in [@types/googlemaps](https://www.npmjs.com/package/@types/googlemaps) | Typings are included |
| Typings are in [@types/googlemaps](https://npmjs.com/package/@types/googlemaps) | Typings are included |
| Does not support keep alive | Supports keep alive |
| Does not support interceptors | Supports [interceptors](https://github.com/axios/axios#interceptors)|
| Does not support cancelalation | Supports [cancellation](https://github.com/axios/axios#cancellation) |
Expand Down Expand Up @@ -169,36 +183,54 @@ client
});
```

## Contributing

Contributions are welcome and encouraged! If you'd like to contribute, send us a [pull request] and refer to our [code of conduct] and [contributing guide].

## Terms of Service

This library uses Google Maps Platform services. Use of Google Maps Platform services through this library is subject to the Google Maps Platform [Terms of Service].

This library is not a Google Maps Platform Core Service. Therefore, the Google Maps Platform Terms of Service (e.g. Technical Support Services, Service Level Agreements, and Deprecation Policy) do not apply to the code in this library.

## Support

This library is community supported. We're comfortable enough with the
stability and features of the library that we want you to build real
production applications on it. We will try to support, through Stack
Overflow, the public surface of the library and maintain
backwards compatibility in the future; however, while the library is in
version 0.x, we reserve the right to make backwards-incompatible
changes. If we do remove some functionality (typically because better
functionality exists or if the feature proved infeasible), our intention
is to deprecate and give developers a year to update their code.

If you find a bug, or have a feature suggestion, please
[log an issue][issues]. If you'd like to contribute, please read
[How to Contribute][contrib].

[apikey]: https://developers.google.com/maps/faq#keysystem
[clientid]: https://developers.google.com/maps/documentation/business/webservices/auth

[Google Maps API Web Services]: https://developers.google.com/maps/apis-by-platform#web_service_apis
[Directions API]: https://developers.google.com/maps/documentation/directions/
This library is offered via an open source [license]. It is not governed by the Google Maps Platform Support [Technical Support Services Guidelines, the SLA, or the [Deprecation Policy]. However, any Google Maps Platform services used by the library remain subject to the Google Maps Platform Terms of Service.

This library adheres to [semantic versioning] to indicate when backwards-incompatible changes are introduced. Accordingly, while the library is in version 0.x, backwards-incompatible changes may be introduced at any time.

If you find a bug, or have a feature request, please [file an issue] on GitHub. If you would like to get answers to technical questions from other Google Maps Platform developers, ask through one of our [developer community channels]. If you'd like to contribute, please check the [contributing guide].

You can also discuss this library on our [Discord server].

[Google Maps Platform Web Services APIs]: https://developers.google.com/maps/apis-by-platform#web_service_apis
[Maps Static API]: https://developers.google.com/maps/documentation/maps-static
[Directions API]: https://developers.google.com/maps/documentation/directions
[directions-key]: https://developers.google.com/maps/documentation/directions/get-api-key#key
[Distance Matrix API]: https://developers.google.com/maps/documentation/distancematrix/
[Elevation API]: https://developers.google.com/maps/documentation/elevation/
[Geocoding API]: https://developers.google.com/maps/documentation/geocoding/
[Time Zone API]: https://developers.google.com/maps/documentation/timezone/
[Roads API]: https://developers.google.com/maps/documentation/roads/
[Places API]: https://developers.google.com/places/web-service/

[issues]: https://github.com/googlemaps/google-maps-services-js/issues
[contrib]: https://github.com/googlemaps/google-maps-services-js/blob/master/CONTRIBUTING.md
[Maps JavaScript API]: https://developers.google.com/maps/documentation/javascript/
[Distance Matrix API]: https://developers.google.com/maps/documentation/distancematrix
[Elevation API]: https://developers.google.com/maps/documentation/elevation
[Geocoding API]: https://developers.google.com/maps/documentation/geocoding
[Time Zone API]: https://developers.google.com/maps/documentation/timezone
[Roads API]: https://developers.google.com/maps/documentation/roads
[Places API]: https://developers.google.com/places/web-service
[Maps JavaScript API]: https://developers.google.com/maps/documentation/javascript

[API key]: https://developers.google.com/maps/documentation/javascript/get-api-key
[documentation]: https://googlemaps.github.io/google-maps-services-js
[npm-pkg]: https://npmjs.com/package/@googlemaps/google-maps-services-js

[code of conduct]: CODE_OF_CONDUCT.md
[contributing guide]: CONTRIBUTING.md
[Deprecation Policy]: https://cloud.google.com/maps-platform/terms
[developer community channels]: https://developers.google.com/maps/developer-community
[Discord server]: https://discord.gg/hYsWbmk
[file an issue]: https://github.com/googlemaps/google-maps-services-js/issues/new/choose
[license]: LICENSE
[pull request]: https://github.com/googlemaps/google-maps-services-js/compare
[project]: https://developers.google.com/maps/documentation/javascript/cloud-setup#enabling-apis
[semantic versioning]: https://semver.org
[Sign up with Google Maps Platform]: https://console.cloud.google.com/google/maps-apis/start
[similar inquiry]: https://github.com/googlemaps/google-maps-services-js/issues
[SLA]: https://cloud.google.com/maps-platform/terms/sla
[Technical Support Services Guidelines]: https://cloud.google.com/maps-platform/terms/tssg
[Terms of Service]: https://cloud.google.com/maps-platform/terms
Loading