Home / Docs Center / Pet Feeder (ODM Case) / Device Base Module

Device Base Module

Pet Feeder (ODM Case) · App Server-Side API

Project: Pet Feeder | page_id: 1726

Device Module Authentication Interface Documentation

Overview

  • Base path: /api
  • Documentation scope: only includes device basic authentication interfaces
  • Authentication method: request header X-Token
  • Content-Type: application/json

Document Split

  • This document: device basic interfaces, including list, detail, bind, unbind and update
  • P2P proxy interfaces: see device-auth-p2p.md
  • Live address and recording address interfaces: see device-auth-address.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/array/null Business data

Common Authentication Failure Response

{
  "code": 401,
  "msg": "Not logged in or login expired",
  "data": null
}
{
  "code": 401,
  "msg": "Login has expired, please log in again",
  "data": null
}

Device Object Field Description

The data returned when getting the device list, device details or binding a device successfully may contain the following fields:

Field Type Description
id string Unique device identifier
userId integer Currently bound user ID
familyId string Family ID it belongs to
name string Device name
batteryLevel integer Battery percentage
isCharging boolean Whether it is charging
foodLevel integer Remaining food percentage
firmwareVersion string Firmware version
totalFeedCount integer Total number of feedings
todayFeedCount integer Number of feedings today
todayFeedAmount integer Total amount fed today (reset automatically across days)
lastStartTime integer Last online timestamp, in seconds
lastCloseTime integer Last offline timestamp, in seconds
online boolean Whether it is online
isDisabled boolean Whether it is disabled
isNew integer Device status flag, 0 reconnection, 1 program restart, 2 device restart
eip string External network IP
cloudVer string Cloud version
addr string Device address
createdAt string Creation time
updatedAt string Update time

1. Get the Device List

  • Path: /api/device/list
  • Method: POST
  • Authentication required: Yes

Request Body Parameters

Field Type Required Description
familyId string No Family ID. When it is not passed, the device list is queried by the current user; when it is passed, the query is by family

Request Example

{
  "familyId": "family_001"
}

An empty object can also be passed:

{}

Success Response Example

{
  "code": 200,
  "msg": "Operation successful",
  "data": [
    {
      "id": "dev_001",
      "userId": 1,
      "familyId": "family_001",
      "name": "Living room feeder",
      "batteryLevel": 86,
      "isCharging": false,
      "foodLevel": 70,
      "firmwareVersion": "1.0.2",
      "totalFeedCount": 12,
      "todayFeedCount": 3,
      "lastStartTime": 1752297600,
      "lastCloseTime": 1752280000,
      "online": true,
      "isDisabled": false,
      "isNew": 0,
      "eip": "1.2.3.4",
      "cloudVer": "cloud-2026.05",
      "addr": "192.168.1.10",
      "createdAt": "2026-05-01T10:00:00Z",
      "updatedAt": "2026-05-09T10:00:00Z"
    }
  ]
}

Response Parameter Description

Field Type Description
code integer 200 on success
msg string Operation successful on success
data array Device list
data[].* object Device object fields, see the device object field description above

Failure Response Example

{
  "code": 500,
  "msg": "Failed to get the device list",
  "data": null
}

2. Get Device Details

  • Path: /api/device/detail
  • Method: POST
  • Authentication required: Yes

Request Body Parameters

Field Type Required Description
deviceId string Yes Unique device identifier

Request Example

{
  "deviceId": "dev_001"
}

Success Response Example

{
  "code": 200,
  "msg": "Operation successful",
  "data": {
    "id": "dev_001",
    "userId": 1,
    "familyId": "family_001",
    "name": "Living room feeder",
    "batteryLevel": 86,
    "isCharging": false,
    "foodLevel": 70,
    "firmwareVersion": "1.0.2",
    "totalFeedCount": 12,
    "todayFeedCount": 3,
    "lastStartTime": 1752297600,
    "lastCloseTime": 1752280000,
    "online": true,
    "isDisabled": false,
    "isNew": 0,
    "eip": "1.2.3.4",
    "cloudVer": "cloud-2026.05",
    "addr": "192.168.1.10",
    "createdAt": "2026-05-01T10:00:00Z",
    "updatedAt": "2026-05-09T10:00:00Z"
  }
}

Response Parameter Description

Field Type Description
code integer 200 on success
msg string Operation successful on success
data object Device details
data.* mixed Device object fields, see the device object field description above

Failure Response Example

{
  "code": 400,
  "msg": "Parameter error",
  "data": null
}
{
  "code": 404,
  "msg": "Device does not exist",
  "data": null
}

3. Bind a Device

  • Path: /api/device/bind
  • Method: POST
  • Authentication required: Yes

Request Body Parameters

Field Type Required Description
deviceId string Yes Unique device identifier
familyId string Yes Family ID. A family must be specified when binding a device
name string No Custom device name. At most 30 characters, allowing only Chinese characters, letters, digits, underscores and hyphens

Request Example

{
  "deviceId": "dev_001",
  "familyId": "family_001",
  "name": "Living room feeder"
}

Success Response Example

{
  "code": 200,
  "msg": "Device bound successfully",
  "data": {
    "id": "dev_001",
    "userId": 1,
    "familyId": "family_001",
    "name": "Living room feeder"
  }
}

Response Parameter Description

Field Type Description
code integer 200 on success
msg string Device bound successfully on success
data.id string Unique device identifier
data.userId integer Currently bound user ID
data.familyId string Family ID
data.name string Device name

Failure Response Example

{
  "code": 400,
  "msg": "familyId cannot be empty",
  "data": null
}
{
  "code": 400,
  "msg": "Device does not exist and cannot be bound",
  "data": null
}
{
  "code": 400,
  "msg": "This device is already bound by someone else",
  "data": null
}
{
  "code": 400,
  "msg": "The device name cannot exceed 30 characters",
  "data": null
}
{
  "code": 400,
  "msg": "The device name can only contain Chinese characters, letters, digits, underscores and hyphens",
  "data": null
}

4. Unbind a Device

  • Path: /api/device/unbind
  • Method: POST
  • Authentication required: Yes

Request Body Parameters

Field Type Required Description
deviceId string Yes Unique device identifier

Request Example

{
  "deviceId": "dev_001"
}

Success Response Example

{
  "code": 200,
  "msg": "Device unbound",
  "data": null
}

Response Parameter Description

Field Type Description
code integer 200 on success
msg string Device unbound on success
data null No returned data

Failure Response Example

{
  "code": 400,
  "msg": "Device does not exist",
  "data": null
}
{
  "code": 400,
  "msg": "No permission to operate this device",
  "data": null
}

5. Update the Device Name

  • Path: /api/device/update
  • Method: POST
  • Authentication required: Yes

Request Body Parameters

Field Type Required Description
deviceId string Yes Unique device identifier
name string No New device name. At most 30 characters, allowing only Chinese characters, letters, digits, underscores and hyphens

Request Example

{
  "deviceId": "dev_001",
  "name": "Dining room feeder"
}

Success Response Example

{
  "code": 200,
  "msg": "Update successful",
  "data": null
}

Response Parameter Description

Field Type Description
code integer 200 on success
msg string Update successful on success
data null No returned data

Failure Response Example

{
  "code": 400,
  "msg": "Device does not exist",
  "data": null
}
{
  "code": 400,
  "msg": "No permission to operate this device",
  "data": null
}
{
  "code": 400,
  "msg": "The device name cannot exceed 30 characters",
  "data": null
}
{
  "code": 400,
  "msg": "The device name can only contain Chinese characters, letters, digits, underscores and hyphens",
  "data": null
}

Appendix

Description

  • This document only retains the device basic interfaces.
  • The P2P proxy interfaces still pass parameters such as deviceId and sessionId through query; see device-auth-p2p.md.
  • The live address and recording address interfaces use the unified response structure; see device-auth-address.md.
Didn't find what you need?Contact us,Talk to our engineers directly.

Request a Quote

Fill in the form and we will get back with a quote and proposal within 1 business day.

Click "Generate inquiry email" to open your mail client with the body pre-filled. If no mail client is configured, click "Copy" and paste it into webmail — recipient: sunshiyang@xstrive.com.