
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
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.
Pictures are available with or without Care+ subscription, Videos are only available with Care+ subscription
Install the library using pip:
pip install pypetkitapi
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())
Check at the usage in the Home Assistant integration : here
Developers? Want to help? Join us on our Discord channel dedicated to developers and contributors.
Contributions are welcome!
Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
Python client for PetKit API
We found that pypetkitapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.