Last active
February 23, 2023 23:48
-
-
Save alexbowe/22275a42596a8eacb6ccd318a684915f to your computer and use it in GitHub Desktop.
Get Readwise Highlights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
READWISE_API_KEY = "" # Go to readwise.io/access_token | |
def get_readwise_data(): | |
next_page = None | |
while True: | |
# See https://readwise.io/api_deets for more info | |
response = requests.get( | |
url="https://readwise.io/api/v2/export/", | |
params={"pageCursor": next_page}, | |
headers={"Authorization": f"Token {READWISE_API_KEY}"}) | |
yield from response.json()["results"] | |
next_page = response.json().get("nextPageCursor") | |
if not next_page: break | |
print([*get_readwise_data()]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment