Skip to main content

Amazon Photos API

Project description

Amazon Photos API

Table of Contents

Installation

pip install amazon-photos

Setup

These environment variables must be set. They correspond to cookies found in the browser when logged into Amazon Photos.

export SESSION_ID="..."
export UBID_ACDCA="..."
export AT_ACBCA="..."

Query Syntax

For valid location and people IDs, see the results from the aggregations() method.

Example query:

drive/v1/search

type:(PHOTOS OR VIDEOS)
AND things:(plant AND beach OR moon)
AND timeYear:(2019)
AND timeMonth:(7)
AND timeDay:(1)
AND location:(CAN#BC#Vancouver)
AND people:(CyChdySYdfj7DHsjdSHdy)

/drive/v1/nodes

kind:(FILE* OR FOLDER*)
AND contentProperties.contentType:(image* OR video*)
AND status:(AVAILABLE*)
AND settings.hidden:false
AND favorite:(true)

Examples

from pathlib import Path
from amazon_photos import AmazonPhotos

ap = AmazonPhotos()

# get entire Amazon Photos library. (default save to `ap.parquet`)
nodes = ap.query("type:(PHOTOS OR VIDEOS)")

# query Amazon Photos library with more filters applied. (default save to `ap.parquet`)
nodes = ap.query("type:(PHOTOS OR VIDEOS) AND things:(plant AND beach OR moon) AND timeYear:(2023) AND timeMonth:(8) AND timeDay:(14) AND location:(CAN#BC#Vancouver)")

# sample first 10 nodes
node_ids = nodes.id[:10]

# move a batch of images/videos to the trash bin
ap.trash(node_ids)

# restore a batch of images/videos from the trash bin
ap.restore(node_ids)

# upload a batch of images/videos
files = Path('path/to/files').iterdir()
ap.upload(files)

# download a batch of images/videos
ap.download(node_ids)

# permanently delete a batch of images/videos.
ap.delete(node_ids)

# convenience method to get all photos
ap.photos()

# convenience method to get all videos
ap.videos()

# get current usage stats
ap.usage()

# get all identifiers calculated by Amazon.
ap.aggregations(category="all")

# get specific identifiers calculated by Amazon.
ap.aggregations(category="location")

# get trash bin contents
ap.trashed()

Common Paramters

name type description
ContentType str "JSON"
_ int 1690059771064
asset str "ALL"
"MOBILE"
"NONE
"DESKTOP"

default: "ALL"
filters str "type:(PHOTOS OR VIDEOS) AND things:(plant AND beach OR moon) AND timeYear:(2019) AND timeMonth:(7) AND location:(CAN#BC#Vancouver) AND people:(CyChdySYdfj7DHsjdSHdy)"

default: "type:(PHOTOS OR VIDEOS)"
groupByForTime str "day"
"month"
"year"
limit int 200
lowResThumbnail str "true"
"false"

default: "true"
resourceVersion str "V2"
searchContext str "customer"
"all"
"unknown"
"family"
"groups"

default: "customer"
sort str "['contentProperties.contentDate DESC']"
"['contentProperties.contentDate ASC']"
"['createdDate DESC']"
"['createdDate ASC']"
"['name DESC']"
"['name ASC']"

default: "['contentProperties.contentDate DESC']"
tempLink str "false"
"true"

default: "false"

Notes

https://www.amazon.ca/drive/v1/batchLink

  • This endpoint is called when downloading a batch of photos/videos in the web interface. It then returns a URL to download a zip file, then makes a request to that url to download the content. When making a request to download data for 1200 nodes (max batch size), it turns out to be much slower (~2.5 minutes) than asynchronously downloading 1200 photos/videos individually (~1 minute).

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amazon-photos-0.0.14.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

amazon_photos-0.0.14-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file amazon-photos-0.0.14.tar.gz.

File metadata

  • Download URL: amazon-photos-0.0.14.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for amazon-photos-0.0.14.tar.gz
Algorithm Hash digest
SHA256 cd76168172965139bd0ef01f5ae94ec5bf65f76b47b0b1652c2d6ab254209a01
MD5 9f5efc080d5be78f09647fdfd8661e01
BLAKE2b-256 c0a0641aa456e4fd4fd7beb08a0a44c110c42f9b5d77cb00baebc2d4ee216b85

See more details on using hashes here.

File details

Details for the file amazon_photos-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: amazon_photos-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for amazon_photos-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 c52894751730e52f9f01ee7e9e382ec357ba5d81aa4dd613b52c6319b7697192
MD5 1bc6bdeacf3b39ae8528e0a538ff0382
BLAKE2b-256 b93e45eee8eaa8a1d1b62852c1e7d5977bb2bb4cc3968528409b95d4ff56d7e6

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