# Other timing system

Your timing system provides the information of **UTC timestamps**, **chip IDs** (or transponder IDs), and ideally **GEO locations and** you can send this data to RACEMAP server.

When a participant passes a decoder, the timing system generates data including the **timestamp** and the **ID**. You can format this data as a **JSON array** (as shown below) and send it to our servers.

You can use any programming language that supports **HTTPS-based POST requests with JSON bodies**. To test the approach, follow the steps below or set up **permanent forwarding** within your timing system.

For this setup, a **programmer** or someone with **technical expertise** is recommended. However, if you need assistance, reach out to us — we support you build a **reliable, and easy-to-use solution**, similar to our solution with RACE RESULT.

Therr are two scenarios **RACEMAP** receives data from a timekeeping software.

1. Recommended: Reads (detections) include the reader's GEO location.&#x20;
2. Reads without the GEO location. In that case, the [readers' locations must be set in RACEMAP](#set-readers-locations) map editor.&#x20;

### HTTP Request

**URL**        `https://racemap.com/services/trackping/api/v1/timing_input/pings`

**Method** `POST`&#x20;

#### Reads object&#x20;

A read can have the following data fields. Some of them are required, some are optional.

<table data-full-width="false"><thead><tr><th width="169">Field</th><th width="311">Description</th><th width="294">Sample</th><th data-hidden></th></tr></thead><tbody><tr><td><code>timingId</code></td><td>Unique ID of the reader</td><td><code>"XF32098"</code> or <code>"_8nx7uoyun"</code> </td><td></td></tr><tr><td><code>timingName</code> *</td><td>Name of reader in timing software</td><td><code>"5K-split"</code> or <code>"Start II"</code></td><td></td></tr><tr><td><code>chipId</code></td><td>Transponder ID</td><td><code>"RRPing_ZDKAR32"</code> or <code>"RRPing_70761"</code> or <code>"HH32098"</code></td><td></td></tr><tr><td><code>timestamp</code></td><td><a href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time">Timestamp in UTC</a> when the reader detects the transponder</td><td><code>"2023-11-09T16:35:05.248Z"</code></td><td></td></tr><tr><td><code>lat</code> **</td><td>Latitude of the reader</td><td><code>51.5074</code></td><td></td></tr><tr><td><code>lng</code> **</td><td>Longitude of the reader</td><td><code>13.7276</code></td><td></td></tr></tbody></table>

(\*) Optional parameter without impact on processing the reads in RACEMAP.

(\*\*) If unavailable you have to set GEO locations for each reader in the [RACEMAP](https://racemap.com/admin/events) map editor

### Examples

The examples demonstrate the process of&#x20;

* converting your timing data into **RACEMAP**-compatible reads,&#x20;
* sending the data to our server, and&#x20;
* testing access using the API token.&#x20;

Once your timing data is successfully forwarded to RACEMAP, we can provide further support to help you build a reliable integration.

{% tabs %}
{% tab title="1. Using VS Code" %}
To test this example, use the [VS Code](https://code.visualstudio.com/) editor. &#x20;

* Install VS Code on your computer.&#x20;
* Install the [Rest Client Extension](< vscode:extension/humao.rest-client>).
* Save the below sample into a file with the name `test.rest` .
* Open the file in VS Code.
* Paste your **API token**.
* Send the HTTP request to our server.
* Check the **prediction section** of your event in RACEMAP for received reads.

In the 1st sample, the GEO locations of each reader are defined. The `timingId`  identifies the reader and does not influence data processing in the RACEMAP backend. You can use these IDs to verify whether your data was correctly received by RACEMAP.

```json
POST https://racemap.com/services/trackping/api/v1/timing_input/pings
Content-Type: application/json
authorization: Bearer [Place your API token here]

[
  {
    "timingId": "XF32098",
    "timingName": "Start",
    "chipId": "HH32097",
    "timestamp": "2023-11-09T16:31:07.248Z",
    "lat": 51.5074,
    "lng": 13.7386
  },
  {
    "timingId": "XF32099",
    "timingName": "Start II",
    "chipId": "HH32098",
    "timestamp": "2023-11-09T16:31:05.248Z",
    "lat": 51.5074,
    "lng": 13.7386
  },
  {
    "timingId": "XF32100",
    "chipId": "HH32099",
    "timestamp": "2023-11-09T16:32:04.248Z",
    "lat": 51.5074,
    "lng": 13.7386
  }
]
```

In the 2nd sample, the GEO locations of the readers are not defined. You can manually set them in RACEMAP. For each `timingId`, you can define a GEO location in the map editor section of your event. Our prediction algorithm will then use these manually assigned locations.

However, this method is not recommended, as errors may occur if incorrect locations are defined.

<pre class="language-json"><code class="lang-json"><strong>POST https://racemap.com/services/trackping/api/v1/timing_input/pings
</strong>Content-Type: application/json
authorization: Bearer [Place your API token here]
<strong>
</strong>[
  {
    "timingId": "XF32098",
    "timingName": "Start",
    "chipId": "HH32097",
    "timestamp": "2023-11-09T16:31:07.248Z"
  },
  {
    "timingId": "XF32099",
    "timingName": "Start II",
    "chipId": "HH32098",
    "timestamp": "2023-11-09T16:31:05.248Z",
  },
  {
    "timingId": "XF32100",
    "chipId": "HH32099",
    "timestamp": "2023-11-09T16:32:04.248Z",
  }
]
</code></pre>

{% endtab %}

{% tab title="2. Using Python" %}
Python Code for Sending Timing Data (with GEO locations)

Setup Instructions:

* Install [**VS Code** ](https://code.visualstudio.com/)on your computer.
* Install the [**Python extension**](< vscode:extension/ms-python.python>) in VS Code.
* Install the `requests` library if not already installed:
* Save the content below as `test.py`.
* Replace `YOUR_API_TOKEN` with your actual API token.
* Run the script in VS Code.
* On success  `response.status_code` should be 200.
* Check the **prediction section** of your event in Racemap for received reads.

```python
import requests

# API Endpoint
url = "https://racemap.com/services/trackping/api/v1/timing_input/pings"

# API Token (Replace with your actual token)
api_token = "YOUR_API_TOKEN"

# Headers
headers = {
    "Content-Type": "application/json",
    "authorization": f"Bearer {api_token}"
}

# Timing data with GEO locations
data_with_geo = [
    {
        "timingId": "XF32098",
        "timingName": "Start",
        "chipId": "HH32097",
        "timestamp": "2023-11-09T16:31:07.248Z",
        "lat": 51.5074,
        "lng": 13.7386
    },
    {
        "timingId": "XF32099",
        "timingName": "Start II",
        "chipId": "HH32098",
        "timestamp": "2023-11-09T16:31:05.248Z",
        "lat": 51.5074,
        "lng": 13.7386
    },
    {
        "timingId": "XF32100",
        "chipId": "HH32099",
        "timestamp": "2023-11-09T16:32:04.248Z",
        "lat": 51.5074,
        "lng": 13.7386
    }
]

# Sending request
response = requests.post(url, json=data_with_geo, headers=headers)

# Output response
print(f"Status Code: {response.status_code}")
print(f"Response: {response.text}")

```

Python Code for Sending Timing Data (without GEO locations)

```python
import requests

# API Endpoint
url = "https://racemap.com/services/trackping/api/v1/timing_input/pings"

# API Token (Replace with your actual token)
api_token = "YOUR_API_TOKEN"

# Headers
headers = {
    "Content-Type": "application/json",
    "authorization": f"Bearer {api_token}"
}

# Timing data without GEO locations
data_with_geo = [
    {
        "timingId": "XF32098",
        "timingName": "Start",
        "chipId": "HH32097",
        "timestamp": "2023-11-09T16:31:07.248Z"
    },
    {
        "timingId": "XF32099",
        "timingName": "Start II",
        "chipId": "HH32098",
        "timestamp": "2023-11-09T16:31:05.248Z"
    },
    {
        "timingId": "XF32100",
        "chipId": "HH32099",
        "timestamp": "2023-11-09T16:32:04.248Z"
    }
]

# Sending request
response = requests.post(url, json=data_with_geo, headers=headers)

# Output response
print(f"Status Code: {response.status_code}")
print(f"Response: {response.text}")

```

{% endtab %}
{% endtabs %}

### **Response**

If everything is correct the HTTP code 200 is returned.

### **Set readers' locations**&#x20;

Case 2, if reads are sent without coordinates: \
Virtually define the locations of your readers in the [map settings](https://docs.racemap.com/tab-map) of your tracking map.&#x20;

* Upload the race track.&#x20;
* Set this track as the [shadowtrack of the race](https://docs.racemap.com/live-tracking/shadowtrack#shadowtrack).
* Create a split representing the location of your reader at the race.&#x20;
* Check "Timekeeping"&#x20;
* Provide the unique `timingId` in the field "IDs of Timing Systems" of the split. You can add multiple `timingId` to a split, if you use multiple readers at the same location.&#x20;

Note: If a single reader is used for multiple detections (e.g., timing a lap race at 5K and 10K), enter its location only once. There's no need to add the reader multiple times.

<figure><img src="https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2F5nZh9gW6455mv8dxpjcK%2Fscreenshot-racemap.com-2024.08.29-15_14_13.png?alt=media&#x26;token=c750e0a0-bfd5-4a0b-9b5c-92ddfbaae06e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2F62okU58tX7W4vOicag46%2Fscreenshot-racemap.com-2024.08.29-15_19_15.png?alt=media&#x26;token=c2c4e751-a123-499b-9dfa-d9bfa572d932" alt=""><figcaption><p>Split "CP-1" with the unique split id U078</p></figcaption></figure>
