-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use better pagination (and implement progress bar) #1
Comments
Prototype code: offset = 0
fetched = []
size = 500
while True:
page = requests.get("https://getpocket.com/v3/get", {
"consumer_key": consumer_key,
"access_token": access_token,
"sort": "oldest",
"detailType": "complete",
"count": size,
"offset": offset,
}).json()
print(offset)
fetched.append(page)
offset += size
if not len(page["list"]):
break |
For a progress bar I need to know how many total items there are. I found an undocumented API for this! {
"count_list": 7394,
"count_read": 1016,
"count_unread": 6378,
"status": 1
} I guessed this based on the documented v2 API: https://getpocket.com/api/v2_docs/#stats |
I keep getting 503 errors even though I appear to be staying within the rate limit:
I'm going to try doing a few automatic retries any time I see a 503 error. |
Or maybe it was because of the current Google Cloud outage? https://news.ycombinator.com/item?id=22706677 |
Right now we attempt to load everything at once - which caps out at 5,000 items and is really slow.
We can do better by implementing pagination using count and offset.
The text was updated successfully, but these errors were encountered: