> For the complete documentation index, see [llms.txt](https://space-axolotls.gitbook.io/space-axolotls-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://space-axolotls.gitbook.io/space-axolotls-docs/api-documentation/google-maps-elevation.md).

# Google Maps Elevation

## Google Maps Elevation API Documentation

This document describes how to use the **Google Maps Elevation API** to retrieve elevation data for specific geographic locations or paths on Earth’s surface.

***

### Base Endpoint

To request elevation data, use the following endpoint:

```
https://maps.googleapis.com/maps/api/elevation/json?parameters
```

Replace `parameters` with query arguments such as `locations`, `path`, and your `key`.

***

### 1. Basic Elevation Request

#### Endpoint Example

```
https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key=YOUR_API_KEY
```

This request returns the elevation for one or more geographic coordinates.

#### Parameters

| Parameter   | Type   | Description                                               |
| ----------- | ------ | --------------------------------------------------------- |
| `locations` | string | One or more latitude/longitude pairs separated by \`      |
| `key`       | string | Your Google Cloud API key with the Elevation API enabled. |

#### Response Fields

| Field          | Type   | Description                                                                                                   |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------- |
| `results`      | array  | Contains one or more elevation results.                                                                       |
| `elevation`    | float  | Elevation of the location in meters above sea level.                                                          |
| `location.lat` | float  | Latitude of the requested point.                                                                              |
| `location.lng` | float  | Longitude of the requested point.                                                                             |
| `resolution`   | float  | Maximum distance between data points from which the elevation was interpolated, in meters.                    |
| `status`       | string | Status of the request (e.g., `OK`, `INVALID_REQUEST`, `OVER_QUERY_LIMIT`, `REQUEST_DENIED`, `UNKNOWN_ERROR`). |

***

### 2. Path Elevation Request

#### Endpoint Example

```
https://maps.googleapis.com/maps/api/elevation/json?path=36.578581,-118.291994|36.23998,-116.83171&samples=3&key=YOUR_API_KEY
```

This returns elevation values along a path between multiple coordinates.

#### Parameters

| Parameter | Type    | Description                                                                    |
| --------- | ------- | ------------------------------------------------------------------------------ |
| `path`    | string  | A set of two or more latitude/longitude pairs defining a path, separated by \` |
| `samples` | integer | The number of equally spaced points along the path to sample for elevation.    |
| `key`     | string  | Your API key.                                                                  |

#### Response Example

```json
{
  "results": [
    {
      "elevation": 1608.637939453125,
      "location": {"lat": 36.578581, "lng": -118.291994},
      "resolution": 4.771975994110107
    },
    {
      "elevation": 1523.73828125,
      "location": {"lat": 36.400433, "lng": -117.561852},
      "resolution": 4.771975994110107
    },
    {
      "elevation": -64.37896728515625,
      "location": {"lat": 36.23998, "lng": -116.83171},
      "resolution": 19.08790397644043
    }
  ],
  "status": "OK"
}
```

***

### 3. Common Response Fields

| Field                    | Type   | Description                                                   |
| ------------------------ | ------ | ------------------------------------------------------------- |
| `results`                | array  | Contains one or more elevation data points.                   |
| `results[].elevation`    | float  | Elevation in meters above sea level.                          |
| `results[].location.lat` | float  | Latitude of the elevation point.                              |
| `results[].location.lng` | float  | Longitude of the elevation point.                             |
| `results[].resolution`   | float  | Maximum resolution (in meters) of the elevation data.         |
| `status`                 | string | Status code indicating the success or failure of the request. |

***

### 4. Error Status Codes

| Status             | Meaning                                                                |
| ------------------ | ---------------------------------------------------------------------- |
| `OK`               | Request succeeded.                                                     |
| `INVALID_REQUEST`  | The request is missing a required parameter or has an invalid value.   |
| `OVER_QUERY_LIMIT` | The request exceeded your usage quota.                                 |
| `REQUEST_DENIED`   | The request was denied, often due to an invalid or restricted API key. |
| `UNKNOWN_ERROR`    | A server error occurred. Try again later.                              |

***

### Example Use Case

**Retrieve the elevation profile along a hiking trail**

```bash
curl "https://maps.googleapis.com/maps/api/elevation/json?path=34.11,-118.11|34.13,-118.15&samples=5&key=YOUR_API_KEY"
```

This returns five elevation points evenly spaced along the specified path, allowing you to plot an elevation profile.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://space-axolotls.gitbook.io/space-axolotls-docs/api-documentation/google-maps-elevation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
