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

Pet Module

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

Project: Pet Feeder | page_id: 1731

Pet Authentication Interface Documentation

Overview

  • Base path: /api
  • Documentation scope: pet module interfaces in the authenticated routes
  • Authentication method: request header X-Token
  • Content-Type: application/json

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
}

Pet Object Field Description

Field Type Description
id string Public pet ID
userId integer Owning user ID
deviceId string Associated device ID
name string Pet name
type string Pet type, such as dog, cat, other
breed string Breed
age string Age group, such as young, adult, senior
gender string Gender, such as male, female
avatar string Pet avatar identifier, currently usually an emoji or a short string
weight integer Weight, in grams
createdAt string Creation time
updatedAt string Update time

1. Get the Pet List

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

Request Body Parameters

Field Type Required Description
deviceId string No Unique device identifier. When it is not passed, all pets are queried by the current user; when it is passed, the query is by device

Request Example

{
  "deviceId": "dev_001"
}

An empty object can also be passed:

{}

Success Response Example

{
  "code": 200,
  "msg": "Operation successful",
  "data": [
    {
      "id": "pet_001",
      "userId": 1,
      "deviceId": "dev_001",
      "name": "Doudou",
      "type": "Cat",
      "breed": "British Shorthair",
      "age": "Adult",
      "gender": "Female",
      "avatar": "🐱",
      "weight": 4200,
      "createdAt": "2026-05-09T10: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 Pet list
data[].* object Pet object; see the pet object field description above

Failure Response Example

{
  "code": 400,
  "msg": "Parameter error",
  "data": null
}
{
  "code": 500,
  "msg": "Failed to get the pet list",
  "data": null
}

2. Add a Pet

  • Path: /api/pet/add
  • Method: POST
  • Authentication required: Yes

Request Body Parameters

Field Type Required Description
deviceId string No Associated device ID. When it is passed, the server verifies that the device exists and belongs to the current user
name string Yes Pet name
type string Yes Pet type, such as dog, cat, other
breed string No Breed
age string No Age group
gender string No Gender
avatar string No Avatar identifier
weight integer No Weight, in grams

Request Example

{
  "deviceId": "dev_001",
  "name": "Doudou",
  "type": "Cat",
  "breed": "British Shorthair",
  "age": "Adult",
  "gender": "Female",
  "avatar": "🐱",
  "weight": 4200
}

Success Response Example

{
  "code": 200,
  "msg": "Pet added successfully",
  "data": {
    "id": "pet_001",
    "userId": 1,
    "deviceId": "dev_001",
    "name": "Doudou",
    "type": "Cat",
    "breed": "British Shorthair",
    "age": "Adult",
    "gender": "Female",
    "avatar": "🐱",
    "weight": 4200,
    "createdAt": "2026-05-09T10:00:00Z",
    "updatedAt": "2026-05-09T10:00:00Z"
  }
}

Response Parameter Description

Field Type Description
code integer 200 on success
msg string Pet added successfully on success
data object The newly created pet object
data.* mixed Pet object fields, see the pet object field description above

Failure Response Example

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

3. Update Pet Information

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

Request Body Parameters

Field Type Required Description
id string Yes Public pet ID
name string No New pet name
breed string No New breed
age string No New age group
gender string No New gender
avatar string No New avatar identifier
weight integer No New weight, in grams; updated only when it is greater than 0

Request Example

{
  "id": "pet_001",
  "name": "Doudou",
  "breed": "Golden Chinchilla",
  "age": "Adult",
  "gender": "Female",
  "avatar": "🐱",
  "weight": 4500
}

Success Response Example

{
  "code": 200,
  "msg": "Pet information updated",
  "data": null
}

Response Parameter Description

Field Type Description
code integer 200 on success
msg string Pet information updated on success
data null No returned data

Failure Response Example

{
  "code": 400,
  "msg": "Parameter error",
  "data": null
}
{
  "code": 400,
  "msg": "Pet does not exist",
  "data": null
}
{
  "code": 400,
  "msg": "No permission to operate",
  "data": null
}

4. Delete a Pet

  • Path: /api/pet/delete
  • Method: POST
  • Authentication required: Yes

Request Body Parameters

Field Type Required Description
id string Yes Public pet ID

Request Example

{
  "id": "pet_001"
}

Success Response Example

{
  "code": 200,
  "msg": "Pet deleted",
  "data": null
}

Response Parameter Description

Field Type Description
code integer 200 on success
msg string Pet deleted on success
data null No returned data

Failure Response Example

{
  "code": 400,
  "msg": "Parameter error",
  "data": null
}
{
  "code": 400,
  "msg": "Pet does not exist",
  "data": null
}
{
  "code": 400,
  "msg": "No permission to operate",
  "data": null
}

Appendix

Description

  • Getting the pet list returns an array; when there is no data, an empty array is returned instead of null.
  • When adding a pet, deviceId can be empty; when it is empty, the pet only belongs to the user and is not forcibly bound to a device.
  • When updating a pet, type and deviceId currently cannot be modified; only the name, breed, age, gender, avatar and weight can be updated.
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.