Skip to main content

A Python library for Eufy Security cameras and devices

Project description

pyeufysecurity

CI PyPi Version License

A Python library for Eufy Security cameras and devices.

Based on python-eufy-security by FuzzyMistborn and eufy-security-client by bropat.

Python Versions

The library is currently supported on:

  • Python 3.11
  • Python 3.12
  • Python 3.13

Installation

pip install pyeufysecurity

Account Information

Because of the way the Eufy Security private API works, an email/password combo cannot work with both the Eufy Security mobile app and this library. It is recommended to use the mobile app to create a secondary "guest" account with a separate email address and use it with this library.

Features

  • Async authentication with Eufy Security cloud API using v2 encrypted protocol
  • ECDH key exchange for secure communication
  • CAPTCHA support for login verification
  • Automatic token refresh when expired
  • Automatic domain switching for regional API endpoints
  • Retry on 401 authentication errors
  • Camera listing and management
  • RTSP stream start/stop (local and cloud)
  • Station/hub listing
  • Event history for camera thumbnails

Usage

Everything starts with an aiohttp ClientSession:

import asyncio

from aiohttp import ClientSession

from eufy_security import async_login


async def main() -> None:
    """Create the aiohttp session and run the example."""
    async with ClientSession() as session:
        # Create an API client:
        api = await async_login(EUFY_EMAIL, EUFY_PASSWORD, session)

        # Loop through the cameras associated with the account:
        for camera in api.cameras.values():
            print(f"Camera Name: {camera.name}")
            print(f"Serial Number: {camera.serial}")
            print(f"Station Serial Number: {camera.station_serial}")
            print(f"Last Camera Image URL: {camera.last_camera_image_url}")

            print("Starting RTSP Stream")
            stream_url = await camera.async_start_stream()
            print(f"Stream URL: {stream_url}")

            print("Stopping RTSP Stream")
            await camera.async_stop_stream()


asyncio.run(main())

CAPTCHA Handling

Eufy may require CAPTCHA verification for new logins. Handle CaptchaRequiredError:

from eufy_security import async_login, CaptchaRequiredError

try:
    api = await async_login(email, password, session)
except CaptchaRequiredError as err:
    # err.captcha_image contains a base64-encoded image
    # Prompt user to solve CAPTCHA, then retry:
    api = await async_login(
        email, password, session,
        captcha_id=err.captcha_id,
        captcha_code=user_provided_code,
        api=err.api,  # Reuse API instance for same ECDH keys
    )

Contributing

  1. Check for open features/bugs or initiate a discussion on one.
  2. Fork the repository.
  3. Install the dev environment: pip install -e . && pip install pytest pytest-cov pytest-asyncio ruff mypy
  4. Code your new feature or bug fix.
  5. Write a test that covers your new functionality.
  6. Update README.md with any new documentation.
  7. Run tests: pytest tests/ -v
  8. Ensure you have no linting errors: ruff check .
  9. Ensure you have typed your code correctly: mypy eufy_security
  10. Submit a pull request!

License

MIT License

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

pyeufysecurity-0.4.0.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

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

pyeufysecurity-0.4.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file pyeufysecurity-0.4.0.tar.gz.

File metadata

  • Download URL: pyeufysecurity-0.4.0.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pyeufysecurity-0.4.0.tar.gz
Algorithm Hash digest
SHA256 cb91b00431ac41f298dfc901b529c50ecc68cfe1f72dcce1db23d42bc96f157d
MD5 b5f49a6c9b479264ef866036f358e2e8
BLAKE2b-256 8df1f5a7738f90d03d34d8e678f556ee1be918b51a5d1b069614161a3ccb5b1a

See more details on using hashes here.

File details

Details for the file pyeufysecurity-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pyeufysecurity-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pyeufysecurity-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aeececd61c1a52dfd143267d10af5844dcfc36f2e04d3b9b2f087a7ed7a5e92d
MD5 8472f9c54ffa2395f2977177c27f21ff
BLAKE2b-256 2ce6b9a18e3de01ab66316412cbcde6d5cb92498672beb8bd4c8c5b43c1b2223

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