# Live Actions

The Live Actions websocket contains a live 'stream' of the team and player actions happening within the basketball match - this will include; 3 points made, free throws, steals, turnovers and more.

You should receive a new update any time a key action is completed and this websocket is crucial for powering live scores and match actions.

The authentication token provided will be required to make a connection to this websocket endpoint.

Once you have the API token, any further data that you send over the connection will be ignored.

N.B – This endpoint sends heartbeats in-between data packets to let you know that it is still connected.

## Endpoint URL

**wss\://dde-streams.data.imgarena.com/media/basketball/fixtures/{fixtureId}/actions**

> **wss\://dde-streams.data.imgarena.com/media/basketball/fixtures/{fixtureId}/actions**

`CONNECT` `wss://dde-streams.data.imgarena.com/media/basketball/fixtures/{fixtureId}/actions`

#### Headers

| Name                                            | Type   | Description                                      |
| ----------------------------------------------- | ------ | ------------------------------------------------ |
| Accept<mark style="color:red;">\*</mark>        | String | application/vnd.imggaming.dde.api+json;version=1 |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {token}                                   |
| Connection<mark style="color:red;">\*</mark>    | String | keep-alive                                       |

{% tabs %}
{% tab title="401: Unauthorized " %}

```javascript
{
    The supplied authentication is invalid
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    Request is missing required HTTP header 'Accept'
}
```

{% endtab %}
{% endtabs %}

N.B. – Please insert the relevant fixtureId returned from the fixtures API endpoint to return you the data. The authentication token provided will be required to make a connection to this websocket endpoint.

### Process for connecting to the web socket endpoints

* Connect to SSL websocket address
* Send JSON packet containing API token
* Receive response indicating that connection is authorised (or a response indicating why the connection cannot be made)
* Receive heartbeat packets every 10 seconds to verify the connection is live
* Receive data packets

Once you have the API token, any further data that you send over the connection will be ignored. This endpoint sends heartbeats in-between data packets to let you know that it is still connected.

## Request parameters

There are 2 optional params, that are in common with these Websocket endpoints:<br>

* “speed” - this can be “fast” or “normal”. Default is normal and only applicable for offline matches
* “startPosition” : integer value, default is 0. This is how many events to skip from the beginning of the list of events. e.g. 5 would be start sending events from the 5th event received for that websocket. This is a useful feature if you want to continue without getting all the events again from the beginning when you reconnect

## Polling limits

IMG Arena monitor the incoming traffic from our customers and strive to ensure that traffic is controlled, in-keeping with our guidelines and not unnecessarily excessive. We would suggest a polling rate of 5 requests per second, whilst we strive towards implementing rate limiting.

## Response Model

For sample JSON files and details of each value with descriptions within the payloads, utilise the following Swagger Pages:

JSON Schema <https://app.swaggerhub.com/apis/IMG_Arena/IMGA-DDE-BASKETBALL/1.4#/basketball/getActionsByFixtureId>

JSON Schema with value descriptions <https://app.swaggerhub.com/apis/IMG_Arena/IMGA-DDE-BASKETBALL/1.4#/ActionMessage>
