#api-wrapper #async #stories #wattpad-api #fanfiction #wattpad-rs

wattpad

Unofficial async Rust wrapper around the (various) Wattpad API(s)

12 releases

0.3.2 Sep 27, 2023
0.3.1 Apr 22, 2023
0.3.0 Mar 26, 2023
0.2.5 Mar 17, 2023
0.1.2 Mar 5, 2023

#1913 in Web programming

Download history 2/week @ 2024-02-24 2/week @ 2024-03-09 4/week @ 2024-03-16 40/week @ 2024-03-30 1/week @ 2024-04-06 106/week @ 2024-04-20

147 downloads per month

BSD-3-Clause

29KB
602 lines

wattpad-rs

Unofficial async Rust wrapper around the (various) Wattpad API(s)

Documentation

See docs.rs

Examples

Stories:

use wattpad::Wattpad;

#[tokio::main]
async fn main() {
    let watt = Wattpad::new()
    .await
    .unwrap();
    let story = watt
        .get_story("336149308")
        .await
    .unwrap();

    println!("{}", story.title)
}

Searches:

use wattpad::{SearchSort, SearchType, Wattpad};

#[tokio::main]
async fn main() {
    let watt = Wattpad::new()
    .await
    .unwrap();

    // Text searches
    let text_search = watt
        .search(
            "bendy x reader",
            SearchType::Text,
            SearchSort::Hot,
            30,
        )
        .await
        .unwrap();

    let text_results = text_search.page(0).await.unwrap();

    println!("{}", text_results[0].title)


    // Tag searches
    let tag_search = watt
        .search(
            "bendyxreader,batim",
            SearchType::Text,
            SearchSort::Hot,
            30,
        )
        .await
        .unwrap();

    let tag_results = tag_search.page(0).await.unwrap();

    println!("{}", tag_results[0].title)
}

Dependencies

~6–22MB
~314K SLoC