misskey/packages/misskey-js
かっこかり 16ffd88ecc
enhance: 誕生日のユーザーウィジェットで、今日だけに限らず、直近の誕生日ユーザーを表示できるように (#13637)
* enhance(frontend): 「今日誕生日のフォロー中ユーザー」ウィジェットをリファクタリング

(cherry picked from commit 24652b9364)

* fix(backend): 年越しの時期で誕生日検索クエリーが誤動作する問題を修正 (MisskeyIO#577)

(cherry picked from commit 38581006be)

* fix

* spdx

* delete birthday param on users/following api

* 名称を一本化

* Update Changelog

* Update Changelog

* fix(frontend/WidgetBirthdayFollowings): ユーザーの名前が長いと投稿ボタンがはみ出てしまう問題を修正 (MisskeyIO#582)

(cherry picked from commit fa47a545b1)

* use module css

* default 3day

* Revert "delete birthday param on users/following api"

This reverts commit a47456c1c4.

* Update Changelog

* 日付が1ヶ月ズレている問題を修正?

* fix: 日付関連のバグを修正

Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com>

* build misskey-js types

* add comment

* Update CHANGELOG.md

* migrate

* change migration

* UPdate Changelog

* fix: revert unnecessary changes

* 🎨

* i18n

* fix

* update changelog

* 🎨

* fix lint

* refactor: remove unnecessary classes

* fix

* fix

---------

Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com>
2025-12-31 22:33:26 +09:00
..
docs docs: Remove forum references and use Github Discussions (#12158) 2023-11-02 19:57:43 +09:00
etc enhance: 誕生日のユーザーウィジェットで、今日だけに限らず、直近の誕生日ユーザーを表示できるように (#13637) 2025-12-31 22:33:26 +09:00
generator feat: use tsgo where capable (#16984) 2025-12-22 16:52:05 +09:00
src enhance: 誕生日のユーザーウィジェットで、今日だけに限らず、直近の誕生日ユーザーを表示できるように (#13637) 2025-12-31 22:33:26 +09:00
test chore(deps): update [misskey-js] update dependencies (major) (#16177) 2025-08-02 16:20:08 +09:00
test-d chore(deps): update [misskey-js] update dependencies (major) (#16177) 2025-08-02 16:20:08 +09:00
CONTRIBUTING.md docs: Remove forum references and use Github Discussions (#12158) 2023-11-02 19:57:43 +09:00
LICENSE 2025 (#15203) 2025-01-04 14:37:14 +09:00
README.md Feat: Chat (#15686) 2025-03-24 21:32:46 +09:00
api-extractor.json fix(misskey-js): api extractorの出力をLFに強制 (#15369) 2025-02-01 05:48:04 +00:00
build.js feat: use tsgo where capable (#16984) 2025-12-22 16:52:05 +09:00
eslint.config.js chore(deps): update [misskey-js] update dependencies (major) (#16177) 2025-08-02 16:20:08 +09:00
package.json feat: use tsgo where capable (#16984) 2025-12-22 16:52:05 +09:00
tsconfig.json refactor(misskey-js): enable exactOptionalPropertyTypes (#14203) 2024-07-14 15:52:43 +09:00
vitest.config.ts chore(deps): update [misskey-js] update dependencies (major) (#16177) 2025-08-02 16:20:08 +09:00

README.md

misskey.js

Strongly-typed official Misskey SDK for browsers/Node.js.

Test codecov

NPM

JavaScript(TypeScript)用の公式MisskeySDKです。ブラウザ/Node.js上で動作します。

以下が提供されています:

  • ユーザー認証
  • APIリクエスト
  • ストリーミング
  • ユーティリティ関数
  • Misskeyの各種型定義

対応するMisskeyのバージョンは12以上です。

Install

npm i misskey-js

Usage

インポートは以下のようにまとめて行うと便利です。

import * as Misskey from 'misskey-js';

便宜上、以後のコード例は上記のように* as Misskeyとしてインポートしている前提のものになります。

ただし、このインポート方法だとTree-Shakingできなくなるので、コードサイズが重要なユースケースでは以下のような個別インポートをお勧めします。

import { api as misskeyApi } from 'misskey-js';

Authenticate

todo

API request

APIを利用する際は、利用するサーバーの情報とアクセストークンを与えてAPIClientクラスのインスタンスを初期化し、そのインスタンスのrequestメソッドを呼び出してリクエストを行います。

const cli = new Misskey.api.APIClient({
	origin: 'https://misskey.test',
	credential: 'TOKEN',
});

const meta = await cli.request('meta', { detail: true });

requestの第一引数には呼び出すエンドポイント名、第二引数にはパラメータオブジェクトを渡します。レスポンスはPromiseとして返ります。

Streaming

misskey.jsのストリーミングでは、二つのクラスが提供されます。 ひとつは、ストリーミングのコネクション自体を司るStreamクラスと、もうひとつはストリーミング上のチャンネルの概念を表すChannelクラスです。 ストリーミングを利用する際は、まずStreamクラスのインスタンスを初期化し、その後でStreamインスタンスのメソッドを利用してChannelクラスのインスタンスを取得する形になります。

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const mainChannel = stream.useChannel('main');
mainChannel.on('notification', notification => {
	console.log('notification received', notification);
});

コネクションが途切れても自動で再接続されます。

チャンネルへの接続

チャンネルへの接続はStreamクラスのuseChannelメソッドを使用します。

パラメータなし

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });

const mainChannel = stream.useChannel('main');

パラメータあり

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });

const chatChannel = stream.useChannel('chat', {
	other: 'xxxxxxxxxx',
});

チャンネルから切断

Channelクラスのdisposeメソッドを呼び出します。

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });

const mainChannel = stream.useChannel('main');

mainChannel.dispose();

メッセージの受信

ChannelクラスはEventEmitterを継承しており、メッセージがサーバーから受信されると受け取ったイベント名でペイロードをemitします。

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const mainChannel = stream.useChannel('main');
mainChannel.on('notification', notification => {
	console.log('notification received', notification);
});

メッセージの送信

Channelクラスのsendメソッドを使用してメッセージをサーバーに送信することができます。

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const chatChannel = stream.useChannel('chat', {
	other: 'xxxxxxxxxx',
});

chatChannel.send('read', {
	id: 'xxxxxxxxxx'
});

コネクション確立イベント

Streamクラスの_connected_イベントが利用可能です。

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
stream.on('_connected_', () => {
	console.log('connected');
});

コネクション切断イベント

Streamクラスの_disconnected_イベントが利用可能です。

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
stream.on('_disconnected_', () => {
	console.log('disconnected');
});

コネクションの状態

Streamクラスのstateプロパティで確認できます。

  • initializing: 接続確立前
  • connected: 接続完了
  • reconnecting: 再接続中