From b2fa9766a0a384c96ddc6e820f8fe00fb6a587cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Thu, 13 Apr 2023 00:10:21 +0900 Subject: [PATCH] add api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- openapi/openapi-3.0.yaml | 80 ++++++++++++++++++- openapi/src/components/schemas/Timeline.yaml | 66 +++++++++++++++ openapi/src/components/schemas/User.yaml | 9 ++- openapi/src/paths/follow/Followers.yaml | 2 + openapi/src/paths/follow/Following.yaml | 3 + .../paths/timeline/HomeLatestTimeline.yaml | 59 ++++++++++++++ openapi/src/paths/timeline/HomeTimeline.yaml | 78 +++++++++--------- .../timeline/ListLatestTweetsTimeline.yaml | 59 ++++++++++++++ 8 files changed, 309 insertions(+), 47 deletions(-) create mode 100644 openapi/src/components/schemas/Timeline.yaml create mode 100644 openapi/src/paths/timeline/HomeLatestTimeline.yaml create mode 100644 openapi/src/paths/timeline/ListLatestTweetsTimeline.yaml diff --git a/openapi/openapi-3.0.yaml b/openapi/openapi-3.0.yaml index 22df567..31fbba2 100644 --- a/openapi/openapi-3.0.yaml +++ b/openapi/openapi-3.0.yaml @@ -2,21 +2,95 @@ openapi: 3.0.3 info: title: Twitter OpenAPI description: |- - Twitter OpenAPI + Twitter OpenAPI(Swagger) specification termsOfService: https://github.com/fa0311 contact: email: yuki@yuki0311.com license: - name: other - url: https://github.com/fa0311/twitter-openapi/LICENSE + name: GNU Affero General Public License v3. + url: https://raw.githubusercontent.com/fa0311/twitter-openapi/main/LICENSE.txt version: 0.0.1 servers: - url: https://twitter.com/i/api/graphql paths: + # timeline /BntFPEOxs3GYdPaS6CjUcg/HomeTimeline: $ref: ./src/paths/timeline/HomeTimeline.yaml + /37RUvMgTiEVYYfrRTVDxpw/HomeLatestTimeline: + $ref: ./src/paths/timeline/HomeLatestTimeline.yaml + /VEwO8c1TYdm5zjxCOIiwFw/ListLatestTweetsTimeline: + $ref: ./src/paths/timeline/ListLatestTweetsTimeline.yaml + # follow /FaBzCqZXuQCb4PhB0RHqHw/Following: $ref: ./src/paths/follow/Following.yaml /VptSi88PiaQhBevFbGVlGg/Followers: $ref: ./src/paths/follow/Followers.yaml + +components: + securitySchemes: + BearerAuth: + type: http + scheme: bearer + description: "AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA" + + CsrfToken: + type: apiKey + in: header + name: x-csrf-token + + ActiveUser: + type: apiKey + in: header + name: x-twitter-active-user + description: "yes" + + AuthType: + type: apiKey + in: header + name: x-twitter-auth-type + description: "OAuth2Session" + + ClientLanguage: + type: apiKey + in: header + name: x-twitter-client-language + description: "en" + + CookieAuthToken: + type: apiKey + in: cookie + name: auth_token + + CookieAuthCt0: + type: apiKey + in: cookie + name: ct0 + +tags: + - name: timeline + description: timeline + - name: tweet + description: tweet + - name: user + description: user + - name: follow + description: follow + - name: search + description: search + - name: dm + description: dm + - name: settings + description: settings + - name: notify + description: notify + + # === + - name: login required + description: login session required + - name: graphql + description: graphql + - name: login-flow + description: login flow + - name: report-flow + description: report flow diff --git a/openapi/src/components/schemas/Timeline.yaml b/openapi/src/components/schemas/Timeline.yaml new file mode 100644 index 0000000..956c20a --- /dev/null +++ b/openapi/src/components/schemas/Timeline.yaml @@ -0,0 +1,66 @@ +TimelineResponse: + required: + - "data" + properties: + data: + $ref: "#/HomeTimelineData" + +HomeTimelineData: + required: + - "home" + properties: + home: + $ref: "#/HomeTimelineHome" + +HomeTimelineHome: + required: + - "home_timeline_urt" + properties: + home_timeline_urt: + $ref: "#/HomeTimelineUrt" + +# ====== + +ListTweetsTimelineResponse: + required: + - "data" + properties: + data: + $ref: "#/ListTweetsTimelineData" + +ListTweetsTimelineData: + required: + - "list" + properties: + home: + $ref: "#/ListTweetsTimelineList" + +ListTweetsTimelineList: + required: + - "tweets_timeline" + properties: + tweets_timeline: + $ref: "#/ListTweetsTimeline" + +ListTweetsTimeline: + required: + - "timeline" + properties: + timeline: + $ref: "#/HomeTimelineUrt" + +# ====== + +HomeTimelineUrt: + required: + - "instructions" + - "metadata" + properties: + instructions: + type: array + items: + $ref: "./Instruction.yaml#/InstructionUnion" + metadata: + type: object # todo + responseObjects: + type: object # todo diff --git a/openapi/src/components/schemas/User.yaml b/openapi/src/components/schemas/User.yaml index 31a5605..73201f8 100644 --- a/openapi/src/components/schemas/User.yaml +++ b/openapi/src/components/schemas/User.yaml @@ -75,10 +75,8 @@ UserLegacy: - "has_custom_timelines" - "is_translator" - "listed_count" - - "location" - "media_count" - "muting" - - "name" - "normal_followers_count" - "notifications" - "pinned_tweet_ids_str" @@ -120,6 +118,7 @@ UserLegacy: type: integer favourites_count: type: integer + default: 0 follow_request_sent: type: boolean default: false @@ -128,11 +127,13 @@ UserLegacy: default: false followers_count: type: integer + default: 0 following: type: boolean default: false friends_count: type: integer + default: 0 has_custom_timelines: type: boolean default: false @@ -141,10 +142,12 @@ UserLegacy: default: false listed_count: type: integer + default: 0 location: type: string media_count: type: integer + default: 0 muting: type: boolean default: false @@ -152,6 +155,7 @@ UserLegacy: type: string normal_followers_count: type: integer + default: 0 notifications: type: boolean default: false @@ -179,6 +183,7 @@ UserLegacy: type: string statuses_count: type: integer + default: 0 translator_type: type: string url: diff --git a/openapi/src/paths/follow/Followers.yaml b/openapi/src/paths/follow/Followers.yaml index 2e60c0f..ca92327 100644 --- a/openapi/src/paths/follow/Followers.yaml +++ b/openapi/src/paths/follow/Followers.yaml @@ -24,3 +24,5 @@ get: responses: "200": description: Successful operation + tags: + - "follow" diff --git a/openapi/src/paths/follow/Following.yaml b/openapi/src/paths/follow/Following.yaml index 6a13aba..a838a59 100644 --- a/openapi/src/paths/follow/Following.yaml +++ b/openapi/src/paths/follow/Following.yaml @@ -24,3 +24,6 @@ get: responses: "200": description: Successful operation + + tags: + - "follow" diff --git a/openapi/src/paths/timeline/HomeLatestTimeline.yaml b/openapi/src/paths/timeline/HomeLatestTimeline.yaml new file mode 100644 index 0000000..1910b0b --- /dev/null +++ b/openapi/src/paths/timeline/HomeLatestTimeline.yaml @@ -0,0 +1,59 @@ +get: + operationId: getHomeLatestTimeline + description: get tweet list of timeline + parameters: + - name: variables + in: query + required: true + schema: + type: string + example: '''{ + "count":20, + "includePromotedContent":true, + "latestControlAvailable":true, + "requestContext":"launch", + "withDownvotePerspective":false + }''' + - name: features + in: query + required: true + schema: + type: string + example: '''{ + "blue_business_profile_image_shape_enabled":true, + "responsive_web_graphql_exclude_directive_enabled":true, + "verified_phone_label_enabled":false, + "responsive_web_graphql_timeline_navigation_enabled":true, + "responsive_web_graphql_skip_user_profile_image_extensions_enabled":false, + "tweetypie_unmention_optimization_enabled":true, + "vibe_api_enabled":true, + "responsive_web_edit_tweet_api_enabled":true, + "graphql_is_translatable_rweb_tweet_is_translatable_enabled":true, + "view_counts_everywhere_api_enabled":true, + "longform_notetweets_consumption_enabled":true, + "tweet_awards_web_tipping_enabled":false, + "freedom_of_speech_not_reach_fetch_enabled":false, + "standardized_nudges_misinfo":true, + "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled":false, + "interactive_text_enabled":true, + "responsive_web_text_conversations_enabled":false, + "longform_notetweets_rich_text_read_enabled":true, + "responsive_web_enhance_cards_enabled":false + }''' + - name: queryId + in: query + required: true + schema: + type: string + default: "37RUvMgTiEVYYfrRTVDxpw" + example: "'37RUvMgTiEVYYfrRTVDxpw'" + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: "./../../components/schemas/Timeline.yaml#/TimelineResponse" + tags: + - "timeline" + - "login-required" diff --git a/openapi/src/paths/timeline/HomeTimeline.yaml b/openapi/src/paths/timeline/HomeTimeline.yaml index 472d5e5..3953cbf 100644 --- a/openapi/src/paths/timeline/HomeTimeline.yaml +++ b/openapi/src/paths/timeline/HomeTimeline.yaml @@ -7,62 +7,56 @@ get: required: true schema: type: string - + example: '''{ + "count": 20, + "includePromotedContent": true, + "latestControlAvailable": true, + "requestContext": "launch", + "withCommunity": true, + "withDownvotePerspective": false, + "withReactionsMetadata": false, + "withReactionsPerspective": false + }''' - name: features in: query required: true schema: type: string - + example: '''{ + "blue_business_profile_image_shape_enabled": true, + "responsive_web_graphql_exclude_directive_enabled": true, + "verified_phone_label_enabled": false, + "responsive_web_graphql_timeline_navigation_enabled": true, + "responsive_web_graphql_skip_user_profile_image_extensions_enabled": false, + "tweetypie_unmention_optimization_enabled": true, + "vibe_api_enabled": true, + "responsive_web_edit_tweet_api_enabled": true, + "graphql_is_translatable_rweb_tweet_is_translatable_enabled": true, + "view_counts_everywhere_api_enabled": true, + "longform_notetweets_consumption_enabled": true, + "tweet_awards_web_tipping_enabled": false, + "freedom_of_speech_not_reach_fetch_enabled": false, + "standardized_nudges_misinfo": true, + "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": false, + "interactive_text_enabled": true, + "responsive_web_text_conversations_enabled": false, + "longform_notetweets_richtext_consumption_enabled": true, + "responsive_web_enhance_cards_enabled": false + }''' - name: queryId in: query required: true schema: type: string default: "BntFPEOxs3GYdPaS6CjUcg" - + example: "'BntFPEOxs3GYdPaS6CjUcg'" responses: "200": description: Successful operation content: application/json: schema: - $ref: "#/components/schemas/HomeTimelineResponse" - -components: - schemas: - HomeTimelineResponse: - required: - - "data" - properties: - data: - $ref: "#/components/schemas/HomeTimelineData" - - HomeTimelineData: - required: - - "home" - properties: - home: - $ref: "#/components/schemas/HomeTimelineHome" - - HomeTimelineHome: - required: - - "home_timeline_urt" - properties: - home_timeline_urt: - $ref: "#/components/schemas/HomeTimelineUrt" - - HomeTimelineUrt: - required: - - "instructions" - - "metadata" - - "responseObjects" - properties: - instructions: - type: array - items: - $ref: "./../../components/schemas/Instruction.yaml#/InstructionUnion" - metadata: - type: object # todo - responseObjects: - type: object # todo + $ref: "./../../components/schemas/Timeline.yaml#/TimelineResponse" + tags: + - "timeline" + - "login-required" diff --git a/openapi/src/paths/timeline/ListLatestTweetsTimeline.yaml b/openapi/src/paths/timeline/ListLatestTweetsTimeline.yaml new file mode 100644 index 0000000..dae6ba5 --- /dev/null +++ b/openapi/src/paths/timeline/ListLatestTweetsTimeline.yaml @@ -0,0 +1,59 @@ +get: + operationId: getListLatestTweetsTimeline + description: get tweet list of timeline + parameters: + - name: variables + in: query + required: true + schema: + type: string + example: ''' + { + "listId":"000000000000", + "count":20, + "withDownvotePerspective":false + }''' + - name: features + in: query + required: true + schema: + type: string + example: ''' + { + "blue_business_profile_image_shape_enabled": true, + "responsive_web_graphql_exclude_directive_enabled": true, + "verified_phone_label_enabled": false, + "responsive_web_graphql_timeline_navigation_enabled": true, + "responsive_web_graphql_skip_user_profile_image_extensions_enabled": false, + "tweetypie_unmention_optimization_enabled": true, + "vibe_api_enabled": true, + "responsive_web_edit_tweet_api_enabled": true, + "graphql_is_translatable_rweb_tweet_is_translatable_enabled": true, + "view_counts_everywhere_api_enabled": true, + "longform_notetweets_consumption_enabled": true, + "tweet_awards_web_tipping_enabled": false, + "freedom_of_speech_not_reach_fetch_enabled": false, + "standardized_nudges_misinfo": true, + "tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": false, + "interactive_text_enabled": true, + "responsive_web_text_conversations_enabled": false, + "longform_notetweets_rich_text_read_enabled": true, + "responsive_web_enhance_cards_enabled": false, + }''' + - name: queryId + in: query + required: true + schema: + type: string + default: "VEwO8c1TYdm5zjxCOIiwFw" + example: "'VEwO8c1TYdm5zjxCOIiwFw'" + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: "./../../components/schemas/Timeline.yaml#/ListTweetsTimelineResponse" + tags: + - "timeline" + - "login-required"