Home
Softono

Lemmy Client Rs

Open source Rust
27
Stars
4
Forks
3
Issues
4
Watchers
2 months
Last Commit

 About Lemmy Client Rs

Rust client for Lemmy

Platforms

Web Self-hosted

Languages

Rust

Need Help Installing Lemmy Client Rs?

We provide expert installation service for this software. Our team will install, configure, and secure Lemmy Client Rs on your server. plans start at just $30.

Lemmy Client Rs

View on GitHub

Crates.io Version GitHub tag (latest SemVer) Build Status GitHub issues License GitHub stars

Lemmy logo

lemmy-client

A Rust HTTP client for Lemmy. Uses the browser's built-in fetch API when targeting WASM to keep the binary size small.

Usage

In your Cargo.toml:

[dependencies]
lemmy_client = "X.X.X"

An example:

use lemmy_client::{LemmyClient, ClientOptions};
use lemmy_api_common::account::auth::Login;

async fn get_site_test() {
  let mut client = LemmyClient::new(ClientOptions {
    domain: "lemmy.ml",
    secure: true
  });

  let res = client.get_site().await;
  assert!(res.is_ok());

  // Login
  let login = Login {
    username_or_email: "user".to_string().into(),
    password: "password".to_string().into(),
    stay_logged_in: None,
    totp_2fa_token: None,
  };
  let jwt = client.login(login).await?.jwt;
  if let Some(jwt) = jwt {
    client.set_jwt(&jwt.into_inner());
  };
}