3 stable releases

new 4.0.2 Dec 15, 2024
4.0.1 Nov 26, 2024
3.0.0 Aug 26, 2022
2.1.1 Jun 14, 2021
0.1.0 May 24, 2021

#792 in Web programming

Download history 28/week @ 2024-09-23 277/week @ 2024-11-25 84/week @ 2024-12-09

361 downloads per month

GPL-3.0 license

59KB
1K SLoC

dot4ch

dot4ch is a convenient wrapper library around an imageboard's API.

This library can fetch and update:

  • Threads
  • Boards
  • Catalogs

While respecting:

  • GET 1 second-per-request cooldown.
  • If-Modified-Since headers with update requests.
  • 10 seconds per thread update rate limits.

Getting Started

Examples can be found in the examples directory.

You can run any example with

cargo run --example <example name>

MSRV

Rust MSRV: 1.70.1 Edition: 2021


lib.rs:

dot4ch

dot4ch is a convenient wrapper library around an imageboard's read-only API.

This library can fetch and update:

While respecting:

  • 1 second-per-request rate-limits.
  • If-Modified-Since headers with update requests.
  • 10 seconds per thread update rate limits.

Example: Printing the comment from a thread.

use dot4ch::thread::Post;
use dot4ch::thread::Thread;
use dot4ch::Client;

#[tokio::main]
async fn main() -> Result<()> {
    let client = Client::new();
    let mut thread = Thread::new(&client, "po", 570368).await?;

    // update thread
    thread.update(&client).await?;

    // print thread's OP comment
    let comment = thread.first().and_then(Post::com).unwrap();
    let comment = comment.replace("<br>", "\n"); // replace line breaks
    println!("op says: {comment}");
    Ok(())
}

Dependencies

~6–17MB
~226K SLoC