The recently_deleted iCloud album?

How do I clear the photos from the recently deleted iCloud album? I tried several libraries without success. Recently Deleted is essentially a photo recovery site. I am a newbie. Please help me.

import logging
from icloudpy import ICloudPyService
import requests

# 配置日志记录

# iCloud 帐户信息
apple_id = "secret"
password = "secret"

# 创建 iCloud 服务实例"正在创建 iCloud 服务实例...")
api = ICloudPyService(apple_id, password)

# 获取所有相册"正在获取所有相册...")
albums =
for album_name, album in albums.items():"找到相册: {album_name}")

# 获取“Recently Deleted”相册
recently_deleted_album = albums['Recently Deleted']

# 获取会话令牌
session_token = None
for cookie in api.session.cookies:
        session_token = cookie.value

if not session_token:
    client_id = api.session.client_id if hasattr(api.session, 'client_id') else "client_id_placeholder"
    service_endpoint = ""  # 请根据需要修改此值

    # 删除“Recently Deleted”相册中的所有照片"开始从 'Recently Deleted' 相册中彻底删除所有照片...")
    for photo in recently_deleted_album:
  "正在删除照片: {photo.filename}")
            delete_url = f"https://{service_endpoint}/database/1/"
            payload = {
                "clientId": client_id,
                "command": {
                    "operation": "delete",
                    "ids": []
            headers = {
                'Authorization': f'Bearer {session_token}',
                'Content-Type': 'application/json'
            response =, json=payload, headers=headers)
  "照片 {photo.filename} 已删除")
        except Exception as e:
            logging.error(f"删除照片时出错: {e}")"照片删除完毕。")

You should probably redact your iCloud password, and then go change it real quick.

I’ve hidden the username and password. Regardless, you should assume they are no longer secure and change your password immediately.

This is just a test account, it’s okay