# Stream

Live video streaming

## Fetch the HLS playlist for a Device camera channel

`GET /stream/{deviceId}/{channel}/live.m3u8`

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Parameters:

- `deviceId` (path, integer, required)
  Type: integer

- `channel` (path, integer, required)
  Type: integer

Responses:

- 200: OK

Content type: application/vnd.apple.mpegurl

Type: string

- 401: Unauthorized

## Examples

### cURL

```bash
curl -X GET 'https://demo.traccar.org/api/stream/0/0/live.m3u8' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE'
```

### JavaScript

```javascript
const response = await fetch('https://demo.traccar.org/api/stream/0/0/live.m3u8', {
  method: 'GET',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://demo.traccar.org/api/stream/0/0/live.m3u8',
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    },
)
print(response.text)
```


## Fetch an HLS video segment for a Device camera channel

`GET /stream/{deviceId}/{channel}/{index}.ts`

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Parameters:

- `deviceId` (path, integer, required)
  Type: integer

- `channel` (path, integer, required)
  Type: integer

- `index` (path, integer, required)
  Type: integer

Responses:

- 200: OK

Content type: video/mp2t

Type: string, binary

- 401: Unauthorized

## Examples

### cURL

```bash
curl -X GET 'https://demo.traccar.org/api/stream/0/0/0.ts' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE'
```

### JavaScript

```javascript
const response = await fetch('https://demo.traccar.org/api/stream/0/0/0.ts', {
  method: 'GET',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://demo.traccar.org/api/stream/0/0/0.ts',
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    },
)
print(response.text)
```
