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

esa-api-client

v1.2.0

Published

ESA API v1 client for TypeScript

Downloads

31

Readme

ESA API Client for TypeScript

TypeScriptで実装されたesa.io API v1のクライアントライブラリです。 標準のfetch APIを使用しています。 また、コードの作成にClaudeを使用しています。

インストール

npm install esa-api-client

または

yarn add esa-api-client

または

pnpm add esa-api-client

使い方

クライアントの初期化

import { EsaClient } from 'esa-api-client';

// チーム名を指定して初期化
const client = new EsaClient({
  token: 'YOUR_ACCESS_TOKEN',
  teamName: 'your-team-name'
});

// または、後からチーム名を設定することも可能
const client = new EsaClient({
  token: 'YOUR_ACCESS_TOKEN'
});
client.setTeamName('your-team-name');

チーム情報

// 所属チーム一覧の取得
const teams = await client.getTeams();

// 特定チームの取得
const team = await client.getTeam('your-team-name');

// チームの統計情報
const stats = await client.getTeamStats('your-team-name');

メンバー

// チームメンバー一覧の取得
const members = await client.getMembers();

// 特定メンバーの取得
const member = await client.getMember('username');

// メンバーの削除 (オーナー権限が必要)
await client.deleteMember('username');

記事

// 全ての記事を取得
const posts = await client.getPosts();

// 検索条件を指定して記事を取得
const searchedPosts = await client.getPosts({
  q: 'category:general',
  sort: 'updated',
  order: 'desc',
  page: 1,
  per_page: 20
});

// 特定の記事を取得
const post = await client.getPost(123);
// コメントも含めて取得
const postWithComments = await client.getPost(123, 'comments');

// 記事の作成
const newPost = await client.createPost({
  name: '新しい記事',
  body_md: '# はじめに\nこれは新しい記事です。',
  tags: ['api', 'dev'],
  category: 'dev/api',
  wip: true,
  message: '記事を作成しました'
});

// 記事の更新
const updatedPost = await client.updatePost(123, {
  body_md: '# はじめに\nこれは更新された記事です。',
  message: '記事を更新しました'
});

// 記事の削除
await client.deletePost(123);

コメント

// 記事のコメント一覧の取得
const comments = await client.getPostComments(123);

// 特定のコメントを取得
const comment = await client.getComment(456);

// コメントの作成
const newComment = await client.createComment(123, {
  body_md: 'いいね!'
});

// コメントの更新
const updatedComment = await client.updateComment(456, {
  body_md: 'とてもいいね!'
});

// コメントの削除
await client.deleteComment(456);

Star

// 記事のStarをしたユーザー一覧
const stargazers = await client.getPostStargazers(123);

// 記事にStarをつける
await client.starPost(123, { body: '素晴らしい記事です!' });

// 記事のStarを解除
await client.unstarPost(123);

// コメントのStarをしたユーザー一覧
const commentStargazers = await client.getCommentStargazers(456);

// コメントにStarをつける
await client.starComment(456);

// コメントのStarを解除
await client.unstarComment(456);

Watch

// 記事をWatchしているユーザー一覧
const watchers = await client.getPostWatchers(123);

// 記事をWatchする
await client.watchPost(123);

// 記事のWatchを解除
await client.unwatchPost(123);

カテゴリ

// カテゴリの一括移動
const result = await client.batchMoveCategory({
  from: '/foo/bar/',
  to: '/baz/'
});

タグ

// タグ一覧の取得
const tags = await client.getTags();

招待

// 共通招待URLの取得
const invitation = await client.getInvitationUrl();

// 共通招待URLの再発行
const newInvitation = await client.regenerateInvitationUrl();

// メンバーの招待
const invitations = await client.inviteMembers({
  emails: ['[email protected]', '[email protected]']
});

// 招待一覧の取得
const pendingInvitations = await client.getInvitations();

// 招待の削除
await client.deleteInvitation('invitation-code');

絵文字

// チーム固有の絵文字一覧の取得
const emojis = await client.getEmojis();

// すべての絵文字一覧の取得
const allEmojis = await client.getEmojis(true);

// 絵文字の作成
const newEmoji = await client.createEmoji({
  code: 'team_emoji',
  image: 'BASE64_ENCODED_IMAGE' // または File オブジェクト
});

// 絵文字の削除
await client.deleteEmoji('team_emoji');

ユーザー

// 認証中のユーザー情報の取得
const user = await client.getAuthenticatedUser();

// チーム情報を含むユーザー情報の取得
const userWithTeams = await client.getAuthenticatedUser(true);

エラーハンドリング

import { EsaClient, EsaApiError } from 'esa-api-client';

try {
  const post = await client.getPost(123);
} catch (error) {
  if (error instanceof EsaApiError) {
    console.error(`API Error (${error.status}):`, error.data);
  } else {
    console.error('Network or other error:', error);
  }
}

レート制限

esa APIには15分間に300リクエストという制限があります。このクライアントは429エラー(Too Many Requests)を検出した場合、自動的に待機して再試行します。

開発

テスト実行

単体テストの実行:

npm test

または特定のテストファイルのみ実行:

npm test -- esa-client.test.ts

統合テスト

実際のesa APIと通信する統合テストも用意されています。実行には有効なアクセストークンとチーム名が必要です:

ESA_API_TOKEN=your_token ESA_TEAM_NAME=your_team ESA_RUN_INTEGRATION=true npm test -- integration.test.ts

ビルド

TypeScriptのコンパイル:

npm run build

パッケージの公開

npm publish

ライセンス

MIT