{
  "openapi": "3.0.3",
  "info": {
    "title": "Twitter API Aggregated Documentation",
    "version": "1.0.0",
    "description": "This OpenAPI specification aggregates multiple Twitter API endpoints into a single document."
  },
  "servers": [
    {
      "url": "https://api.aisa.one/apis/v1"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "TweetThreadContextResponse": {
        "type": "object",
        "properties": {
          "has_next_page": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "success",
              "error"
            ]
          },
          "tweets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Tweet"
            }
          },
          "msg": {
            "type": "string"
          }
        }
      },
      "Tweet": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "retweetCount": {
            "type": "integer"
          },
          "replyCount": {
            "type": "integer"
          },
          "likeCount": {
            "type": "integer"
          },
          "quoteCount": {
            "type": "integer"
          },
          "viewCount": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string"
          },
          "lang": {
            "type": "string"
          },
          "bookmarkCount": {
            "type": "integer"
          },
          "isReply": {
            "type": "boolean"
          },
          "inReplyToId": {
            "type": "string"
          },
          "conversationId": {
            "type": "string"
          },
          "displayTextRange": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "inReplyToUserId": {
            "type": "string"
          },
          "inReplyToUsername": {
            "type": "string"
          },
          "author": {
            "$ref": "#/components/schemas/User"
          },
          "entities": {
            "$ref": "#/components/schemas/Entities"
          },
          "quoted_tweet": {
            "type": "string"
          },
          "retweeted_tweet": {
            "type": "string"
          },
          "isLimitedReply": {
            "type": "boolean"
          }
        }
      },
      "User": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "userName": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "isBlueVerified": {
            "type": "boolean"
          },
          "verifiedType": {
            "type": "string"
          },
          "profilePicture": {
            "type": "string"
          },
          "coverPicture": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "location": {
            "type": "string"
          },
          "followers": {
            "type": "integer"
          },
          "following": {
            "type": "integer"
          },
          "canDm": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          },
          "favouritesCount": {
            "type": "integer"
          },
          "hasCustomTimelines": {
            "type": "boolean"
          },
          "isTranslator": {
            "type": "boolean"
          },
          "mediaCount": {
            "type": "integer"
          },
          "statusesCount": {
            "type": "integer"
          },
          "withheldInCountries": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "possiblySensitive": {
            "type": "boolean"
          },
          "pinnedTweetIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "isAutomated": {
            "type": "boolean"
          },
          "automatedBy": {
            "type": "string"
          },
          "unavailable": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "unavailableReason": {
            "type": "string"
          }
        }
      },
      "Entities": {
        "type": "object",
        "properties": {
          "hashtags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "indices": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  }
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "urls": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "display_url": {
                  "type": "string"
                },
                "expanded_url": {
                  "type": "string"
                },
                "indices": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  }
                },
                "url": {
                  "type": "string"
                }
              }
            }
          },
          "user_mentions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id_str": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "screen_name": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ArticleResponse": {
        "type": "object",
        "properties": {
          "article": {
            "$ref": "#/components/schemas/Article",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "success",
              "failed"
            ]
          },
          "msg": {
            "type": "string"
          }
        }
      },
      "Article": {
        "type": "object",
        "properties": {
          "author": {
            "$ref": "#/components/schemas/User"
          },
          "replyCount": {
            "type": "integer"
          },
          "likeCount": {
            "type": "integer"
          },
          "quoteCount": {
            "type": "integer"
          },
          "viewCount": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "preview_text": {
            "type": "string"
          },
          "cover_media_img_url": {
            "type": "string"
          },
          "contents": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "AdvancedSearchResponse": {
        "type": "object",
        "properties": {
          "tweets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Tweet"
            }
          },
          "has_next_page": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string"
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/twitter/tweet/thread_context": {
      "get": {
        "x-aisa-pricing": {
          "model": "dynamic",
          "currency": "USD",
          "basis": "provider_cost x 2",
          "nominal_usd": 0.007,
          "observed_usd": {
            "min": 0.00015,
            "p50": 0.007,
            "p95": 0.007,
            "max": 0.0111
          },
          "cost_drivers": [
            {
              "param": "result count",
              "effect": "charge scales with number of tweets/users returned"
            }
          ],
          "cost_tier": "variable",
          "note": "nominal_usd is a static reference, NOT a guaranteed minimum; actual charge = provider_cost x multiplier and can be higher or lower"
        },
        "tags": [
          "https://docs.twitterapi.io/api-reference/endpoint/get_tweet_thread_context"
        ],
        "summary": "Get Tweet Thread Context",
        "operationId": "get_twitter_tweet_thread_context",
        "description": "Reconstruct the conversation around a tweet. Accepts either a reply or an original tweet and returns the surrounding thread, cursor-paginated. Use this when a tweet lacks context on its own and you need the parent chain to interpret it correctly. Returns tweets under `tweets` with `has_next_page` and `next_cursor`. For only the replies below a post use `get_twitter_tweet_replies_v2`.",
        "parameters": [
          {
            "name": "tweetId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The tweet ID to get. Can be a reply tweet or an original tweet."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The cursor to paginate through the results. First page is empty."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TweetThreadContextResponse"
                }
              }
            }
          }
        }
      }
    },
    "/twitter/article": {
      "get": {
        "x-aisa-pricing": {
          "model": "dynamic",
          "currency": "USD",
          "basis": "provider_cost x 1",
          "nominal_usd": 0.0022,
          "observed_usd": {
            "min": 0.001,
            "p50": 0.0022,
            "p95": 0.0022,
            "max": 0.0022
          },
          "cost_drivers": [
            {
              "param": "result count",
              "effect": "charge scales with number of tweets/users returned"
            }
          ],
          "cost_tier": "variable",
          "note": "nominal_usd is a static reference, NOT a guaranteed minimum; actual charge = provider_cost x multiplier and can be higher or lower"
        },
        "tags": [
          "https://docs.twitterapi.io/api-reference/endpoint/get_article"
        ],
        "summary": "Get Article",
        "operationId": "get_twitter_article",
        "description": "Get the full body of an X Article (long-form post) by its tweet ID. Use this when a tweet links to or is an Article and the 280-character preview is not enough — this returns the complete text rather than the truncated tweet. Returns the article under `article`. For ordinary tweets use `get_twitter_tweets`.",
        "parameters": [
          {
            "name": "tweet_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The tweet ID of the article."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArticleResponse"
                }
              }
            }
          }
        }
      }
    },
    "/twitter/tweet/advanced_search": {
      "get": {
        "x-aisa-pricing": {
          "model": "dynamic",
          "currency": "USD",
          "basis": "provider_cost x 2",
          "nominal_usd": 0.0022,
          "observed_usd": {
            "min": 0.00015,
            "p50": 0.0022,
            "p95": 0.006,
            "max": 0.006
          },
          "cost_drivers": [
            {
              "param": "result count",
              "effect": "charge scales with number of tweets/users returned"
            }
          ],
          "cost_tier": "variable",
          "note": "nominal_usd is a static reference, NOT a guaranteed minimum; actual charge = provider_cost x multiplier and can be higher or lower"
        },
        "tags": [
          "https://docs.twitterapi.io/api-reference/endpoint/tweet_advanced_search"
        ],
        "summary": "Advanced Search",
        "operationId": "get_twitter_tweet_advanced_search",
        "description": "Search X posts by keyword or query with X's advanced search operators, sorted by Latest (default) or Top. This is the primary entry point for X content research when you do not yet have tweet IDs or handles. Supports operators in the query string such as `from:`, `to:`, `since:`, `until:`, `min_faves:`, and `-filter:replies`. Cursor-paginated; returns tweets with `has_next_page` and `next_cursor`. To search accounts rather than posts use `get_twitter_user_search`. To read one account's own posts use `get_twitter_user_tweet_timeline`.",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The query to search for."
          },
          {
            "name": "queryType",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "Latest",
                "Top"
              ],
              "default": "Latest"
            },
            "description": "The query type to search for."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The cursor to paginate through the results. First page is empty."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdvancedSearchResponse"
                }
              }
            }
          }
        }
      }
    }
  }
}
