Skip to main content

Python library for PetKit's API

Project description

Petkit_api

Asynchronous Python library for PetKit's API.

This is PetKit's undocumented API. With that said, future changes made by PetKit may break this library. The API endpoint used is determined based on the region your account is locked to. See the Regions section for available region values.

Currently Supported Devices:

Feeders

Litter Boxes

Purifiers

Water Fountains

Working on it :

Important

PetKit accounts can only be logged in on one device at a time. Using this library will result in getting signed out of the mobile app. If you want to continue using the mobile app, use the family share feature to share devices to a secondary account. Note: The secondary account needs to be used with the mobile app while the primary account is used with this library as this library will not fetch devices that are part of family sharing.

This package depends on aiohttp and tzlocal. Python 3.7 or greater is required.

Usage

Regions


See regions available (click to expand)
Region
Afghanistan
Aland Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
Armenia
Aruba
Australia
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belgium
Belize
Benin
Bermuda
Bhutan
Bolivia
Bosnia and Herzegovina
Botswana
Bouvet Island
Brazil
British Indian Ocean Territory
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Canada
Cape Verde
Cayman Islands
Central African Republic
Chad
Chile
China
Christmas Island
Cocos (Keeling) Islands
Colombia
Comoros
Congo
Congo (the Democratic Republic of the Congo)
Cook Islands
Costa Rica
Côte d'Ivoire
Croatia
Cuba
Cyprus
Czech Republic
Denmark
Djibouti
Dominica
Dominican Republic
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Ethiopia
Falkland Islands [Malvinas]
Faroe Islands
Fiji
Finland
France
French Guiana
French Polynesia
French Southern Territories
Gabon
Gambia
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guernsey
Guinea
Guinea-Bissau
Guyana
Haiti
Heard Island and McDonald Islands
Holy See [Vatican City State]
Honduras
Hong Kong
Hungary
Iceland
India
Indonesia
Iran (the Islamic Republic of Iran)
Iraq
Ireland
Isle of Man
Israel
Italy
Jamaica
Japan
Jersey
Jordan
Kazakhstan
Kenya
Kiribati
Korea (the Democratic People's Republic of Korea)
Korea (the Republic of Korea)
Kuwait
Kyrgyzstan
Lao People's Democratic Republic
Latvia
Lebanon
Lesotho
Liberia
Libyan Arab Jamahiriya
Liechtenstein
Lithuania
Luxembourg
Macao
Macedonia (the former Yugoslav Republic of Macedonia)
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mayotte
Mexico
Micronesia (the Federated States of Micronesia)
Moldova (the Republic of Moldova)
Monaco
Mongolia
Montenegro
Montserrat
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands
Netherlands Antilles
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
Northern Mariana Islands
Norway
Oman
Pakistan
Palau
Palestinian Territory
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn
Poland
Portugal
Puerto Rico
Qatar
Réunion
Romania
Russian Federation
Rwanda
Saint Helena
Saint Kitts and Nevis
Saint Lucia
Saint Pierre and Miquelon
Saint Vincent and the Grenadines
Samoa
San Marino
Sao Tome and Principe
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Singapore
Slovakia
Slovenia
Solomon Islands
Somalia
South Africa
South Georgia and the South Sandwich Islands
Spain
Sri Lanka
Sudan
Suriname
Svalbard and Jan Mayen
Swaziland
Sweden
Switzerland
Syrian Arab Republic
Taiwan (Province of China)
Tajikistan
Tanzania,United Republic of
Thailand
Timor-Leste
Togo
Tokelau
Tonga
Trinidad and Tobago
Tunisia
Turkey
Turkmenistan
Turks and Caicos Islands
Tuvalu
Uganda
Ukraine
United Arab Emirates
United Kingdom
United States
United States Minor Outlying Islands
Uruguay
Uzbekistan
Vanuatu
Venezuela
Viet Nam
Virgin Islands (British)
Virgin Islands (U.S.)
Wallis and Futuna
Western Sahara
Yemen
Zambia
Zimbabwe

Creating Client


import asyncio
from petkit_api import PetKitClient
from aiohttp import ClientSession

async def main():
    async with ClientSession() as session:

        # Create a client using PetKit account email, password, and region
        client = PetKitClient('email', 'password', session, 'United States')


        ###################################################################################
        Examples within the examples section utilize the PetKitClient instance created above
        ###################################################################################



loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Examples

Retrieving all PetKit devices on account

# See model.py for details regarding Data Classes created

devices = await client.get_petkit_data()

Manual Feeding

# See model.py for details regarding "Feeder" class


# Reusing retrieved devices from above. Note: A valid amount (in grams) will depend on the capabilities of the feeder.
await client.manual_feeding(feeder=devices.feeders[feederid], amount=10)

Change Feeder Setting

# See constants.py FeederSetting class for available settings
# Additional import needed:
from petkit_api.constants import FeederSetting


# Enabling child lock on a D4 feeder. Note: Mini Feeders use a different setting.
# Reusing retrieved devices from above.
await client.update_feeder_settings(feeder=devices.feeders[feederid], setting=FeederSetting.CHILD_LOCK, value=1)

Reset Feeder Desiccant

# Reusing retrieved devices from above.
await client.reset_feeder_desiccant(feeder=devices.feeders[feederid])

Control Water Fountain via BLE Relay

# A valid relay (set up through the PetKit app) is required in order to send commands to the Eversweet 3 Pro
# See constants.py W5Command class for available commands
# Additional import needed:
from petkit_api.constants import FountainCommand

# Set Water Fountain to Smart Mode. Reusing retrieved devices from above.
await client.control_water_fountain(water_fountain=devices.water_fountains[water_fountain_id],
                                    command=FountainCommand.SMART)

Project details


Download files

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

Source Distribution

petkit_api-0.1.6.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

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

petkit_api-0.1.6-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file petkit_api-0.1.6.tar.gz.

File metadata

  • Download URL: petkit_api-0.1.6.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for petkit_api-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c6eaf1fc55b823a1f5574bd76e652957a09652200127aafc9e6a37e776f03e33
MD5 7f3854e187dfa259d7f27d7d79ce111d
BLAKE2b-256 f3582445c317b055cb1eb24af09176c101c19096c6537e50d64f1019f007869f

See more details on using hashes here.

Provenance

The following attestation bundles were made for petkit_api-0.1.6.tar.gz:

Publisher: publish.yml on Jezza34000/petkit-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file petkit_api-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: petkit_api-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for petkit_api-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 856cd149a04193f408726a248def12b078f3fda0856aa9d9df56de01ba7bce88
MD5 46166cd87266730926ef8ac500af6661
BLAKE2b-256 5220fc51be8a80529199459e1f212bdc604b1dff0b605fbd9c26a6d25cf71fb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for petkit_api-0.1.6-py3-none-any.whl:

Publisher: publish.yml on Jezza34000/petkit-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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