mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-12-14 23:11:26 +00:00
A javascript / typescript http and websocket client and type system for Lemmy.
Nutomic
792bed9a01
* Instance blocks with mod log entry and expiration * 0.20.0-instance-blocks.0 * fix methods * 0.20.0-instance-blocks.1 * remove params * 0.20.0-instance-blocks.2 * pass domain * 0.20.0-instance-blocks.3 * add file * 0.20.0-instance-blocks.4 * pass instance domain * 0.20.0-instance-blocks.5 * Changes for api v4 * 0.20.0-api-v4.0 * 0.20.0-api-v4.1 * remove param * 0.20.0-api-v4.2 * remove GetSiteResponse.my_user * 0.20.0-api-v4.3 * 0.20.0-api-v4.4 * fix path * 0.20.0-api-v4.5 * fix path * 0.20.0-api-v4.6 * 0.20.0-api-v4.7 * 0.20.0-api-v4.8 * move block endpoints * 0.20.0-api-v4.9 * fix path * 0.20.0-api-v4.10 * fix * 0.20.0-api-v4.11 * change /admin/block_instance to /admin/instance/block (and same for allow) * 0.20.0-api-v4.12 * fix mark all read * 0.20.0-api-v4.13 * fix user endpoints * 0.20.0-api-v4.14 * add MarkManyPostsAsRead * change account route * 0.20.0-api-v4.15 * rename mention mark as read * 0.20.0-api-v4.16 --------- Co-authored-by: Dessalines <tyhou13@gmx.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