Project: Pet Feeder | page_id: 1724
Device Module Authentication Interface Documentation - Address Interfaces
Overview
- Base path: /api
- Documentation scope: device live address and recording playback address interfaces
- Authentication method: request header X-Token
- Content-Type: application/json
Document Split
- This document only retains the live address and recording address interfaces
- For device basic interfaces, see device-auth.md
- For P2P proxy interfaces, see device-auth-p2p.md
Authentication Header
| Field |
Type |
Required |
Description |
| X-Token |
string |
Yes |
The JWT Token obtained after the user logs in |
Unified Response Format
{
"code": 200,
"msg": "Operation successful",
"data": {}
}
Response Field Description
| Field |
Type |
Description |
| code |
integer |
Business status code; 200 means success, other values mean failure |
| msg |
string |
Response message |
| data |
object/null |
Business data |
1. Get the Live Address
- Path: /api/device/live/address
- Method: POST
- Authentication required: Yes
Request Body Parameters
| Field |
Type |
Required |
Description |
| deviceId |
string |
Yes |
Unique device identifier |
| channelId |
integer |
No |
Video channel ID. When it is less than or equal to 0, the server corrects it to 1 |
| expiredTime |
integer |
No |
Expiration time (seconds). When it is invalid, the server corrects it to the current time + 3600 |
Request Example
{
"deviceId": "dev_001",
"channelId": 1,
"expiredTime": 1752297600
}
Success Response Example
{
"code": 200,
"msg": "Operation successful",
"data": {
"address": "https://live.example.com/dev_001/hlsram/live0/token.flv"
}
}
Response Parameter Description
| Field |
Type |
Description |
| code |
integer |
200 on success |
| msg |
string |
Operation successful on success |
| data.address |
string |
Live stream address |
Failure Response Example
{
"code": 400,
"msg": "Parameter error",
"data": null
}
{
"code": 500,
"msg": "Failed to get the live address: failed to set live token in Redis: ...",
"data": null
}
2. Get the Recording Playback Address
- Path: /api/device/record/address
- Method: POST
- Authentication required: Yes
Request Body Parameters
| Field |
Type |
Required |
Description |
| deviceId |
string |
Yes |
Unique device identifier |
| startTime |
integer |
Yes |
Playback start timestamp, in milliseconds |
| endTime |
integer |
Yes |
Playback end timestamp, in milliseconds |
Request Example
{
"deviceId": "dev_001",
"startTime": 1750176000000,
"endTime": 1750262399999
}
Success Response Example
{
"code": 200,
"msg": "Operation successful",
"data": {
"address": "https://record.example.com/xsw/api/record/hls/vod/index.m3u8?..."
}
}
Response Parameter Description
| Field |
Type |
Description |
| code |
integer |
200 on success |
| msg |
string |
Operation successful on success |
| data.address |
string |
Recording playback address |
Failure Response Example
{
"code": 400,
"msg": "Parameter error",
"data": null
}
{
"code": 500,
"msg": "Failed to get the recording address: ...",
"data": null
}
Appendix
Description
- Both the live address and recording address interfaces use the unified response structure.
- In live/address, a channelId less than or equal to 0 is corrected to 1.
- In live/address, an expiredTime less than or equal to 0 is corrected to 3600. The current implementation passes this value directly as the expiredTime parameter of GetDeviceLiveUrl.
- record/address generates the playback address directly from deviceId, startTime and endTime.