mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2025-01-24 02:45:54 +00:00
A javascript / typescript http and websocket client and type system for Lemmy.
Nutomic
646b95907b
* Adding list reports. * 0.20.0-reports-combined.0 * Fix comment. * Use internal tagging. * 0.20.0-reports-combined.1 * 0.20.0-reports-combined.2 * 0.20.0-reports-combined.3 * Rework image api * fix * 0.20.0-image-api-rework.0 * rename * 0.20.0-image-api-rework.2 * rename params * 0.20.0-image-api-rework.3 * fix null * fix upload urls * 0.20.0-image-api-rework.4 * build full url * 0.20.0-image-api-rework.5 * remaining upload endpoints * 0.20.0-image-api-rework.6 * 0.20.0-image-api-rework.7 * Update dependency @types/node to v22.10.5 (#438) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update typescript-eslint monorepo to v8.19.0 (#439) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * add missing endpoints including delete * 0.20.0-image-api-rework.8 --------- Co-authored-by: Dessalines <tyhou13@gmx.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> |
||
---|---|---|
.github | ||
.husky | ||
src | ||
.gitignore | ||
.prettierrc.json | ||
.woodpecker.yml | ||
CHANGELOG.md | ||
cliff.toml | ||
copy_generated_types_from_lemmy.sh | ||
deploy.sh | ||
eslint.config.mjs | ||
generate_changelog.sh | ||
LICENSE | ||
package.json | ||
pnpm-lock.yaml | ||
putTypesInIndex.js | ||
README.md | ||
renovate.json | ||
tsconfig.json |
lemmy-js-client
A javascript / typescript http client and type system for Lemmy.
Installation
pnpm install lemmy-js-client
Usage
HTTP Client
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