readwise

Crates.ioreadwise
lib.rsreadwise
version0.4.0
sourcesrc
created_at2021-02-07 21:23:54.413544
updated_at2022-10-13 15:07:11.316018
descriptionA rust wrapper for the Readwise API.
homepagehttps://github.com/terror/readwise
repositoryhttps://github.com/terror/readwise
max_upload_size
id352079
size27,083
liam (terror)

documentation

https://docs.rs/readwise

README

Readwise

A rust wrapper for the Readwise API.

Installation

Simply add readwise to your Cargo.toml file:

readwise = "0.4.0"

Example

Here is a small example showcasing the main functionality of the library.

use {
  dotenv::dotenv,
  readwise::client::Client,
  std::{collections::HashMap, env},
};

fn main() {
  dotenv().ok();

  let client = Client::new(&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 new_highlight = HashMap::new();
  new_highlight.insert("text", "hello world!");

  for highlight in client.create_highlights(vec![new_highlight]).unwrap() {
    println!("{}", highlight.text);
  }

  // Update a highlight by ID
  let mut fields = HashMap::new();
  fields.insert("text", "hello, world!");
  client.update_highlight(138105649, fields).unwrap();

  // Delete a highlight by ID
  client.delete_highlight(136887156).unwrap();
}
Commit count: 20

cargo fmt