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.2.tar.gz (37.3 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.2-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyeufysecurity-0.4.2.tar.gz
  • Upload date:
  • Size: 37.3 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.2.tar.gz
Algorithm Hash digest
SHA256 5ba7d64f8295de10a0cd029595f1a5c9346e4ecdf2492028044d5cb36b1b4d1d
MD5 bd87b4e044074def49c95b9a21a0138c
BLAKE2b-256 ec30253ec25125a46774650b62c8fee0262e691f0b82fecf5c33e19618bb8545

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyeufysecurity-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 17.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fef8883a0951ce08299b9ff847a2e24338f78af8d24e91dddac789c3d7e3a489
MD5 e14203661e88900e6a05f45e5db53e12
BLAKE2b-256 1a114fc9368a6da28a5b68bc4f4450a039ca90f6718dc6c7b88ab5dcae9187fc

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