Skip to content

API Documentation

Jamie Jones edited this page Oct 20, 2024 · 1 revision

Standalone PETLIBRO API Documentation

This section provides detailed information about the PetLibro API used in this integration. The API allows you to interact with PetLibro devices, retrieve device status, and manage device settings programmatically.

Base URL

The base URL for the API is:
https://api.us.petlibro.com

Endpoints

1. GET /device/device/list

Retrieve a list of all devices associated with your PetLibro account.

Request:

  • Method: GET
  • URL: /device/device/list
  • Headers:
    • Authorization: Bearer {your_token}

Response:

{
  "code": 200,
  "data": [
    {
      "deviceId": "123456789",
      "deviceName": "Granary Smart Feeder",
      "deviceType": "Feeder",
      "status": "online"
    }
  ]
}

2. POST /device/device/baseInfo

Retrieve basic information for a specific device.

Request:

  • Method: POST
  • URL: /device/device/baseInfo
  • Headers:
    • Authorization: Bearer {your_token}
  • Body:
{
  "deviceId": "123456789"
}
{
  "code": 200,
  "data": {
    "deviceId": "123456789",
    "deviceName": "Granary Smart Feeder",
    "firmwareVersion": "1.0.0",
    "batteryStatus": "Good"
  }
}

3. POST /device/device/realInfo

Retrieve real-time information from a specific device, such as feeding activity, current settings, and status.

Request:

  • Method: POST
  • URL: /device/device/realInfo
  • Headers:
    • Authorization: Bearer {your_token}
  • Body:
{
  "deviceId": "123456789"
}
{
  "code": 200,
  "data": {
    "deviceId": "123456789",
    "feedingStatus": "Feeding",
    "currentGrainLevel": "75%",
    "nextScheduledFeed": "2024-10-20T08:00:00Z"
  }
}

4. GET /device/data/grainStatus

Retrieve the current grain status of a feeder, such as the remaining food level and whether there are any blockages.

Request:

  • Method: GET
  • URL: /device/data/grainStatus
  • Headers:
    • Authorization: Bearer {your_token}

Response:

{
  "code": 200,
  "data": {
    "deviceId": "123456789",
    "remainingGrain": "75%",
    "grainBlocked": false
  }
}

Authentication

All API requests require an Authorization header with a Bearer token. You can obtain this token by logging in through the official PetLibro app or via the Home Assistant integration, which handles token generation automatically.

Error Codes

The following error codes are used in the PetLibro API integration:

  • 200: Success - The request was successful.
  • 1009: General Error - Indicates a failure or error in the API request.
  • 401: Unauthorized - Invalid or expired token, requiring a new login or token refresh.

These codes are essential for troubleshooting issues when interacting with the PetLibro API.

Notes

For more detailed usage examples and device-specific features, please refer to the device's specific API documentation.

Clone this wiki locally