> For the complete documentation index, see [llms.txt](https://docs.sportradar.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sportradar.com/tennis/p-and-b-tracking-websockets/connecting-to-the-stream-endpoints.md).

# Connecting to the Stream Endpoints

The Stream API provides a stream of live match data as JSON over a WebSocket connection. Please see the below for how to connect to the stream endpoint.

### 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
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://docs.sportradar.com/tennis/p-and-b-tracking-websockets/connecting-to-the-stream-endpoints.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.
