discourse-api-rs

Crates.iodiscourse-api-rs
lib.rsdiscourse-api-rs
version20260125.0.0
created_at2026-01-25 18:28:07.565248+00
updated_at2026-01-25 18:28:07.565248+00
descriptionRust client for the Discourse API
homepage
repositoryhttps://github.com/ducks/discourse-api-rs
max_upload_size
id2069248
size81,685
(ducks)

documentation

README

discourse-api

Rust client library for the Discourse API.

Features

  • Fetch latest topics
  • Get categories
  • Get topic details with posts
  • Get individual posts
  • Filter topics by category
  • Async/await support with tokio
  • Optional authentication with API keys

Installation

[dependencies]
discourse-api = "0.20251116"

Usage

Basic (unauthenticated)

use discourse_api::DiscourseClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = DiscourseClient::new("https://meta.discourse.org");

    let topics = client.get_latest().await?;

    for topic in topics.topics {
        println!("{}", topic.title);
    }

    Ok(())
}

With API Authentication

let client = DiscourseClient::with_api_key(
    "https://your-forum.com",
    "your-api-key",
    "your-username"
);

let topics = client.get_latest().await?;

Examples

Run the example:

cargo run --example fetch_latest

API Endpoints

  • get_latest() - Get latest topics
  • get_categories() - Get all categories
  • get_topic(id) - Get topic with posts
  • get_post(id) - Get individual post
  • get_category_topics(category_id) - Get topics in category

License

MIT

Commit count: 63

cargo fmt