> For the complete documentation index, see [llms.txt](https://docs.racemap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.racemap.com/api/distance.md).

# \*/distance and locations

API with real-time geolocations, distances, and bearings to a reference device; for maximum stability and minimum delay the data is processed as little as possible

### Request

**URL** `https://racemap.com/api/data/v1/:eventId/distance`\
**Method** GET

**Live sample** <https://racemap.com/api/data/v1/66bf4318d1c783279d183dd3/distance>\
Corresponding map <https://racemap.com/player/100KmDuathlon2018_API-live-sample>

#### Optional query with `deviceId`

* The `deviceId` of a chosen reference device to calculate `gapDistance` and `bearing` to the other devices.
* If API is called without a `deviceId` then `gapDistance` and `bearing` is calculated for the first device in the list.
* Sample [https://racemap.com/api/data/v1/66bf4318d1c783279d183dd3/distance<mark style="background-color:red;">**?**</mark>**deviceId=66bf4318d1c783279d183e3d**](https://racemap.com/api/data/v1/66bf4318d1c783279d183dd3/distance?deviceId=66bf4318d1c783279d183e3d)

### Response

#### Event object

| Field       | Description \[unit]           | Sample                            |
| ----------- | ----------------------------- | --------------------------------- |
| `name`      | Name of event                 | `"Sample live \| 100km Duathlon"` |
| `location`  | Location                      | `"🇩🇪 Dresden"`                  |
| `startTime` | Start time in UTC             | `"2022-03-09T07:00:03.201Z"`      |
| `endTime`   | End time in UTC               | `"2022-03-09T14:59:38.201Z"`      |
| `starters`  | Array for participant objects |                                   |

#### Participant object

| Field         | Description \[unit]                                                                                                                                                                                                                     | Sample                                                                                                |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `id`          | Unique Racemap ID of participant                                                                                                                                                                                                        | `"61a2122f181c0a6c4bb5376e"`                                                                          |
| `importId`    | User-defined ID with imported participant data, [Generic API](/api-import-and-export-data/import-basics/metadata-api.md) (`importId`) or [RACE\|RESULT API](/api-import-and-export-data/import-basics/metadata-import-via-rr.md) (`Id`) | <p><code>"UniqueImportId\_2"</code> or <code>"null"</code><br>if no importId exists</p>               |
| `startNumber` | Bib number                                                                                                                                                                                                                              | `"2"`                                                                                                 |
| `name`        | Name                                                                                                                                                                                                                                    | `"CLV Megware"`                                                                                       |
| `current`     | Object for real-time data                                                                                                                                                                                                               | <p><code>null</code></p><p>if no locations within <code>startTime</code> and <code>endTime</code></p> |

#### Current object

The `current`-object provides the latest data

| Field         | Description \[unit]                                                                                  | Sample                                          |
| ------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| `time`        | Timestamp in UTC when device recorded latest geolocation                                             | `"2022-03-09T13:23:15.000Z"`                    |
| `lat`         | Latitude                                                                                             | `51.04229`                                      |
| `lng`         | Longitude                                                                                            | `13.63867`                                      |
| `elv`         | Elevation                                                                                            | `63`                                            |
| `gapDistance` | Distance \[m] between latest locations of device and reference device                                | `679.80` or `0` for the reference device        |
| `bearing`     | Angle \[°] line between latest locations of device and reference device and line from south to north | `-76.372782293` or `0` for the reference device |

![](https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2FouAeThHyAMxllgova0KJ%2FgapDistance.png?alt=media\&token=7e5619a9-7b6f-4ef0-81df-07cc7443ff16)

#### Sample response

{% code expandable="true" %}

```javascript
{
  "name": "Sample repeat | 100km Duathlon ",
  "location": "🇩🇪 Dresden",
  "startTime": "2022-01-17T07:00:02.881Z",
  "endTime": "2022-01-17T15:00:02.881Z",
  "starters": [
    {
      "id": "61a2122f181c0a0ff7b53765",
      "importId": "UniqueImportId_1",
      "startNumber": "001",
      "name": "🔥 Flaming 🔥 Sideburns 🔥",
      "current": {
        "time": "2022-01-17T12:13:30.000Z",
        "lat": 51.10966,
        "lng": 13.71298,
        "gapDistance": 0,
        "bearing": 0
      }
    },
    {
      "id": "61a2122f181c0a6c4bb5376e",
      "importId": "UniqueImportId_2",
      "startNumber": "002",
      "name": "CLV Megware meets SG Adelsberg",
      "current": {
        "time": "2022-01-17T12:13:30.000Z",
        "lat": 51.11025,
        "lng": 13.7107,
        "gapDistance": 172.16007216012576,
        "bearing": 112.39911045990338
      }
    },
    {
      "id": "61a21230181c0a4ab0b53944",
      "importId": "UniqueImportId_54",
      "startNumber": "21",
      "name": "Kingscupkönige",
      "current": null
    }
  ]
}
```

{% endcode %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.racemap.com/api/distance.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
