A javascript / typescript http and websocket client and type system for Lemmy.
Find a file
renovate[bot] 878fd54779
Update dependency @types/node to v22.9.0 (#396)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-08 20:24:38 -05:00
.github
.husky
src Private community (#371) 2024-11-07 12:19:30 -05:00
.gitignore
.prettierrc.json
.woodpecker.yml
CHANGELOG.md Updating git cliff. (#361) 2024-09-27 20:24:25 +00:00
cliff.toml Updating git cliff. (#361) 2024-09-27 20:24:25 +00:00
copy_generated_types_from_lemmy.sh Upgrading to use ts-rs 10.0.0 (#394) 2024-11-07 12:07:49 -05:00
deploy.sh
eslint.config.mjs
generate_changelog.sh
LICENSE
package.json 0.20.0-alpha.18 2024-11-07 12:21:34 -05:00
pnpm-lock.yaml Update dependency @types/node to v22.9.0 (#396) 2024-11-08 20:24:38 -05:00
putTypesInIndex.js Update types 3 (#359) 2024-09-30 08:14:59 -04:00
README.md
renovate.json Running renovate every weekend. (#365) 2024-09-30 22:13:26 -04:00
tsconfig.json

GitHub tag (latest SemVer) GitHub issues License GitHub stars

lemmy-js-client

A javascript / typescript http client and type system for Lemmy.

Installation

pnpm install lemmy-js-client

Usage

HTTP Client

LemmyHttp docs

import { LemmyHttp, Login } from "lemmy-js-client";

// Build the client
const baseUrl = "https://lemmy.ml";
const client: LemmyHttp = new LemmyHttp(baseUrl);

// Build the login form
const loginForm: Login = {
  username_or_email: "my_name",
  password: "my_pass",
};

// Login and set the client headers with your jwt
const { jwt } = await client.login(loginForm);
client.setHeaders({ Authorization: `Bearer ${jwt}` });

// Fetch top posts for the day
const getPostsForm: GetPosts = {
  sort: "TopDay",
  type_: "Local",
};
const posts = await client.getPosts(getPostsForm);

Development

Use pnpm add to develop and test changes locally:

pnpm add path/to/lemmy-js-client