Skip to main content

Python client for PetKit API

Project description

Petkit API Client


Lifecycle:Maturing Python Version Actions status

PyPI PyPI Downloads


Quality Gate Status Coverage Lines of Code

Maintainability Rating Reliability Rating Security Rating Bugs Code Smells Duplicated Lines (%) Vulnerabilities

pre-commit Black mypy Ruff


Enjoying this library?

Sponsor Jezza34000 Static Badge


ℹ️ Overview

PetKit Client is a Python library for interacting with the PetKit API. It allows you to manage your PetKit devices, retrieve account data, and control devices through the API.

🚀 Features

  • Login and session management
  • Fetch account and device data
  • Control PetKit devices (Feeder, Litter Box, Water Fountain, Purifiers)
  • Fetch images & videos produced by devices

    Pictures are available with or without Care+ subscription, Videos are only available with Care+ subscription

⬇️ Installation

Install the library using pip:

pip install pypetkitapi

💡 Usage Example:

Here is a simple example of how to use the library to interact with the PetKit API
This example is not an exhaustive list of all the features available in the library.

import asyncio
import logging
import aiohttp
from pypetkitapi.client import PetKitClient
from pypetkitapi.command import DeviceCommand, FeederCommand, LBCommand, DeviceAction, LitterCommand

logging.basicConfig(level=logging.DEBUG)

async def main():
    async with aiohttp.ClientSession() as session:
        client = PetKitClient(
            username="username",  # Your PetKit account username or id
            password="password",  # Your PetKit account password
            region="FR",  # Your region or country code (e.g. FR, US,CN etc.)
            timezone="Europe/Paris",  # Your timezone(e.g. "Asia/Shanghai")
            session=session,
        )

        await client.get_devices_data()

        # Lists all devices and pet from account

        for key, value in client.petkit_entities.items():
            print(f"{key}: {type(value).__name__} - {value.name}")

        # Select a device
        device_id = key
        # Read devices or pet information
        print(client.petkit_entities[device_id])

        # Send command to the devices
        ### Example 1 : Turn on the indicator light
        ### Device_ID, Command, Payload
        await client.send_api_request(device_id, DeviceCommand.UPDATE_SETTING, {"lightMode": 1})

        ### Example 2 : Feed the pet
        ### Device_ID, Command, Payload
        # simple hopper :
        await client.send_api_request(device_id, FeederCommand.MANUAL_FEED, {"amount": 1})
        # dual hopper :
        await client.send_api_request(device_id, FeederCommand.MANUAL_FEED, {"amount1": 2})
        # or
        await client.send_api_request(device_id, FeederCommand.MANUAL_FEED, {"amount2": 2})

        ### Example 3 : Start the cleaning process
        ### Device_ID, Command, Payload
        await client.send_api_request(device_id, LitterCommand.CONTROL_DEVICE, {DeviceAction.START: LBCommand.CLEANING})


if __name__ == "__main__":
    asyncio.run(main())

💡 More example usage

Check at the usage in the Home Assistant integration : here

☑️ Supported Devices

🛟 Help and Support

Developers? Want to help? Join us on our Discord channel dedicated to developers and contributors.

Discord

👨‍💻 Contributing

Contributions are welcome!
Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypetkitapi-1.27.0.tar.gz (48.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypetkitapi-1.27.0-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file pypetkitapi-1.27.0.tar.gz.

File metadata

  • Download URL: pypetkitapi-1.27.0.tar.gz
  • Upload date:
  • Size: 48.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.4 Linux/6.17.0-1010-azure

File hashes

Hashes for pypetkitapi-1.27.0.tar.gz
Algorithm Hash digest
SHA256 c4fbdf838db8d08d6569b1431efa2ad7c19ce2f9d2c9c3ed63487bb498855218
MD5 a693c2e45f09cd952c8ecd5d321c9787
BLAKE2b-256 33ba94cabf9a59c417b65f23441b184eb87477f291f26ca87d7d9ec42d584737

See more details on using hashes here.

File details

Details for the file pypetkitapi-1.27.0-py3-none-any.whl.

File metadata

  • Download URL: pypetkitapi-1.27.0-py3-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.4 Linux/6.17.0-1010-azure

File hashes

Hashes for pypetkitapi-1.27.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a10ccb636ee0cd4c6b53c9d769c2a0e7b3606e3e487f5b0d4aa1bae9119ab63b
MD5 e1596679ba182a82243e7d2463dc805a
BLAKE2b-256 05a11a2e89ed53c24f4f5c27f770ff90c60c840a69e0524ce49921de79cc2287

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page