Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suin/esa-exporter
esa.io API から全データをエクスポートするライブラリ。
https://github.com/suin/esa-exporter
esa esa-api esa-io
Last synced: about 1 month ago
JSON representation
esa.io API から全データをエクスポートするライブラリ。
- Host: GitHub
- URL: https://github.com/suin/esa-exporter
- Owner: suin
- License: mit
- Created: 2021-03-24T01:15:31.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-25T01:57:54.000Z (almost 4 years ago)
- Last Synced: 2024-10-04T23:15:32.832Z (3 months ago)
- Topics: esa, esa-api, esa-io
- Language: TypeScript
- Homepage:
- Size: 70.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @suin/esa-exporter
esa.io API から全データをエクスポートするライブラリ。
esa.io のエクスポート機能はマークダウンファイルがダウンロードできるだけで、他の情報が入ってこないためこれを開発しました。
## 特徴
- エクスポートに対応しているデータ
- メンバー
- 投稿
- コメント
- stargazers## インストール
```bash
yarn add @suin/esa-exporter
# or
npm install @suin/esa-exporter
```## 使い方
基本的な用法:
```typescript
import { exportAll, Entity } from "@suin/esa-exporter";(async () => {
const team = process.env.ESA_TEAM;
const token = process.env.ESA_TOKEN;
const entities: Entity[] = [];for await (const entity of exportAll({ team, token })) {
entities.push(entity);
}console.log(entities);
})();
```出力例:
```javascript
[
{
$type: "member",
myself: true,
name: "Taro Tanaka",
screen_name: "tanaka",
icon:
"https://img.esa.io/uploads/production/users/1/icon/thumb_m_********.png",
role: "owner",
posts_count: 222,
joined_at: "2014-07-01T08:10:55+09:00",
last_accessed_at: "2019-12-27T16:23:23+09:00",
email: "[email protected]",
},
{
$type: "member",
myself: false,
name: "Hanako Sato",
screen_name: "sato",
icon:
"https://img.esa.io/uploads/production/users/2/icon/thumb_m_********.jpg",
role: "owner",
posts_count: 111,
joined_at: "2014-07-01T08:19:26+09:00",
last_accessed_at: "2019-08-13T18:07:24+09:00",
email: "[email protected]",
},
{
$type: "post",
number: 1,
name: "esa APIの使い方",
full_name: "日報/2015/05/09/esa APIの使い方 #api #dev",
wip: true,
body_md: "...",
body_html: "...",
created_at: "2015-05-09T11:54:50+09:00",
message: "初稿です!",
url: "https://example.esa.io/posts/1",
updated_at: "2015-05-09T11:54:51+09:00",
tags: ["api", "dev"],
category: "日報/2015/05/09",
revision_number: 1,
created_by: {
myself: true,
name: "Taro Tanaka",
screen_name: "tanaka",
icon:
"https://img.esa.io/uploads/production/users/1/icon/thumb_m_********.png",
},
updated_by: {
myself: true,
name: "Taro Tanaka",
screen_name: "tanaka",
icon:
"https://img.esa.io/uploads/production/users/1/icon/thumb_m_********.png",
},
},
];
````exportAll`は様々なエンティティをごちゃまぜで返してくるので、 エンティティ種別ごとに何らかの処理をする必要がある場合は、`Entity[$type]`で分岐処理を書いてください:
```typescript
import { exportAll, Member, Post } from "@suin/esa-exporter";(async () => {
const team = process.env.ESA_TEAM;
const token = process.env.ESA_TOKEN;const members: Member[] = [];
const posts: Post[] = [];for await (const entity of exportAll({ team, token })) {
switch (entity.$type) {
case "member":
members.push(entity);
break;
case "post":
posts.push(posts);
break;
}
}
})();
```## API リファレンス
https://suin.github.io/esa-exporter/