Skip to main content

Built and signed on GitHub Actions

TypeScript client API for Lysand and Mastodon servers.

This package works with Bun, Cloudflare Workers, Node.js, Deno, Browsers
JSR Score
100%
Published
a day ago (0.1.8)

Lysand Logo

@lysand-org/client

TypeScript client API for Lysand and Mastodon servers.

Efficiency

The built output of the package is not even 32 KB in size, making it a lightweight and efficient solution for your Lysand needs. Installing the package adds around 5 MB to your node_modules folder, but this does not affect the final bundle size.

Compilation (bundling/minifying) time is a few seconds, almost all of which is spent on type-checking. The actual compilation time is less than a tenth of a second.

Usage

This application may be used in the same was as megalodon.

Initialize the client with the following code:

import { LysandClient } from "@lysand-org/client";

const baseUrl = new URL("https://social.lysand.org");
const accessToken  = "...";

const client = new LysandClient(baseUrl, accessToken);

The client can then be used to interact with the server:

const { data: status } = await client.postStatus("Hey there!");
const { data: posts } = await client.getHomeTimeline();

Use your editor's IntelliSense to see all available methods and properties. JSDoc comments are always available. Method names are the same as with Megalodon, but with slight parameter changes in some cases.

All methods have a special extra parameter that can be used to pass additional parameters to the underlying HTTP request. This can be used to pass query parameters, headers, etc.:

// extra is a RequestInit, the same as the second parameter of native fetch
const { data: posts } = await client.getHomeTimeline({
    headers: { "User-Agent": "MyApp/3" },
    signal: new AbortSignal(),
});

Getting Started

Prerequisites

For Usage

See the Compatibility section for the supported environments. Any package manager can be used to install the packages.

For Development

  • Bun version 1.1.8 or higher.
  • Either the Linux or macOS operating systems. (Windows will work, but is not officially supported.)

Compatibility

This library is built for JavaScript runtimes with the support for:

Runtimes

  • Node.js: 14.0+ is the minimum, but only Node.js 20.0+ (LTS) is officially supported.
  • Deno: Support is unknown. 1.0+ is expected to work.
  • Bun: Bun 1.1.8 is the minimum-supported version. As Bun is rapidly evolving, this may change. Previous versions may also work.

Browsers

Consequently, this library is compatible without any bundling in the following browser versions:

  • Chrome: 80+
  • Edge: 80+
  • Firefox: 74+
  • Safari: 13.1+
  • Opera: 67+
  • Internet Explorer: None

If you are targeting older browsers, please don't, you are doing yourself a disservice.

Transpilation to non-ES Module environments is not officially supported, but should be simple with the use of a bundler like Parcel or Rollup.

Installation

Package is distributed as a scoped package on the NPM registry and JSR.

We strongly recommend using JSR over NPM for all your packages that are available on it.

# NPM version
deno add npm:@lysand-org/client # For Deno
npm install @lysand-org/client # For NPM
yarn add @lysand-org/client # For Yarn
pnpm add @lysand-org/client # For PNPM
bun add @lysand-org/client # For Bun

# JSR version
deno add @lysand-org/client # For Deno
npx jsr add @lysand-org/client # For JSR
yarn dlx jsr add @lysand-org/client # For Yarn
pnpm dlx jsr add @lysand-org/client # For PNPM
bunx jsr add @lysand-org/client # For Bun

From Source

If you want to install from source, you can clone this repository and run the following commands:

bun install # Install dependencies

bun run build # Build the packages

The built package will be in the client/dist folder.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Projects

  • Bun: Thanks to the Bun team for creating an amazing JavaScript runtime.
  • TypeScript: TypeScript is the backbone of this project.
  • Node.js: Node.js created the idea of JavaScript on the server.

People

  • April John: Creator and maintainer of the Lysand Server ActivityPub bridge.
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @lysand-org/client

Import symbol

import * as mod from "@lysand-org/client";

Add Package

npx jsr add @lysand-org/client

Import symbol

import * as mod from "@lysand-org/client";

Add Package

yarn dlx jsr add @lysand-org/client

Import symbol

import * as mod from "@lysand-org/client";

Add Package

pnpm dlx jsr add @lysand-org/client

Import symbol

import * as mod from "@lysand-org/client";

Add Package

bunx jsr add @lysand-org/client

Import symbol

import * as mod from "@lysand-org/client";