Skip to content

Commit 3d8c8ef

Browse files
committed
ADD: api endpoints founds
1 parent f716f67 commit 3d8c8ef

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/kindle/api.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# found api endpoints
2+
# have to find out more
3+
4+
15
import json
26
from datetime import datetime
37

@@ -41,3 +45,73 @@ def get_manifest(auth, asin: str):
4145
return r.json()
4246

4347

48+
def whispersync(auth):
49+
user_id = auth.customer_info["user_id"]
50+
url = f"https://api.amazon.com/whispersync/v2/data/{user_id}/datasets"
51+
params1 = {
52+
"embed": "records.first_page",
53+
"quiet": "true"
54+
}
55+
# alternative params in other requests found
56+
params2 = {
57+
"filterDeletedUpto": 201,
58+
"embed": "records.first_page",
59+
"filterDeleted": "true",
60+
"after": 188
61+
}
62+
params3 = {
63+
"after": 201,
64+
"quiet": "true"
65+
}
66+
with httpx.Client(auth=auth) as session:
67+
r = session.get(url, params=params1)
68+
return r.json()
69+
70+
71+
def whispersync_records_by_identifier(auth, identifier: str):
72+
user_id = auth.customer_info["user_id"]
73+
url = f"https://api.amazon.com/whispersync/v2/data/{user_id}/datasets/{identifier}/records"
74+
params = {
75+
"after": 201
76+
}
77+
with httpx.Client(auth=auth) as session:
78+
r = session.get(url, params=params)
79+
return r.json()
80+
81+
82+
def sidecar(auth, asin: str):
83+
url = f"https://sars.amazon.com/sidecar/sa/EBOK/{asin}"
84+
with httpx.Client(auth=auth) as session:
85+
r = session.get(url)
86+
return r.json()
87+
88+
89+
def get_news(auth):
90+
url = "https://sars.amazon.com/kinapps/notifications/new"
91+
with httpx.Client(auth=auth) as session:
92+
r = session.get(url)
93+
return r.json()
94+
95+
96+
def get_notification_channels(auth, marketplace: str):
97+
# marketplace e.g. A1PA6795UKMFR9
98+
url = f"https://d3ohh9b4v3oawh.cloudfront.net/iOS/1.1/{marketplace}/notificationsChannels.json"
99+
with httpx.Client(auth=auth) as session:
100+
r = session.get(url)
101+
return r.json()
102+
103+
104+
def get_device_credentials(auth):
105+
# gives same credential types like a device registration
106+
# value are different, but why?
107+
# credentials from device registration are still valid
108+
# gives cookies for more amazon domains
109+
url = "https://firs-ta-g7g.amazon.com/FirsProxy/getDeviceCredentials"
110+
params = {
111+
"softwareVersion": "1184366692"
112+
}
113+
with httpx.Client(auth=auth) as session:
114+
r = session.get(url, params=params)
115+
cred = xmltodict.parse(r.text)
116+
cred = json.loads(json.dumps(cred))
117+
return cred.get("response", cred)

0 commit comments

Comments
 (0)