Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Ry0taK

Ry0taK/fleet.md Secret

Last active December 3, 2023 16:27
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Ry0taK/005b79eccb4297469a09696dae9fa3c6 to your computer and use it in GitHub Desktop.
Save Ry0taK/005b79eccb4297469a09696dae9fa3c6 to your computer and use it in GitHub Desktop.

注意

このGistは、このブログ記事の解説中に使用するために公開されています。
ここに書かれている内容は既に動作しない可能性が高いです。

フリート機能のAPI

概要

このGistを書く数日前にTwitterでフリートと呼ばれる機能がリリースされていた。
フリートで遊んでいる際に、使用されているAPIがOAuth 1.0aを用いたリクエストをサポートしていることに気がついたのでGistにAPIドキュメントをまとめておく。(非公式クライアントの製作者がこれを読んでくれると嬉しいなと思いつつ)

認証

TwitterのAPIを叩く際に必要な手順と同じ (詳しくはTwitterの公式ドキュメントを参照)

ベースのURL

https://api.twitter.com

エンドポイント

ユーザーに紐付くフリート一覧取得

パス

GET /fleets/v1/user_fleets

パラメータ

パラメータ名
user_id フリートを作成したユーザーのID (例: 1114004787324805120)

権限

READ

レートリミット

180回/15分 (ユーザーごと)

リクエスト例

GET /fleets/v1/user_fleets?user_id=1195137762027962368 HTTP/1.1
Host: api.twitter.com
[認証用のヘッダ]

レスポンス例

{
   "fleet_threads":[
      {
         "active_mentions":[
            
         ],
         "active_mentions_str":[
            
         ],
         "active_participants":[
            1195137762027962368
         ],
         "active_participants_str":[
            "1195137762027962368"
         ],
         "all_mentions":[
            
         ],
         "all_mentions_str":[
            
         ],
         "all_participants":[
            1195137762027962368
         ],
         "all_participants_str":[
            "1195137762027962368"
         ],
         "created_at":"2020-11-12T10:07:22.400000000Z",
         "fleet_thread_id":"T1-328239591289021129",
         "fleets":[
            {
               "created_at":"2020-11-12T10:07:22.400000000Z",
               "deleted_at":null,
               "expiration":"2020-11-13T10:07:22.401900284Z",
               "fleet_id":"F1-328239591289086665",
               "fleet_thread_id":"T1-328239591289021129",
               "media_bounding_boxes":[
                  {
                     "anchor_point_x":0.5,
                     "anchor_point_y":0.5,
                     "width":0.17777778,
                     "height":0.045833334,
                     "rotation":0,
                     "entity":{
                        "type":"text",
                        "value":"Fleet"
                     }
                  }
               ],
               "media_entity":{
                  "additional_metadata":{
                     
                  },
                  "media_id":1326828925251588096,
                  "media_id_str":"1326828925251588096",
                  "media_info":{
                     
                  },
                  "media_key":{
                     "media_category":"TWEET_IMAGE",
                     "media_id":1326828925251588096,
                     "media_id_str":"1326828925251588096"
                  },
                  "media_url_https":"https://pbs.twimg.com/media/EmnX4K9VkAAGYpG.jpg",
                  "sizes":[
                     {
                        "size_type":"ORIG",
                        "width":1080,
                        "height":1920
                     },
                     {
                        "size_type":"LARGE",
                        "width":1080,
                        "height":1920
                     },
                     {
                        "size_type":"MEDIUM",
                        "width":675,
                        "height":1200
                     },
                     {
                        "size_type":"SMALL",
                        "width":383,
                        "height":680
                     },
                     {
                        "size_type":"THUMB",
                        "width":150,
                        "height":150
                     }
                  ]
               },
               "media_key":{
                  "media_category":"TWEET_IMAGE",
                  "media_id":1326828925251588096,
                  "media_id_str":"1326828925251588096"
               },
               "mentions":null,
               "mentions_str":null,
               "read":false,
               "text":"",
               "user_id":1195137762027962368,
               "user_id_str":"1195137762027962368"
            }
         ],
         "fully_read":false,
         "is_muted":false,
         "updated_at":"2020-11-12T10:07:22.400000000Z",
         "user_id":1195137762027962368,
         "user_id_str":"1195137762027962368"
      }
   ],
   "users":null,
   "is_muted":false
}

Fleetline(画面上部に表示されるFleet一覧)取得

パス

GET /fleets/v1/fleetline

パラメータ

無し

権限

READ

レートリミット

100回/15分 (ユーザーごと)

リクエスト例

GET /fleets/v1/fleetline HTTP/1.1
Host: api.twitter.com
[認証用のヘッダ]

レスポンス例

{
   "threads":[
      {
         "fully_read":false,
         "mentions":[
            
         ],
         "mentions_str":[
            
         ],
         "participants":[
            1195137762027962368
         ],
         "participants_str":[
            "1195137762027962368"
         ],
         "thread_id":"T1-328239591289021129",
         "user_id":1195137762027962368,
         "user_id_str":"1195137762027962368"
      },
      {
         "fully_read":false,
         "mentions":[
            
         ],
         "mentions_str":[
            
         ],
         "participants":[
            783214
         ],
         "participants_str":[
            "783214"
         ],
         "thread_id":"T1-v0-ja",
         "user_id":783214,
         "user_id_str":"783214"
      }
   ],
   "hydrated_threads":[
      {
         "active_mentions":[
            
         ],
         "active_mentions_str":[
            
         ],
         "active_participants":[
            1195137762027962368
         ],
         "active_participants_str":[
            "1195137762027962368"
         ],
         "all_mentions":[
            
         ],
         "all_mentions_str":[
            
         ],
         "all_participants":[
            1195137762027962368
         ],
         "all_participants_str":[
            "1195137762027962368"
         ],
         "created_at":"2020-11-12T10:07:22.400000000Z",
         "fleet_thread_id":"T1-328239591289021129",
         "fleets":[
            {
               "created_at":"2020-11-12T10:07:22.400000000Z",
               "deleted_at":null,
               "expiration":"2020-11-13T10:07:22.401900284Z",
               "fleet_id":"F1-328239591289086665",
               "fleet_thread_id":"T1-328239591289021129",
               "media_bounding_boxes":[
                  {
                     "anchor_point_x":0.5,
                     "anchor_point_y":0.5,
                     "width":0.17777778,
                     "height":0.045833334,
                     "rotation":0,
                     "entity":{
                        "type":"text",
                        "value":"Fleet"
                     }
                  }
               ],
               "media_entity":{
                  "additional_metadata":{
                     
                  },
                  "media_id":1326828925251588096,
                  "media_id_str":"1326828925251588096",
                  "media_info":{
                     
                  },
                  "media_key":{
                     "media_category":"TWEET_IMAGE",
                     "media_id":1326828925251588096,
                     "media_id_str":"1326828925251588096"
                  },
                  "media_url_https":"https://pbs.twimg.com/media/EmnX4K9VkAAGYpG.jpg",
                  "sizes":[
                     {
                        "size_type":"ORIG",
                        "width":1080,
                        "height":1920
                     },
                     {
                        "size_type":"LARGE",
                        "width":1080,
                        "height":1920
                     },
                     {
                        "size_type":"MEDIUM",
                        "width":675,
                        "height":1200
                     },
                     {
                        "size_type":"SMALL",
                        "width":383,
                        "height":680
                     },
                     {
                        "size_type":"THUMB",
                        "width":150,
                        "height":150
                     }
                  ]
               },
               "media_key":{
                  "media_category":"TWEET_IMAGE",
                  "media_id":1326828925251588096,
                  "media_id_str":"1326828925251588096"
               },
               "mentions":null,
               "mentions_str":null,
               "read":false,
               "text":"",
               "user_id":1195137762027962368,
               "user_id_str":"1195137762027962368"
            }
         ],
         "fully_read":false,
         "is_muted":false,
         "updated_at":"2020-11-12T10:07:22.400000000Z",
         "user_id":1195137762027962368,
         "user_id_str":"1195137762027962368"
      },
      {
         "active_mentions":[
            
         ],
         "active_mentions_str":[
            
         ],
         "active_participants":[
            783214
         ],
         "active_participants_str":[
            "783214"
         ],
         "all_mentions":null,
         "all_mentions_str":null,
         "all_participants":[
            783214
         ],
         "all_participants_str":[
            "783214"
         ],
         "created_at":"2020-11-12T10:04:20.769918422Z",
         "fleet_thread_id":"T1-v0-ja",
         "fleets":[
            {
               "created_at":"2020-11-12T10:04:20.769918422Z",
               "deleted_at":null,
               "expiration":"2020-11-13T10:04:20.769918422Z",
               "fleet_id":"FTUT-v0-327857329737327308",
               "fleet_thread_id":"T1-v0-ja",
               "media_entity":{
                  "additional_metadata":{
                     
                  },
                  "media_id":1325867258434891777,
                  "media_id_str":"1325867258434891777",
                  "media_info":{
                     "video_info":{
                        "duration_millis":24491,
                        "aspect_ratio":{
                           "numerator":9,
                           "denominator":16
                        },
                        "variants":[
                           {
                              "url":"https://video.twimg.com/ext_tw_video/1325867258434891777/pu/pl/rmp3cQgGGD7qvr9V.m3u8?tag=10",
                              "content_type":"application/x-mpegURL"
                           },
                           {
                              "url":"https://video.twimg.com/ext_tw_video/1325867258434891777/pu/vid/320x568/4ki4yTcNh3xDMZyq.mp4?tag=10",
                              "content_type":"video/mp4",
                              "bit_rate":632000
                           },
                           {
                              "url":"https://video.twimg.com/ext_tw_video/1325867258434891777/pu/vid/360x640/80_qnvV6u2VnxfzR.mp4?tag=10",
                              "content_type":"video/mp4",
                              "bit_rate":832000
                           },
                           {
                              "url":"https://video.twimg.com/ext_tw_video/1325867258434891777/pu/vid/720x1280/VdWCeVfYVzVBeJhY.mp4?tag=10",
                              "content_type":"video/mp4",
                              "bit_rate":2176000
                           }
                        ]
                     }
                  },
                  "media_key":{
                     "media_category":"TWEET_VIDEO",
                     "media_id":1325867258434891777,
                     "media_id_str":"1325867258434891777"
                  },
                  "media_url_https":"https://pbs.twimg.com/ext_tw_video_thumb/1325867258434891777/pu/img/ttu9L9fcZ8CYUju9.jpg",
                  "sizes":[
                     {
                        "size_type":"ORIG",
                        "width":720,
                        "height":1280
                     },
                     {
                        "size_type":"LARGE",
                        "width":720,
                        "height":1280
                     },
                     {
                        "size_type":"MEDIUM",
                        "width":675,
                        "height":1200
                     },
                     {
                        "size_type":"SMALL",
                        "width":383,
                        "height":680
                     },
                     {
                        "size_type":"THUMB",
                        "width":150,
                        "height":150
                     }
                  ]
               },
               "media_key":{
                  "media_category":"TWEET_VIDEO",
                  "media_id":1325867258434891777,
                  "media_id_str":"1325867258434891777"
               },
               "mentions":null,
               "mentions_str":null,
               "read":false,
               "text":"",
               "user_id":783214,
               "user_id_str":"783214"
            }
         ],
         "fully_read":false,
         "is_feature_highlight":true,
         "is_muted":false,
         "updated_at":"2020-11-09T18:49:56.760000000Z",
         "user_id":783214,
         "user_id_str":"783214"
      }
   ],
   "refresh_delay_secs":300
}

スレッドに紐付くフリート一覧取得

パス

GET /fleets/v1/fleet_threads

パラメータ

パラメータ名
thread_ids コンマ区切りのスレッドID一覧 (例: T1-328239591289021129,T1-328239591289021129)

権限

READ

レートリミット

1000回/15分 (ユーザーごと)

リクエスト例

GET /fleets/v1/fleet_threads?thread_ids=T1-328239591289021129 HTTP/1.1
Host: api.twitter.com
[認証用のヘッダ]

レスポンス例

{
   "fleet_threads":[
      {
         "active_mentions":[
            
         ],
         "active_mentions_str":[
            
         ],
         "active_participants":[
            1195137762027962368
         ],
         "active_participants_str":[
            "1195137762027962368"
         ],
         "all_mentions":[
            
         ],
         "all_mentions_str":[
            
         ],
         "all_participants":[
            1195137762027962368
         ],
         "all_participants_str":[
            "1195137762027962368"
         ],
         "created_at":"2020-11-12T10:07:22.400000000Z",
         "fleet_thread_id":"T1-328239591289021129",
         "fleets":[
            {
               "created_at":"2020-11-12T10:07:22.400000000Z",
               "deleted_at":null,
               "expiration":"2020-11-13T10:07:22.401900284Z",
               "fleet_id":"F1-328239591289086665",
               "fleet_thread_id":"T1-328239591289021129",
               "media_bounding_boxes":[
                  {
                     "anchor_point_x":0.5,
                     "anchor_point_y":0.5,
                     "width":0.17777778,
                     "height":0.045833334,
                     "rotation":0,
                     "entity":{
                        "type":"text",
                        "value":"Fleet"
                     }
                  }
               ],
               "media_entity":{
                  "additional_metadata":{
                     
                  },
                  "media_id":1326828925251588096,
                  "media_id_str":"1326828925251588096",
                  "media_info":{
                     
                  },
                  "media_key":{
                     "media_category":"TWEET_IMAGE",
                     "media_id":1326828925251588096,
                     "media_id_str":"1326828925251588096"
                  },
                  "media_url_https":"https://pbs.twimg.com/media/EmnX4K9VkAAGYpG.jpg",
                  "sizes":[
                     {
                        "size_type":"ORIG",
                        "width":1080,
                        "height":1920
                     },
                     {
                        "size_type":"LARGE",
                        "width":1080,
                        "height":1920
                     },
                     {
                        "size_type":"MEDIUM",
                        "width":675,
                        "height":1200
                     },
                     {
                        "size_type":"SMALL",
                        "width":383,
                        "height":680
                     },
                     {
                        "size_type":"THUMB",
                        "width":150,
                        "height":150
                     }
                  ]
               },
               "media_key":{
                  "media_category":"TWEET_IMAGE",
                  "media_id":1326828925251588096,
                  "media_id_str":"1326828925251588096"
               },
               "mentions":null,
               "mentions_str":null,
               "read":false,
               "text":"",
               "user_id":1195137762027962368,
               "user_id_str":"1195137762027962368"
            }
         ],
         "fully_read":false,
         "is_muted":false,
         "updated_at":"2020-11-12T10:07:22.400000000Z",
         "user_id":1195137762027962368,
         "user_id_str":"1195137762027962368"
      }
   ]
}

フリートに既読をつけたユーザー一覧取得

パス

GET /fleets/v1/viewers

パラメーター

パラメーター名
fleet_id フリートのID (例: F1-328239591289086665)

権限

READ

レートリミット

100回/15分 (ユーザーごと)

リクエスト例

GET /fleets/v1/viewers?fleet_id=F1-328239591289086665 HTTP/1.1
Host: api.twitter.com
[認証用のヘッダ]

レスポンス例

{
   "user_ids":[
      1114004787324805120
   ],
   "user_ids_str":[
      "1114004787324805120"
   ],
   "view_count":1
}

フリートをミュートしているユーザー一覧取得

※正常に動作していない可能性あり

パス

GET /fleets/v1/mutes/list

パラメータ

無し

権限

READ

レートリミット

100回/15分 (ユーザーごと)

リクエスト例

GET /fleets/v1/mutes/list HTTP/1.1
Host: api.twitter.com
[認証用のヘッダ]

レスポンス例

{
   "user_ids":[
      
   ],
   "user_ids_str":[
      
   ]
}

フリートの作成

パス

POST /fleets/v1/create

Content-Type

application/json

パラメータ

パラメータ名 必須
text 画面中央に表示されるテキスト(例: "Fleet") 文字列
media_id 背景に設定されるメディアID 数値
media_bounding_boxes テキストの場所などをしていするオブジェクト(詳しくは下記リクエスト例を参照) オブジェクト
fleet_thread_id フリートを作成するスレッドID、他人のものは指定不可 (例: "T1-328245785034515145") 文字列
nonce 多重送信を防ぐための一意の数値 (例: 12345) 数値
overlay_text わからんけど必須じゃない

権限

WRITE

レートリミット

明示的な指定は無し、作成しすぎると凍結される恐れあり。

リクエスト例

POST /fleets/v1/create HTTP/1.1
Host: api.twitter.com
Content-Type: application/json
[認証用のヘッダ]

{"text":"Fleet","media_id":1301884549740126208,"fleet_thread_id":"T1-328245785034515145","media_bounding_boxes":[{"anchor_point_x":0.5,"anchor_point_y":0.5,"width":0.17777778,"height":0.045833334,"rotation":0,"entity":{"type":"text","value":"Fleeet"}}]}

レスポンス例

{
   "fleet":{
      "created_at":"2020-11-12T11:22:54.680000000Z",
      "deleted_at":null,
      "expiration":"2020-11-13T11:22:54.687562869Z",
      "fleet_id":"F1-328247195193074463",
      "fleet_thread_id":"T1-328245785034515145",
      "media_bounding_boxes":[
         {
            "anchor_point_x":0.5,
            "anchor_point_y":0.5,
            "width":0.17777778,
            "height":0.045833334,
            "rotation":0,
            "entity":{
               "type":"text",
               "value":"Fleeet"
            }
         }
      ],
      "media_entity":{
         "additional_metadata":{
            "color_info":{
               "palette":[
                  {
                     "rgb":{
                        "red":247,
                        "green":219,
                        "blue":171
                     },
                     "percentage":40.86
                  },
                  {
                     "rgb":{
                        "red":127,
                        "green":130,
                        "blue":161
                     },
                     "percentage":33.13
                  },
                  {
                     "rgb":{
                        "red":132,
                        "green":114,
                        "blue":99
                     },
                     "percentage":15.19
                  },
                  {
                     "rgb":{
                        "red":128,
                        "green":179,
                        "blue":160
                     },
                     "percentage":6.37
                  },
                  {
                     "rgb":{
                        "red":249,
                        "green":249,
                        "blue":250
                     },
                     "percentage":3.7
                  }
               ]
            }
         },
         "media_id":1301884549740126208,
         "media_id_str":"1301884549740126208",
         "media_info":{
            "image_info":{
               
            }
         },
         "media_key":{
            "media_category":"TWEET_IMAGE",
            "media_id":1301884549740126208,
            "media_id_str":"1301884549740126208"
         },
         "media_url_https":"https://pbs.twimg.com/media/EhE5Ga3UYAAw26p.jpg",
         "sizes":[
            {
               "size_type":"ORIG",
               "width":1600,
               "height":1600
            },
            {
               "size_type":"LARGE",
               "width":1600,
               "height":1600
            },
            {
               "size_type":"MEDIUM",
               "width":1200,
               "height":1200
            },
            {
               "size_type":"SMALL",
               "width":680,
               "height":680
            },
            {
               "size_type":"THUMB",
               "width":150,
               "height":150
            }
         ]
      },
      "media_key":{
         "media_category":"TWEET_IMAGE",
         "media_id":1301884549740126208,
         "media_id_str":"1301884549740126208"
      },
      "mentions":null,
      "mentions_str":null,
      "read":false,
      "text":"Fleet",
      "user_id":1283531182617923585,
      "user_id_str":"1283531182617923585"
   },
   "fleet_thread_id":"T1-328245785034515145",
   "fleet_id":"F1-328247195193074463",
   "users":null
}

フリートに既読をつける

パス

POST /fleets/v1/mark_read

Content-Type

application/json

パラメータ

パラメータ名 必須
fleet_ids 既読をつけるフリートのID一覧(例: ["F1-328248544165194472"]) 配列

権限

WRITE

レートリミット

明示的な指定は無し、作成しすぎると凍結される恐れあり。

リクエスト例

POST /fleets/v1/mark_read HTTP/1.1
Host: api.twitter.com
Content-Type: application/json
[認証用のヘッダ]

{"fleet_ids":["F1-328248544165194472"]}

レスポンス例

"success"

フリートを削除する

パス

POST /fleets/v1/delete

Content-Type

application/json

パラメータ

パラメータ名 必須
fleet_ids 削除するフリートのID一覧(例: ["F1-328248544165194472"]) 配列

権限

WRITE

レートリミット

明示的な指定は無し、作成しすぎると凍結される恐れあり。

リクエスト例

POST /fleets/v1/delete HTTP/1.1
Host: api.twitter.com
Content-Type: application/json
[認証用のヘッダ]
 
{"fleet_ids":["F1-328248544165194472"]}

レスポンス例

"success"

特定のユーザーのフリートをミュート

※正常に動作していない可能性あり

パス

POST /fleets/v1/mutes/create

Content-Type

application/json

パラメータ

パラメータ名 必須
user_id ミュートするユーザーのID(例: 1114004787324805120) 数値

権限

WRITE

レートリミット

明示的な指定は無し

リクエスト例

POST /fleets/v1/mutes/create HTTP/1.1
Host: api.twitter.com
[認証用のヘッダ]

{"user_id":783214}

レスポンス例

"success"

フリートのミュートを解除

※正常に動作していない可能性あり

パス

POST /fleets/v1/mutes/destroy

Content-Type

application/json

パラメータ

パラメータ名 必須
user_id ミュートを解除するユーザーのID(例: 1114004787324805120) 数値

権限

WRITE

レートリミット

明示的な指定は無し

リクエスト例

POST /fleets/v1/mutes/destroy HTTP/1.1
Host: api.twitter.com
[認証用のヘッダ]

{"user_id":783214}

レスポンス例

"success"

トラッキング用エンドポイント

Twitterアプリがユーザーの操作をトラッキングするためのエンドポイント、ドキュメント化する必要がなさそうなので割愛。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment