9 stable releases (3 major)

3.0.0 Aug 26, 2022
2.1.1 Jun 14, 2021
1.2.0 Jun 3, 2021
1.1.1 May 27, 2021
0.1.0 May 24, 2021

#2261 in Web programming

GPL-3.0 license

44KB
827 lines

dot4ch

Rust

dot4ch is a convenient wrapper library around 4chan's API.

This library can fetch and update:

  • Posts (fetch only)
  • Threads
  • Boards
  • Catalogs

While respecting 4chan's:

  • GET 1 second-per-request cooldown.
  • If-Modified-Since headers with update requests.
  • 10 second cooldown with Thread, Catalog and Board update requests.

Getting Started

THE DOCS

There are plenlty of examples in the examples directory to get you started plus the I believe everything in the crate is documented.

You can run any example with

cargo run --example <example name>

lib.rs:

dot4ch

dot4ch is a convenient wrapper library around 4chan's API.

This library can fetch and update:

  • Posts
  • Threads
  • Catalog
  • Boards

While respecting 4chan's:

Example: Getting an image from the OP of a thread

#[tokio::main]
async fn main() {
    use dot4ch::{Client, thread::Thread};
    
    // Making a client.
    let mut client = Client::new();
    
    // Building a board.
    let board = "g";

    // Getting a specific `Thread` from the board.
    let post_id = 76759434;

    // Fetching a new thread.
    let thread = Thread::new(&client, board, post_id).await.unwrap();
    
    // Getting the OP of the thread.
    let post = thread.op();
    println!("{}", post.image_url(board).unwrap());
}

Dependencies

~6–22MB
~293K SLoC