instapaper

Crates.ioinstapaper
lib.rsinstapaper
version0.1.2
sourcesrc
created_at2018-11-05 08:25:54.778147
updated_at2021-04-02 12:10:18.625088
descriptionInstapaper API wrapper.
homepagehttps://github.com/sirupsen/instapaper-rs
repositoryhttps://github.com/sirupsen/instapaper-rs
max_upload_size
id94788
size17,825
Simon Eskildsen (sirupsen)

documentation

https://github.com/sirupsen/instapaper-rs

README

instapaper

Rust wrapper for the Instapaper public API. The official API's documentation can be found here. Note that in order to receive a consumer key and secret to access the API you must fill out this form. See the Client struct for all methods made available.

Rustdocs

Installation

Add instapaper = "*" to your Cargo.toml.

Example

extern crate dotenv;

use dotenv::dotenv;
use std::env;

dotenv().ok();

for (key, value) in env::vars() {
  println!("{}: {}", key, value);
}

// Instapaper uses the archaic Oauth1 which requires the username and password in order to
// receive an oauth token required for further operations.
let client = instapaper::authenticate(
    &env::var("INSTAPAPER_USERNAME").unwrap(),
    &env::var("INSTAPAPER_PASSWORD").unwrap(),
    &env::var("INSTAPAPER_CONSUMER_KEY").unwrap(),
    &env::var("INSTAPAPER_CONSUMER_SECRET").unwrap(),
).expect("failed to authenticate");

// Now the `oauth_key` and `oauth_secret` on `instapaper::Client` has been set to make it valid
// for API actions
client.add("https://sirupsen.com/read", "How I Read", "").unwrap();
println!("{:?}", client.bookmarks().unwrap());

println!("Client {{");
println!("  consumer_key: {}", client.consumer_key);
println!("  consumer_secret: {}", client.consumer_secret);
println!("  oauth_key: {}", client.oauth_key.as_ref().unwrap());
println!("  oauth_secret: {}", client.oauth_secret.as_ref().unwrap());
println!("}}");

// You can save the Oauth authentication details to e.g. an enviroment file or wherever you
// store secrets and discard the username and password.
let client2 = instapaper::Client {
    consumer_key: env::var("INSTAPAPER_CONSUMER_KEY").unwrap().to_owned(),
    consumer_secret: env::var("INSTAPAPER_CONSUMER_SECRET").unwrap().to_owned(),
    oauth_key: client.oauth_key,
    oauth_secret: client.oauth_secret,
};

println!("{:?}", client2.bookmarks().unwrap());

License: MIT

Commit count: 7

cargo fmt