Discover a seamless way to integrate Readwise with Supernotes, even though it’s not official integration (yet!). Leverage the power of APIs and Pipedream to create a workflow that automates note-taking.
Get started by using two consecutive Python steps to retrieve book information and format the note.After a new highlight is triggered in Readwise, compose your card by gathering additional data in two consecutive Python steps for the card’s markup, first making a call to the Readwise API to retrieve some information on the book, which contains the book or website and the author, using the following code:
Copy
import requestsdef handler(pd: "pipedream"): # Prepare inputs readwise_auth = pd.inputs["readwise"]["$auth"]["access_token"] highlight = pd.steps["trigger"]["event"] # Request data from Readwise API result = requests.get( f'https://readwise.io/api/v2/books/{highlight["book_id"]}', headers={"Authorization": f'Token {readwise_auth}'} ) # Export data for use in future steps return result.json()
Then prepare some pre-formatted strings
Copy
import tldimport reimport dateutil.parser as pdef get_domain_base(url): dom = "" try: res = tld.get_tld(url, as_object=True) dom = f'{res.domain}.{res.tld}' except: dom = url return domdef get_indented_text(text): prefix = "> " return re.sub("\n", f"\n{prefix}", re.sub("^", prefix, text))def get_date(timestamp, date_format): d = p.parse(timestamp) return d.strftime(date_format)def handler(pd: "pipedream"): # Set constants date_format = "%d.%m.%Y" # Prepare inputs book = pd.steps["book"]["$return_value"] highlight = pd.steps["trigger"]["event"] # Get domain base url = book["source_url"] domain_base = get_domain_base(url) # Get indented text text = highlight["text"] indented_text = get_indented_text(text) # Get highlight date book_updated = book["updated"] formatted_date = get_date(book_updated, date_format) # Return data for use in future steps return { "formatted_date": formatted_date, "domain_base": domain_base, "indented_text": indented_text }
Get started with Pipedream and connect Readwise to Supernotes today!