Crate readwise[−][src]
Rust wrapper for the Readwise public API. The official readwise public API documentation can be found here. This wrapper supports retrieving Book information and CRUD for Highlights.
Installation
Simply add readwise = "0.1.0"
to your Cargo.toml
Example
use readwise::auth; extern crate dotenv; use dotenv::dotenv; use std::{collections::HashMap, env}; fn main() -> Result<(), anyhow::Error> { dotenv().ok(); let client = auth(&env::var("ACCESS_TOKEN").unwrap()).unwrap(); // Fetch all books on page 1 for book in client.books(1).unwrap() { println!("{}", book.title); } // Fetch all highlights on page 1 for highlight in client.highlights(1).unwrap() { println!("{}", highlight.id); } // Create highlight(s) let mut highlights = Vec::new(); let mut highlight = HashMap::new(); highlight.insert("text", "hello world!"); highlights.push(highlight); let result = client.create(highlights)?; for highlight in result { println!("{}", highlight.text); } // Update a highlight by ID let mut fields = HashMap::new(); fields.insert("text", "hello, world!"); let _result = client.update(138105649, fields)?; // Delete a highlight by ID client.delete(136887156)?; Ok(()) }
Structs
Book | An individual book |
Client | The authenticated client instance. The access_token can be obtained through Readwise. |
Highlight | An individual highlight |
Functions
auth | Authenticate client using a readwise access token |