A TypeScript-typed and runtime-validated Google Maps Platform API. The requests and responses are validated using Zod and based on the OpenAPI specification.
⚠ Warning: This library is for server-side applications only. Do not use it for client-side applications to prevent your API key from leaking — use one of the client-side libraries instead.
The current list of supported APIs:
- Directions API
- Distance Matrix API
- Elevation API
- Geocoding API
- Geolocation API
- Places API
- Roads API
- Street View API
- Time Zone API
pnpm add @vbudovski/google-maps
Install the dependencies:
nvm use
pnpm install
Copy the sample environment variables file env.sample
to .env
and set the required variables. GOOGLE_MAPS_API_KEY
must be set in order to run the tests.
pnpm build
pnpm test
When a new version of the OpenAPI schema is released, it is necessary to re-generate the schemas and expose the exports for use.
-
Generate the new Zod schemas and fetch functions:
pnpm generate
-
Export the new functions from a module in
src/api
. Be sure to follow existing patterns. -
Add a test module in
src/test
. The name should match that of the API export module.