There's this: https://developer.apple.com/documentation/photokit ("The framework provides access to photos on the person’s device and in iCloud.")
If you want to use undocumented APIs on non-Apple devices directly, there are projects like https://github.com/steilerDev/icloud-photos-sync and https://github.com/icloud-photos-downloader/icloud_photos_do... that appear to be able to do this.
Google Photos, by comparison, has a REST API.
Google Photos, by comparison, has a REST API.