A Python library for Eufy Security cameras and devices
Project description
pyeufysecurity
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
- Check for open features/bugs or initiate a discussion on one.
- Fork the repository.
- Install the dev environment:
pip install -e . && pip install pytest pytest-cov pytest-asyncio ruff mypy - Code your new feature or bug fix.
- Write a test that covers your new functionality.
- Update
README.mdwith any new documentation. - Run tests:
pytest tests/ -v - Ensure you have no linting errors:
ruff check . - Ensure you have typed your code correctly:
mypy eufy_security - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ba7d64f8295de10a0cd029595f1a5c9346e4ecdf2492028044d5cb36b1b4d1d
|
|
| MD5 |
bd87b4e044074def49c95b9a21a0138c
|
|
| BLAKE2b-256 |
ec30253ec25125a46774650b62c8fee0262e691f0b82fecf5c33e19618bb8545
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fef8883a0951ce08299b9ff847a2e24338f78af8d24e91dddac789c3d7e3a489
|
|
| MD5 |
e14203661e88900e6a05f45e5db53e12
|
|
| BLAKE2b-256 |
1a114fc9368a6da28a5b68bc4f4450a039ca90f6718dc6c7b88ab5dcae9187fc
|