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

# Racemap

Racemap makes the data of it's trackers available via an easy Web API. This URL is individual per event.&#x20;

The data in this API contains each tracker's distance to start and from finish and many other data.&#x20;

## Get Distance from start from leading vehicles

In this example, we want to fetch the distance to finish from the lead vehicle's tracker.&#x20;

First we need to setup a global list with the URL provided by Racemap and name it *Racemap*:

<figure><img src="https://2601835662-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk5GLs0WFtuWoGrMBjgcM%2Fuploads%2FMJtk9VuyFP5Yusw36Y7g%2Fimage.png?alt=media&amp;token=5b756a47-25d6-4211-8d72-cfbd3bcc9699" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2601835662-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk5GLs0WFtuWoGrMBjgcM%2Fuploads%2F2T247FxFaoOpnxMBqe57%2Fimage.png?alt=media&amp;token=f0d89d00-b478-405c-9dd7-8e3589e7437e" alt=""><figcaption></figcaption></figure>

In a script, we can now access the data via the *Racemap.Data* variable. We loop through all trackers and find tghe one matching the lead vehicle tracker id. And then fetch the *toFinish* property.&#x20;

```
{{
# Define tracker ID
leadTrackerId = "66bf4318d1c783279d183e37"
leadTrackerFound = false

# Loop through all trackers and pick the one we are interested in
for tracker in Racemap.Data.starters
    if (tracker.id == leadTrackerId)
        leadTrackerFound = true
        distanceToFinish = tracker.current.toFinish
    end
end

# Show texts based on distance
if leadTrackerFound
    if distanceToFinish > 0
        "Distance to Finish: " + ((distanceToFinish / 1000) | Format "####0.0") + "km"
     else 
       "Finished"
     end
else 
    "Tracker not found"
end
}}
```
