npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mst-mkt/mixi2-application-sdk-ts

v0.2.3

Published

mixi2 Application SDK for TypeScript (Unofficial)

Readme

mixi2 Application SDK for TypeScript

mixi2 の Application API を利用するための TypeScript SDK です。

[!NOTE] この SDK は mixi 公式ではありません。 以下の公式リソースをもとに開発しています。

インストール

npm

npm version License Install size Downloads

pnpm add @mst-mkt/mixi2-application-sdk-ts

JSR

JSR JSR JSR Score

deno add jsr:@mst-mkt/mixi2-application-sdk-ts

環境サポート

このライブラリは以下のランタイム API に依存しており、環境によって利用できる機能が異なります。

| 環境 | auth | client | event/webhook | event/stream | | ------------------ | ------ | -------- | --------------- | -------------- | | Node.js | ✅ | ✅ | ✅ | ✅ | | Deno | ✅ | ✅ | ✅ | ✅ | | Bun | ✅ | ✅ | ✅ | ✅ | | Cloudflare Workers | ✅ | ❌ | ✅ | ❌ |

  • Node.js: 18.4.0 以降
    • crypto.subtle: 18.4.0 以降 (ref: https://nodejs.org/en/blog/release/v18.4.0#notable-changes)
    • node:http2: 10.10.0 以降 (ref: https://nodejs.org/en/blog/release/v10.10.0#notable-changes)
  • Deno: 1.26.0 以降
    • crypto.subtle: 1.26.0 以降 (ref: https://deno.com/blog/v1.26#webcrypto-secure-curves)
    • node:http2: 1.37.0 以降 (ref: https://deno.com/blog/v1.37#nodejs-compatibility-improvements)
  • Bun: 0.5.7 以降
    • crypto.subtle: 0.5.7 以降 (ref: https://bun.sh/blog/bun-v0.5.7#changelog)
    • node:http2: 1.0.13 以降 (ref: https://bun.sh/blog/bun-v1.0.13#http2-client-support)
  • Cloudflare Workers: 非対応
    • crypto.subtle: 2023-04-28 以降 (ref: https://developers.cloudflare.com/workers/platform/changelog/#2023-04-28)
    • node:http2: 非対応 (ref: https://developers.cloudflare.com/workers/runtime-apis/nodejs/#supported-nodejs-apis)

[!TIP] サーバーレス環境ではランタイムが対応していても gRPC ストリーミングが利用できない場合があります。環境に応じて Webhook と gRPC ストリーミングを使い分けてください。

機能

| モジュール | 説明 | | ------------------------------------------------- | ------------------------------------- | | @mst-mkt/mixi2-application-sdk-ts/auth | OAuth2 Client Credentials 認証 | | @mst-mkt/mixi2-application-sdk-ts/client | mixi2 Application API クライアント | | @mst-mkt/mixi2-application-sdk-ts/event | イベントハンドラーの定義 | | @mst-mkt/mixi2-application-sdk-ts/event/webhook | Webhook によるイベント受信 | | @mst-mkt/mixi2-application-sdk-ts/event/stream | gRPC ストリーミングによるイベント受信 |

使い方

API

createAuthenticator で認証情報を設定し、createMixi2Client で API クライアントを作成します。

import { createAuthenticator } from '@mst-mkt/mixi2-application-sdk-ts/auth'
import { createMixi2Client } from '@mst-mkt/mixi2-application-sdk-ts/client'

const authenticator = createAuthenticator({
  clientId: CLIENT_ID,
  clientSecret: CLIENT_SECRET,
})

const client = createMixi2Client({ authenticator })

const { posts } = await client.getPosts({ postIdList: ['5efb4595-fe2d-4c52-b078-b85020385955'] })

Event Handling

mixi2 からのイベント (投稿作成, チャット受信) を処理するハンドラーを定義します。 Webhook と gRPC ストリーミングの両方で共通のハンドラーを利用できます。

import { createEventHandler } from '@mst-mkt/mixi2-application-sdk-ts/event'

const eventHandler = createEventHandler({
  chatMessageReceived: async ({ message }) => {
    // チャット受信時の処理
  },
  postCreated: async ({ post }) => {
    // 投稿 (引用, メンション, リプライ) 作成時の処理
  },
})

Webhook

イベントハンドラーと署名検証用の公開鍵から Webhook ハンドラーを作成します。

import { createWebhookHandler } from '@mst-mkt/mixi2-application-sdk-ts/event/webhook'

const webhookHandler = createWebhookHandler(
  { signaturePublicKey: SIGNATURE_PUBLIC_KEY },
  eventHandler,
)

返り値は (req: Request) => Promise<Response> 型の関数で、Web 標準の Request / Response を使う任意の環境で動作します。

gRPC Stream

イベントハンドラーと認証情報から gRPC ストリーミングのウォッチャーを作成します。

import { createStreamWatcher } from '@mst-mkt/mixi2-application-sdk-ts/event/stream'

const streamWatcher = createStreamWatcher({ authenticator }, eventHandler)
await streamWatcher.watch()

watch()AbortSignal を渡すことで、任意のタイミングで監視を停止できます。

環境変数

| 変数名 | 使用先 | 取得元 | | ---------------------- | ---------------------- | -------------------------------------------------------------------------------------- | | CLIENT_ID | createAuthenticator | Developer Platform > アプリケーション > 認証情報 | | CLIENT_SECRET | createAuthenticator | Developer Platform > アプリケーション > 認証情報 | | SIGNATURE_PUBLIC_KEY | createWebhookHandler | Developer Platform > アプリケーション > Webhook |

実装例

開発

CONTRIBUTING.md を参照してください。

ライセンス

Apache License 2.0