# Connecting to the Stream Endpoints

### Connection Protocol

This section defines how to connect to the websocket. This works well in Postman.

<details>

<summary>Submit Auth Request</summary>

1. Open websocket connection to the host and path for the data feed desired
2. Submit authentication request

a. Use the same bearer token used to access any other part of the DDE\
b.

```json
{
  "authToken": "<BEARER TOKEN>"
}
```

</details>

<details>

<summary>Successful Authentication Response</summary>

Successful authentication will return a json response\
{

```json
  "message":"Authorisation accepted",
  "level":"INFO"

}
```

</details>

<details>

<summary>Heartbeats</summary>

At this point a Heartbeat will be sent every 10seconds

```json
{
    "message": "Heartbeat sent at <ISO_DATE_TIME_STAMP>",
    "level": "INFO"
}
```

</details>

<details>

<summary>Submit a fixture request</summary>

```json
{
  "fixtureId": "<FIXTURE ID>", 
  "backfill": <BACKFILL>
}
```

1. Backfill Logic
   1. `n = null` -> all messages from start of feed + all future messages
   2. `n = -1` -> all messages from start of feed + all future messages
   3. `n = 0` -> all future messages ONLY

If the fixture exists then the data feed will commence

**Once a fixture has been requested and accepted, any further fixture requests will be ignored.The connection must be closed and a new one opened to get a new fixture feed**

</details>

{% hint style="info" %}
Once a fixture has been requested and accepted, any further fixture requests will be ignored

The connection must be closed and a new one opened to get a new fixture feed
{% endhint %}

### Error Responses & Handling

#### Failed Authentication Request <a href="#failed-authentication-request" id="failed-authentication-request"></a>

{% hint style="info" %}
The connection will be closed with a message
{% endhint %}

<details>

<summary>Authentication Error Message</summary>

```
{
    "message": "Authentication message had incorrect format",
    "level": "ERROR"
}
```

</details>

#### Unknown Fixture <a href="#unknown-fixture" id="unknown-fixture"></a>

{% hint style="info" %}
The connection will remain open and a warning message will be returned
{% endhint %}

<details>

<summary>Unknown Fixture</summary>

```
{
    "message": "Could not find fixture topic soccer.tracking.enrichment.08456e52-9cf7-48cc-913c-f45ec",
    "level": "WARN"
}
```

</details>


---

# Agent Instructions: 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:

```
GET https://docs.sportradar.com/tennis/p-and-b-tracking-websockets/connecting-to-the-stream-endpoints.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
