Skip to content

Instantly share code, notes, and snippets.

@niku
Last active December 29, 2015 16:49
Show Gist options
  • Save niku/7700173 to your computer and use it in GitHub Desktop.
Save niku/7700173 to your computer and use it in GitHub Desktop.
machine readable chatwork-api generator
{
"endpoints": [
{
"name": "/me",
"description": "自分自身の情報にアクセスできます。",
"apis": [
{
"verb": "GET",
"path": "/me",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/me\"",
"response": {
"account_id": 123,
"room_id": 322,
"name": "John Smith",
"chatwork_id": "tarochatworkid",
"organization_id": 101,
"organization_name": "Hello Company",
"department": "Marketing",
"title": "CMO",
"url": "http://mycompany.com",
"introduction": "Self Introduction",
"mail": "[email protected]",
"tel_organization": "XXX-XXXX-XXXX",
"tel_extension": "YYY-YYYY-YYYY",
"tel_mobile": "ZZZ-ZZZZ-ZZZZ",
"skype": "myskype_id",
"facebook": "myfacebook_id",
"twitter": "mytwitter_id",
"avatar_image_url": "https://example.com/abc.png"
},
"description": "自分自身の情報を取得",
"params": [
]
}
]
},
{
"name": "/my",
"description": "自分が持つデータへアクセスできます。",
"apis": [
{
"verb": "GET",
"path": "/my/status",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/my/status\"",
"response": {
"unread_room_num": 2,
"mention_room_num": 1,
"mytask_room_num": 3,
"unread_num": 12,
"mention_num": 1,
"mytask_num": 8
},
"description": "自分の未読数、未読To数、未完了タスク数を返す",
"params": [
]
},
{
"verb": "GET",
"path": "/my/tasks",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" -d \"assigned_by_account_id=78&status=done\" \"https://api.chatwork.com/v1/my/tasks\"",
"response": [
{
"task_id": 3,
"room": {
"room_id": 5,
"name": "Group Chat Name",
"icon_path": "https://example.com/ico_group.png"
},
"assigned_by_account": {
"account_id": 456,
"name": "Anna",
"avatar_image_url": "https://example.com/def.png"
},
"message_id": 13,
"body": "buy milk",
"limit_time": 1384354799,
"status": "open"
}
],
"description": "自分のタスク一覧を取得する。(※100件まで取得可能。今後、より多くのデータを取得する為のページネーションの仕組みを提供予定)",
"params": [
{
"name": "assigned_by_account_id",
"description": "タスクの依頼者のアカウントID",
"body": "",
"choices": null,
"example": "78",
"type": "integer",
"required": true,
"list_type": null
},
{
"name": "status",
"description": "タスクのステータス",
"body": "",
"choices": [
"open",
"done"
],
"example": "done",
"type": "string",
"required": true,
"list_type": "enum"
}
]
}
]
},
{
"name": "/contacts",
"description": "自分のコンタクトになっているユーザーの一覧にアクセスできます。",
"apis": [
{
"verb": "GET",
"path": "/contacts",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/contacts\"",
"response": [
{
"account_id": 123,
"room_id": 322,
"name": "John Smith",
"chatwork_id": "tarochatworkid",
"organization_id": 101,
"organization_name": "Hello Company",
"department": "Marketing",
"avatar_image_url": "https://example.com/abc.png"
}
],
"description": "自分のコンタクト一覧を取得",
"params": [
]
}
]
},
{
"name": "/rooms",
"description": "グループチャット、ダイレクトチャット、マイチャットなどのチャット全体をあらわすエンドポイントです。チャットにひもづくメッセージ、タスク、ファイル、概要、メンバー情報などにアクセスできます。",
"apis": [
{
"verb": "GET",
"path": "/rooms",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/rooms\"",
"response": [
{
"room_id": 123,
"name": "Group Chat Name",
"type": "group",
"role": "admin",
"sticky": false,
"unread_num": 10,
"mention_num": 1,
"mytask_num": 0,
"message_num": 122,
"file_num": 10,
"task_num": 17,
"icon_path": "https://example.com/ico_group.png",
"last_update_time": 1298905200
}
],
"description": "自分のチャット一覧の取得",
"params": [
]
},
{
"verb": "POST",
"path": "/rooms",
"implemented": true,
"code": "curl -X POST -H \"X-ChatWorkToken: 自分のAPIトークン\" -d \"description=group+chat+description&icon_preset=meeting&members_admin_ids=123%2C542%2C1001&members_member_ids=21%2C344&members_readonly_ids=15%2C103&name=Website+renewal+project\" \"https://api.chatwork.com/v1/rooms\"",
"response": {
"room_id": 123,
"name": "Group Chat Name",
"type": "group",
"role": "admin",
"sticky": false,
"unread_num": 10,
"mention_num": 1,
"mytask_num": 0,
"message_num": 122,
"file_num": 10,
"task_num": 17,
"icon_path": "https://example.com/ico_group.png",
"last_update_time": 1298905200,
"description": "room description text"
},
"description": "グループチャットを新規作成",
"params": [
{
"name": "description",
"description": "チャット概要",
"body": "グループチャットの概要説明テキスト",
"choices": null,
"example": "group chat description",
"type": "string",
"required": true,
"list_type": null
},
{
"name": "icon_preset",
"description": "アイコン種類",
"body": "グループチャットのアイコン種類",
"choices": [
"group",
"check",
"document",
"meeting",
"event",
"project",
"business",
"study",
"security",
"star",
"idea",
"heart",
"magcup",
"beer",
"music",
"sports",
"travel"
],
"example": "meeting",
"type": "string",
"required": true,
"list_type": "enum"
},
{
"name": "members_admin_ids",
"description": "管理者権限のユーザー",
"body": "作成したチャットに参加メンバーのうち、管理者権限にしたいユーザーのアカウントIDの配列。最低1人は指定する必要がある。※リストはカンマ区切りで複数の値を指定してください",
"choices": null,
"example": "123,542,1001",
"type": "integer",
"required": false,
"list_type": "list"
},
{
"name": "members_member_ids",
"description": "メンバー権限のユーザー",
"body": "作成したチャットに参加メンバーのうち、メンバー権限にしたいユーザーのアカウントIDの配列。※リストはカンマ区切りで複数の値を指定してください",
"choices": null,
"example": "21,344",
"type": "integer",
"required": true,
"list_type": "list"
},
{
"name": "members_readonly_ids",
"description": "閲覧のみ権限のユーザー",
"body": "作成したチャットに参加メンバーのうち、閲覧のみ権限にしたいユーザーのアカウントIDの配列。※リストはカンマ区切りで複数の値を指定してください",
"choices": null,
"example": "15,103",
"type": "integer",
"required": true,
"list_type": "list"
},
{
"name": "name",
"description": "グループチャット名",
"body": "作成したいグループチャットのチャット名",
"choices": null,
"example": "Website renewal project",
"type": "string",
"required": false,
"list_type": null
}
]
},
{
"verb": "GET",
"path": "/rooms/{room_id}",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/rooms/{room_id}\"",
"response": {
"room_id": 123,
"name": "Group Chat Name",
"type": "group",
"role": "admin",
"sticky": false,
"unread_num": 10,
"mention_num": 1,
"mytask_num": 0,
"message_num": 122,
"file_num": 10,
"task_num": 17,
"icon_path": "https://example.com/ico_group.png",
"last_update_time": 1298905200,
"description": "room description text"
},
"description": "チャットの名前、アイコン、種類(my/direct/group)を取得",
"params": [
]
},
{
"verb": "PUT",
"path": "/rooms/{room_id}",
"implemented": true,
"code": "curl -X PUT -H \"X-ChatWorkToken: 自分のAPIトークン\" -d \"description=group+chat+description&icon_preset=meeting&name=Website+renewal+project\" \"https://api.chatwork.com/v1/rooms/{room_id}\"",
"response": {
"room_id": 123,
"name": "Group Chat Name",
"type": "group",
"role": "admin",
"sticky": false,
"unread_num": 10,
"mention_num": 1,
"mytask_num": 0,
"message_num": 122,
"file_num": 10,
"task_num": 17,
"icon_path": "https://example.com/ico_group.png",
"last_update_time": 1298905200,
"description": "room description text"
},
"description": "チャットの名前、アイコンをアップデート",
"params": [
{
"name": "description",
"description": "チャット概要",
"body": "グループチャットの概要説明テキスト",
"choices": null,
"example": "group chat description",
"type": "string",
"required": true,
"list_type": null
},
{
"name": "icon_preset",
"description": "アイコン種類",
"body": "グループチャットのアイコン種類",
"choices": [
"group",
"check",
"document",
"meeting",
"event",
"project",
"business",
"study",
"security",
"star",
"idea",
"heart",
"magcup",
"beer",
"music",
"sports",
"travel"
],
"example": "meeting",
"type": "string",
"required": true,
"list_type": "enum"
},
{
"name": "name",
"description": "グループチャット名",
"body": "グループチャットのチャット名",
"choices": null,
"example": "Website renewal project",
"type": "string",
"required": true,
"list_type": null
}
]
},
{
"verb": "DELETE",
"path": "/rooms/{room_id}",
"implemented": true,
"code": "curl -X DELETE -H \"X-ChatWorkToken: 自分のAPIトークン\" -d \"action_type=leave\" \"https://api.chatwork.com/v1/rooms/{room_id}\"",
"response": null,
"description": "グループチャットを退席/削除する",
"params": [
{
"name": "action_type",
"description": "退席するか、削除するか",
"body": "退席すると、このグループチャットにある自分が担当のタスク、および自分が送信したファイルは削除されます。\n削除すると、このグループチャットに参加しているメンバー全員のメッセージ、タスク、ファイルはすべて削除されます。\n※一度削除すると元に戻せません!",
"choices": [
"leave",
"delete"
],
"example": "leave",
"type": "string",
"required": false,
"list_type": "enum"
}
]
},
{
"verb": "GET",
"path": "/rooms/{room_id}/members",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/rooms/{room_id}/members\"",
"response": [
{
"account_id": 123,
"role": "member",
"name": "John Smith",
"chatwork_id": "tarochatworkid",
"organization_id": 101,
"organization_name": "Hello Company",
"department": "Marketing",
"avatar_image_url": "https://example.com/abc.png"
}
],
"description": "チャットのメンバー一覧を取得",
"params": [
]
},
{
"verb": "PUT",
"path": "/rooms/{room_id}/members",
"implemented": true,
"code": "curl -X PUT -H \"X-ChatWorkToken: 自分のAPIトークン\" -d \"members_admin_ids=123%2C542%2C1001&members_member_ids=21%2C344&members_readonly_ids=15%2C103\" \"https://api.chatwork.com/v1/rooms/{room_id}/members\"",
"response": {
"admin": [
123,
542,
1001
],
"member": [
10,
103
],
"readonly": [
6,
11
]
},
"description": "チャットのメンバーを一括変更",
"params": [
{
"name": "members_admin_ids",
"description": "管理者権限のユーザー",
"body": "作成したチャットに参加メンバーのうち、管理者権限にしたいユーザーのアカウントIDの配列。最低1人は指定する必要がある。※リストはカンマ区切りで複数の値を指定してください",
"choices": null,
"example": "123,542,1001",
"type": "integer",
"required": false,
"list_type": "list"
},
{
"name": "members_member_ids",
"description": "メンバー権限のユーザー",
"body": "作成したチャットに参加メンバーのうち、メンバー権限にしたいユーザーのアカウントIDの配列。※リストはカンマ区切りで複数の値を指定してください",
"choices": null,
"example": "21,344",
"type": "integer",
"required": true,
"list_type": "list"
},
{
"name": "members_readonly_ids",
"description": "閲覧のみ権限のユーザー",
"body": "作成したチャットに参加メンバーのうち、閲覧のみ権限にしたいユーザーのアカウントIDの配列。※リストはカンマ区切りで複数の値を指定してください",
"choices": null,
"example": "15,103",
"type": "integer",
"required": true,
"list_type": "list"
}
]
},
{
"verb": "GET",
"path": "/rooms/{room_id}/messages",
"implemented": false,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/rooms/{room_id}/messages\"",
"response": [
{
"message_id": 5,
"account": {
"account_id": 123,
"name": "Bob",
"avatar_image_url": "https://example.com/ico_avatar.png"
},
"body": "Hello Chatwork!",
"send_time": 1384242850,
"update_time": 0
}
],
"description": "※このAPIは未実装です!まだ利用することはできません",
"params": [
]
},
{
"verb": "POST",
"path": "/rooms/{room_id}/messages",
"implemented": true,
"code": "curl -X POST -H \"X-ChatWorkToken: 自分のAPIトークン\" -d \"body=Hello+ChatWork%21\" \"https://api.chatwork.com/v1/rooms/{room_id}/messages\"",
"response": {
"message_id": 5,
"account": {
"account_id": 123,
"name": "Bob",
"avatar_image_url": "https://example.com/ico_avatar.png"
},
"body": "Hello Chatwork!",
"send_time": 1384242850,
"update_time": 0
},
"description": "チャットに新しいメッセージを追加",
"params": [
{
"name": "body",
"description": "メッセージ本文",
"body": "",
"choices": null,
"example": "Hello ChatWork!",
"type": "string",
"required": false,
"list_type": null
}
]
},
{
"verb": "GET",
"path": "/rooms/{room_id}/messages/{message_id}",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/rooms/{room_id}/messages/{message_id}\"",
"response": {
"message_id": 5,
"account": {
"account_id": 123,
"name": "Bob",
"avatar_image_url": "https://example.com/ico_avatar.png"
},
"body": "Hello Chatwork!",
"send_time": 1384242850,
"update_time": 0
},
"description": "メッセージ情報を取得",
"params": [
]
},
{
"verb": "GET",
"path": "/rooms/{room_id}/tasks",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" -d \"account_id=101&assigned_by_account_id=78&status=done\" \"https://api.chatwork.com/v1/rooms/{room_id}/tasks\"",
"response": [
{
"task_id": 3,
"room": {
"room_id": 5,
"name": "Group Chat Name",
"icon_path": "https://example.com/ico_group.png"
},
"account": {
"account_id": 123,
"name": "Bob",
"avatar_image_url": "https://example.com/abc.png"
},
"assigned_by_account": {
"account_id": 456,
"name": "Anna",
"avatar_image_url": "https://example.com/def.png"
},
"message_id": 13,
"body": "buy milk",
"limit_time": 1384354799,
"status": "open"
}
],
"description": "チャットのタスク一覧を取得 (※100件まで取得可能。今後、より多くのデータを取得する為のページネーションの仕組みを提供予定)",
"params": [
{
"name": "account_id",
"description": "タスクの担当者のアカウントID",
"body": "",
"choices": null,
"example": "101",
"type": "integer",
"required": true,
"list_type": null
},
{
"name": "assigned_by_account_id",
"description": "タスクの依頼者のアカウントID",
"body": "",
"choices": null,
"example": "78",
"type": "integer",
"required": true,
"list_type": null
},
{
"name": "status",
"description": "タスクのステータス",
"body": "",
"choices": [
"open",
"done"
],
"example": "done",
"type": "string",
"required": true,
"list_type": "enum"
}
]
},
{
"verb": "POST",
"path": "/rooms/{room_id}/tasks",
"implemented": true,
"code": "curl -X POST -H \"X-ChatWorkToken: 自分のAPIトークン\" -d \"body=Buy+milk&to_ids=1%2C3%2C6\" \"https://api.chatwork.com/v1/rooms/{room_id}/tasks\"",
"response": {
"task_ids": [
123,
124
]
},
"description": "チャットに新しいタスクを追加",
"params": [
{
"name": "body",
"description": "タスクの内容",
"body": "",
"choices": null,
"example": "Buy milk",
"type": "string",
"required": false,
"list_type": null
},
{
"name": "limit",
"description": "タスクの期限",
"body": "",
"choices": null,
"example": null,
"type": "integer",
"required": true,
"list_type": null
},
{
"name": "to_ids",
"description": "担当者のアカウントID",
"body": "担当者のアカウントIDをカンマ区切りで※リストはカンマ区切りで複数の値を指定してください",
"choices": null,
"example": "1,3,6",
"type": "integer",
"required": false,
"list_type": "list"
}
]
},
{
"verb": "GET",
"path": "/rooms/{room_id}/tasks/{task_id}",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/rooms/{room_id}/tasks/{task_id}\"",
"response": {
"task_id": 3,
"account": {
"account_id": 123,
"name": "Bob",
"avatar_image_url": "https://example.com/abc.png"
},
"assigned_by_account": {
"account_id": 456,
"name": "Anna",
"avatar_image_url": "https://example.com/def.png"
},
"message_id": 13,
"body": "buy milk",
"limit_time": 1384354799,
"status": "open"
},
"description": "タスク情報を取得",
"params": [
]
},
{
"verb": "GET",
"path": "/rooms/{room_id}/files",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" -d \"account_id=101\" \"https://api.chatwork.com/v1/rooms/{room_id}/files\"",
"response": [
{
"file_id": 3,
"account": {
"account_id": 123,
"name": "Bob",
"avatar_image_url": "https://example.com/ico_avatar.png"
},
"message_id": 22,
"filename": "README.md",
"filesize": 2232,
"upload_time": 1384414750
}
],
"description": "チャットのファイル一覧を取得 (※100件まで取得可能。今後、より多くのデータを取得する為のページネーションの仕組みを提供予定)",
"params": [
{
"name": "account_id",
"description": "アップロードしたユーザーのアカウントID",
"body": "",
"choices": null,
"example": "101",
"type": "integer",
"required": true,
"list_type": null
}
]
},
{
"verb": "GET",
"path": "/rooms/{room_id}/files/{file_id}",
"implemented": true,
"code": "curl -X GET -H \"X-ChatWorkToken: 自分のAPIトークン\" \"https://api.chatwork.com/v1/rooms/{room_id}/files/{file_id}\"",
"response": {
"file_id": 3,
"account": {
"account_id": 123,
"name": "Bob",
"avatar_image_url": "https://example.com/ico_avatar.png"
},
"message_id": 22,
"filename": "README.md",
"filesize": 2232,
"upload_time": 1384414750
},
"description": "ファイル情報を取得",
"params": [
{
"name": "create_download_url",
"description": "ダウンロードする為のURLを生成するか",
"body": "30秒間だけダウンロード可能なURLを生成します",
"choices": null,
"example": null,
"type": "boolean",
"required": true,
"list_type": null
}
]
}
]
}
]
}
---
:endpoints:
- :name: "/me"
:description: "自分自身の情報にアクセスできます。"
:apis:
- :verb: GET
:path: "/me"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/me"'
:response:
account_id: 123
room_id: 322
name: John Smith
chatwork_id: tarochatworkid
organization_id: 101
organization_name: Hello Company
department: Marketing
title: CMO
url: http://mycompany.com
introduction: Self Introduction
mail: [email protected]
tel_organization: XXX-XXXX-XXXX
tel_extension: YYY-YYYY-YYYY
tel_mobile: ZZZ-ZZZZ-ZZZZ
skype: myskype_id
facebook: myfacebook_id
twitter: mytwitter_id
avatar_image_url: https://example.com/abc.png
:description: "自分自身の情報を取得"
:params: []
- :name: "/my"
:description: "自分が持つデータへアクセスできます。"
:apis:
- :verb: GET
:path: "/my/status"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/my/status"'
:response:
unread_room_num: 2
mention_room_num: 1
mytask_room_num: 3
unread_num: 12
mention_num: 1
mytask_num: 8
:description: "自分の未読数、未読To数、未完了タスク数を返す"
:params: []
- :verb: GET
:path: "/my/tasks"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" -d "assigned_by_account_id=78&status=done"
"https://api.chatwork.com/v1/my/tasks"'
:response:
- task_id: 3
room:
room_id: 5
name: Group Chat Name
icon_path: https://example.com/ico_group.png
assigned_by_account:
account_id: 456
name: Anna
avatar_image_url: https://example.com/def.png
message_id: 13
body: buy milk
limit_time: 1384354799
status: open
:description: "自分のタスク一覧を取得する。(※100件まで取得可能。今後、より多くのデータを取得する為のページネーションの仕組みを提供予定)"
:params:
- :name: assigned_by_account_id
:description: "タスクの依頼者のアカウントID"
:body: ''
:choices:
:example: '78'
:type: :integer
:required: true
:list_type:
- :name: status
:description: "タスクのステータス"
:body: ''
:choices:
- open
- done
:example: done
:type: :string
:required: true
:list_type: :enum
- :name: "/contacts"
:description: "自分のコンタクトになっているユーザーの一覧にアクセスできます。"
:apis:
- :verb: GET
:path: "/contacts"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/contacts"'
:response:
- account_id: 123
room_id: 322
name: John Smith
chatwork_id: tarochatworkid
organization_id: 101
organization_name: Hello Company
department: Marketing
avatar_image_url: https://example.com/abc.png
:description: "自分のコンタクト一覧を取得"
:params: []
- :name: "/rooms"
:description: "グループチャット、ダイレクトチャット、マイチャットなどのチャット全体をあらわすエンドポイントです。チャットにひもづくメッセージ、タスク、ファイル、概要、メンバー情報などにアクセスできます。"
:apis:
- :verb: GET
:path: "/rooms"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/rooms"'
:response:
- room_id: 123
name: Group Chat Name
type: group
role: admin
sticky: false
unread_num: 10
mention_num: 1
mytask_num: 0
message_num: 122
file_num: 10
task_num: 17
icon_path: https://example.com/ico_group.png
last_update_time: 1298905200
:description: "自分のチャット一覧の取得"
:params: []
- :verb: POST
:path: "/rooms"
:implemented: true
:code: 'curl -X POST -H "X-ChatWorkToken: 自分のAPIトークン" -d "description=group+chat+description&icon_preset=meeting&members_admin_ids=123%2C542%2C1001&members_member_ids=21%2C344&members_readonly_ids=15%2C103&name=Website+renewal+project"
"https://api.chatwork.com/v1/rooms"'
:response:
room_id: 123
name: Group Chat Name
type: group
role: admin
sticky: false
unread_num: 10
mention_num: 1
mytask_num: 0
message_num: 122
file_num: 10
task_num: 17
icon_path: https://example.com/ico_group.png
last_update_time: 1298905200
description: room description text
:description: "グループチャットを新規作成"
:params:
- :name: description
:description: "チャット概要"
:body: "グループチャットの概要説明テキスト"
:choices:
:example: group chat description
:type: :string
:required: true
:list_type:
- :name: icon_preset
:description: "アイコン種類"
:body: "グループチャットのアイコン種類"
:choices:
- group
- check
- document
- meeting
- event
- project
- business
- study
- security
- star
- idea
- heart
- magcup
- beer
- music
- sports
- travel
:example: meeting
:type: :string
:required: true
:list_type: :enum
- :name: members_admin_ids
:description: "管理者権限のユーザー"
:body: "作成したチャットに参加メンバーのうち、管理者権限にしたいユーザーのアカウントIDの配列。最低1人は指定する必要がある。※リストはカンマ区切りで複数の値を指定してください"
:choices:
:example: '123,542,1001'
:type: :integer
:required: false
:list_type: :list
- :name: members_member_ids
:description: "メンバー権限のユーザー"
:body: "作成したチャットに参加メンバーのうち、メンバー権限にしたいユーザーのアカウントIDの配列。※リストはカンマ区切りで複数の値を指定してください"
:choices:
:example: '21,344'
:type: :integer
:required: true
:list_type: :list
- :name: members_readonly_ids
:description: "閲覧のみ権限のユーザー"
:body: "作成したチャットに参加メンバーのうち、閲覧のみ権限にしたいユーザーのアカウントIDの配列。※リストはカンマ区切りで複数の値を指定してください"
:choices:
:example: '15,103'
:type: :integer
:required: true
:list_type: :list
- :name: name
:description: "グループチャット名"
:body: "作成したいグループチャットのチャット名"
:choices:
:example: Website renewal project
:type: :string
:required: false
:list_type:
- :verb: GET
:path: "/rooms/{room_id}"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/rooms/{room_id}"'
:response:
room_id: 123
name: Group Chat Name
type: group
role: admin
sticky: false
unread_num: 10
mention_num: 1
mytask_num: 0
message_num: 122
file_num: 10
task_num: 17
icon_path: https://example.com/ico_group.png
last_update_time: 1298905200
description: room description text
:description: "チャットの名前、アイコン、種類(my/direct/group)を取得"
:params: []
- :verb: PUT
:path: "/rooms/{room_id}"
:implemented: true
:code: 'curl -X PUT -H "X-ChatWorkToken: 自分のAPIトークン" -d "description=group+chat+description&icon_preset=meeting&name=Website+renewal+project"
"https://api.chatwork.com/v1/rooms/{room_id}"'
:response:
room_id: 123
name: Group Chat Name
type: group
role: admin
sticky: false
unread_num: 10
mention_num: 1
mytask_num: 0
message_num: 122
file_num: 10
task_num: 17
icon_path: https://example.com/ico_group.png
last_update_time: 1298905200
description: room description text
:description: "チャットの名前、アイコンをアップデート"
:params:
- :name: description
:description: "チャット概要"
:body: "グループチャットの概要説明テキスト"
:choices:
:example: group chat description
:type: :string
:required: true
:list_type:
- :name: icon_preset
:description: "アイコン種類"
:body: "グループチャットのアイコン種類"
:choices:
- group
- check
- document
- meeting
- event
- project
- business
- study
- security
- star
- idea
- heart
- magcup
- beer
- music
- sports
- travel
:example: meeting
:type: :string
:required: true
:list_type: :enum
- :name: name
:description: "グループチャット名"
:body: "グループチャットのチャット名"
:choices:
:example: Website renewal project
:type: :string
:required: true
:list_type:
- :verb: DELETE
:path: "/rooms/{room_id}"
:implemented: true
:code: 'curl -X DELETE -H "X-ChatWorkToken: 自分のAPIトークン" -d "action_type=leave"
"https://api.chatwork.com/v1/rooms/{room_id}"'
:response:
:description: "グループチャットを退席/削除する"
:params:
- :name: action_type
:description: "退席するか、削除するか"
:body: |-
退席すると、このグループチャットにある自分が担当のタスク、および自分が送信したファイルは削除されます。
削除すると、このグループチャットに参加しているメンバー全員のメッセージ、タスク、ファイルはすべて削除されます。
※一度削除すると元に戻せません!
:choices:
- leave
- delete
:example: leave
:type: :string
:required: false
:list_type: :enum
- :verb: GET
:path: "/rooms/{room_id}/members"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/rooms/{room_id}/members"'
:response:
- account_id: 123
role: member
name: John Smith
chatwork_id: tarochatworkid
organization_id: 101
organization_name: Hello Company
department: Marketing
avatar_image_url: https://example.com/abc.png
:description: "チャットのメンバー一覧を取得"
:params: []
- :verb: PUT
:path: "/rooms/{room_id}/members"
:implemented: true
:code: 'curl -X PUT -H "X-ChatWorkToken: 自分のAPIトークン" -d "members_admin_ids=123%2C542%2C1001&members_member_ids=21%2C344&members_readonly_ids=15%2C103"
"https://api.chatwork.com/v1/rooms/{room_id}/members"'
:response:
admin:
- 123
- 542
- 1001
member:
- 10
- 103
readonly:
- 6
- 11
:description: "チャットのメンバーを一括変更"
:params:
- :name: members_admin_ids
:description: "管理者権限のユーザー"
:body: "作成したチャットに参加メンバーのうち、管理者権限にしたいユーザーのアカウントIDの配列。最低1人は指定する必要がある。※リストはカンマ区切りで複数の値を指定してください"
:choices:
:example: '123,542,1001'
:type: :integer
:required: false
:list_type: :list
- :name: members_member_ids
:description: "メンバー権限のユーザー"
:body: "作成したチャットに参加メンバーのうち、メンバー権限にしたいユーザーのアカウントIDの配列。※リストはカンマ区切りで複数の値を指定してください"
:choices:
:example: '21,344'
:type: :integer
:required: true
:list_type: :list
- :name: members_readonly_ids
:description: "閲覧のみ権限のユーザー"
:body: "作成したチャットに参加メンバーのうち、閲覧のみ権限にしたいユーザーのアカウントIDの配列。※リストはカンマ区切りで複数の値を指定してください"
:choices:
:example: '15,103'
:type: :integer
:required: true
:list_type: :list
- :verb: GET
:path: "/rooms/{room_id}/messages"
:implemented: false
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/rooms/{room_id}/messages"'
:response:
- message_id: 5
account:
account_id: 123
name: Bob
avatar_image_url: https://example.com/ico_avatar.png
body: Hello Chatwork!
send_time: 1384242850
update_time: 0
:description: "※このAPIは未実装です!まだ利用することはできません"
:params: []
- :verb: POST
:path: "/rooms/{room_id}/messages"
:implemented: true
:code: 'curl -X POST -H "X-ChatWorkToken: 自分のAPIトークン" -d "body=Hello+ChatWork%21"
"https://api.chatwork.com/v1/rooms/{room_id}/messages"'
:response:
message_id: 5
account:
account_id: 123
name: Bob
avatar_image_url: https://example.com/ico_avatar.png
body: Hello Chatwork!
send_time: 1384242850
update_time: 0
:description: "チャットに新しいメッセージを追加"
:params:
- :name: body
:description: "メッセージ本文"
:body: ''
:choices:
:example: Hello ChatWork!
:type: :string
:required: false
:list_type:
- :verb: GET
:path: "/rooms/{room_id}/messages/{message_id}"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/rooms/{room_id}/messages/{message_id}"'
:response:
message_id: 5
account:
account_id: 123
name: Bob
avatar_image_url: https://example.com/ico_avatar.png
body: Hello Chatwork!
send_time: 1384242850
update_time: 0
:description: "メッセージ情報を取得"
:params: []
- :verb: GET
:path: "/rooms/{room_id}/tasks"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" -d "account_id=101&assigned_by_account_id=78&status=done"
"https://api.chatwork.com/v1/rooms/{room_id}/tasks"'
:response:
- task_id: 3
room:
room_id: 5
name: Group Chat Name
icon_path: https://example.com/ico_group.png
account:
account_id: 123
name: Bob
avatar_image_url: https://example.com/abc.png
assigned_by_account:
account_id: 456
name: Anna
avatar_image_url: https://example.com/def.png
message_id: 13
body: buy milk
limit_time: 1384354799
status: open
:description: "チャットのタスク一覧を取得 (※100件まで取得可能。今後、より多くのデータを取得する為のページネーションの仕組みを提供予定)"
:params:
- :name: account_id
:description: "タスクの担当者のアカウントID"
:body: ''
:choices:
:example: '101'
:type: :integer
:required: true
:list_type:
- :name: assigned_by_account_id
:description: "タスクの依頼者のアカウントID"
:body: ''
:choices:
:example: '78'
:type: :integer
:required: true
:list_type:
- :name: status
:description: "タスクのステータス"
:body: ''
:choices:
- open
- done
:example: done
:type: :string
:required: true
:list_type: :enum
- :verb: POST
:path: "/rooms/{room_id}/tasks"
:implemented: true
:code: 'curl -X POST -H "X-ChatWorkToken: 自分のAPIトークン" -d "body=Buy+milk&to_ids=1%2C3%2C6"
"https://api.chatwork.com/v1/rooms/{room_id}/tasks"'
:response:
task_ids:
- 123
- 124
:description: "チャットに新しいタスクを追加"
:params:
- :name: body
:description: "タスクの内容"
:body: ''
:choices:
:example: Buy milk
:type: :string
:required: false
:list_type:
- :name: limit
:description: "タスクの期限"
:body: ''
:choices:
:example:
:type: :integer
:required: true
:list_type:
- :name: to_ids
:description: "担当者のアカウントID"
:body: "担当者のアカウントIDをカンマ区切りで※リストはカンマ区切りで複数の値を指定してください"
:choices:
:example: '1,3,6'
:type: :integer
:required: false
:list_type: :list
- :verb: GET
:path: "/rooms/{room_id}/tasks/{task_id}"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/rooms/{room_id}/tasks/{task_id}"'
:response:
task_id: 3
account:
account_id: 123
name: Bob
avatar_image_url: https://example.com/abc.png
assigned_by_account:
account_id: 456
name: Anna
avatar_image_url: https://example.com/def.png
message_id: 13
body: buy milk
limit_time: 1384354799
status: open
:description: "タスク情報を取得"
:params: []
- :verb: GET
:path: "/rooms/{room_id}/files"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" -d "account_id=101" "https://api.chatwork.com/v1/rooms/{room_id}/files"'
:response:
- file_id: 3
account:
account_id: 123
name: Bob
avatar_image_url: https://example.com/ico_avatar.png
message_id: 22
filename: README.md
filesize: 2232
upload_time: 1384414750
:description: "チャットのファイル一覧を取得 (※100件まで取得可能。今後、より多くのデータを取得する為のページネーションの仕組みを提供予定)"
:params:
- :name: account_id
:description: "アップロードしたユーザーのアカウントID"
:body: ''
:choices:
:example: '101'
:type: :integer
:required: true
:list_type:
- :verb: GET
:path: "/rooms/{room_id}/files/{file_id}"
:implemented: true
:code: 'curl -X GET -H "X-ChatWorkToken: 自分のAPIトークン" "https://api.chatwork.com/v1/rooms/{room_id}/files/{file_id}"'
:response:
file_id: 3
account:
account_id: 123
name: Bob
avatar_image_url: https://example.com/ico_avatar.png
message_id: 22
filename: README.md
filesize: 2232
upload_time: 1384414750
:description: "ファイル情報を取得"
:params:
- :name: create_download_url
:description: "ダウンロードする為のURLを生成するか"
:body: 30秒間だけダウンロード可能なURLを生成します
:choices:
:example:
:type: :boolean
:required: true
:list_type:
# -*- coding: utf-8 -*-
require 'json'
require 'yaml'
require 'net/http'
require 'nokogiri'
module Generator
class ApiDocument
PATH = URI.parse('http://developer.chatwork.com/ja/endpoints.html')
def self.create(path=PATH)
new(Net::HTTP.get(path))
end
def initialize(raw_doc)
@raw_doc = raw_doc
end
def doc
@doc ||= Nokogiri.parse(@raw_doc)
end
def endpoints
@endpoints ||=
doc.search('a[href="endpoints.html"] + ul li a').
map { |a| EndPoint.create(PATH + a['href']) }
end
def inspect
"<ApiDocument:#{object_id} @endpoints=#{endpoints}>"
end
def to_h
{
endpoints: endpoints.map(&:to_h)
}
end
end
class EndPoint
def self.create(path)
new(Net::HTTP.get(path))
end
def initialize(raw_doc)
@raw_doc = raw_doc
end
def doc
@doc ||= Nokogiri.parse(@raw_doc)
end
def name
doc.at('div.mainContentInner h1').text.gsub(/^エンドポイント: /, '')
end
def description
doc.at('p.lead').text
end
def apis
@apis ||=
doc.search('div._apiDetailBox').
map { |div| Api.create(div) }
end
def inspect
"<EndPoint:#{object_id} @name=#{name} @description=#{description} @apis=#{apis}>"
end
def to_h
{
name: name,
description: description,
apis: apis.map(&:to_h)
}
end
end
class Api
def self.create(element)
new(element)
end
attr_reader :element
def initialize(element)
@element = element
end
def verb
element.at('header span').text
end
def path
element.at('header').children[1..-1].text.gsub(/未実装$/, '')
end
def implemented?
element.at('header span.boxHeadingNotimplemented').nil?
end
def code
element.at('div:nth-of-type(1) code').text
end
def response
response_element = element.at('div:nth-of-type(2) code')
response_element.nil? ? nil : JSON.parse(response_element.text)
end
def description
element.at('div:nth-of-type(3) p').text
end
def params
@params ||=
element.search('div:nth-of-type(4) tr').
map { |tr| Param.create(tr) }
end
def inspect
"<Api:#{object_id} @verb=#{verb} @path=#{path} @implemented=#{implemented?} @code=#{code} @response=#{response} @description=#{description} @params=#{params}>"
end
def to_h
{
verb: verb,
path: path,
implemented: implemented?,
code: code,
response: response,
description: description,
params: params.map(&:to_h)
}
end
end
class Param
def self.create(element)
new(element)
end
attr_reader :element
def initialize(element)
@element = element
end
def name
element.at('th.propertyLabel').children.first.text.strip
end
def description
element.at('td.propertyInfo p:nth-of-type(1)').text
end
def body
e = element.at('td.propertyInfo p:nth-of-type(1)')
str = ''
loop do
e = e.next
break if e.nil?
break if (e['class'] == 'example')
break if (e['class'] == 'enumTitle')
str << e.text.strip
end
str
end
def choices
return nil unless list_type == :enum
element.at('td.propertyInfo div.enum').text.split(',').
map { |e| e.strip }
end
def example
example_element = element.at('td.propertyInfo p.exampleContent')
example_element.nil? ? nil : example_element.text
end
def property
return @property if @property
property_element = element.search('span.propertyLabelTag')
@property = property_element.empty? ? nil : Property.create(property_element)
end
def type
property.type
end
def required?
property.required?
end
def list_type
property.list_type
end
def inspect
"#<Param:#{object_id} @name=#{name} @description=#{description} @body=#{body} @choices=#{choices} @example=#{example} @type=#{type} @required=#{required?} @list_type=#{list_type}>"
end
def to_h
{
name: name,
description: description,
body: body,
choices: choices,
example: example,
type: type,
required: required?,
list_type: list_type
}
end
end
class Property
def self.create(element)
new(element)
end
attr_reader :element
def initialize(element)
@element = element
end
def type
element.at('span.propertyLabelTagType').text.to_sym
end
def required?
element.at('span.propertyLabelTagRequired').nil?
end
def list_type
list_type_element = element.at('span.propertyLabelTagList')
return nil if list_type_element.nil?
case list_type_element.text
when 'リスト'
:list
when '列挙'
:enum
end
end
def inspect
"#<Property:#{object_id} @type=#{type}, @required=#{required?}, @list_type=#{list_type}>"
end
def to_h
{
type: type,
required: required,
list_type: list_type
}
end
end
end
if __FILE__ == $0
doc = Generator::ApiDocument.create
File.write('chatwork-api.json', JSON.pretty_generate(doc.to_h))
File.write('chatwork-api.yaml', doc.to_h.to_yaml)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment