Twitter/X Trends API

The Trends API from Twitter/X — 2 operation(s) for trends.

OpenAPI Specification

twitter-x-trends-api-openapi.yml Raw ↑
openapi: 3.0.0
info:
  description: X API v2 available endpoints
  version: '2.166'
  title: X API v2 Account Activity Trends API
  termsOfService: https://developer.x.com/en/developer-terms/agreement-and-policy.html
  contact:
    name: X Developers
    url: https://developer.x.com/
  license:
    name: X Developer Agreement and Policy
    url: https://developer.x.com/en/developer-terms/agreement-and-policy.html
servers:
- description: X API
  url: https://api.x.com
tags:
- name: Trends
paths:
  /2/trends/by/woeid/{woeid}:
    get:
      security:
      - BearerToken: []
      tags:
      - Trends
      summary: Get Trends by WOEID
      description: Retrieves trending topics for a specific location identified by its WOEID.
      externalDocs:
        url: https://developer.twitter.com/en/docs/twitter-api/trends/api-reference/get-trends-by-woeid
      operationId: getTrendsByWoeid
      parameters:
      - name: woeid
        in: path
        description: The WOEID of the place to lookup a trend for.
        required: true
        example: '2244994945'
        schema:
          type: integer
          format: int32
        style: simple
      - name: max_trends
        in: query
        description: The maximum number of results.
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 50
          format: int32
          default: 20
        style: form
      - $ref: '#/components/parameters/TrendFieldsParameter'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Get2TrendsByWoeidWoeidResponse'
        default:
          description: The request has failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
  /2/users/personalized_trends:
    get:
      security:
      - OAuth2UserToken:
        - tweet.read
        - users.read
      - UserToken: []
      tags:
      - Trends
      summary: Get personalized Trends
      description: Retrieves personalized trending topics for the authenticated user.
      externalDocs:
        url: https://developer.x.com/
      operationId: getTrendsPersonalizedTrends
      parameters:
      - $ref: '#/components/parameters/PersonalizedTrendFieldsParameter'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Get2UsersPersonalizedTrendsResponse'
        default:
          description: The request has failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
components:
  schemas:
    Trend:
      type: object
      description: A trend.
      properties:
        trend_name:
          type: string
          description: Name of the trend.
        tweet_count:
          type: integer
          description: Number of Posts in this trend.
          format: int32
    PersonalizedTrend:
      type: object
      description: A trend.
      properties:
        category:
          type: string
          description: Category of this trend.
        post_count:
          type: integer
          description: Number of posts pertaining to this trend.
        trend_name:
          type: string
          description: Name of the trend.
        trending_since:
          type: string
          description: Time since this is trending.
    Get2TrendsByWoeidWoeidResponse:
      type: object
      properties:
        data:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/Trend'
        errors:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/Problem'
    Problem:
      type: object
      description: An HTTP Problem Details object, as defined in IETF RFC 7807 (https://tools.ietf.org/html/rfc7807).
      required:
      - type
      - title
      properties:
        detail:
          type: string
        status:
          type: integer
        title:
          type: string
        type:
          type: string
      discriminator:
        propertyName: type
        mapping:
          about:blank: '#/components/schemas/GenericProblem'
          https://api.twitter.com/2/problems/client-disconnected: '#/components/schemas/ClientDisconnectedProblem'
          https://api.twitter.com/2/problems/client-forbidden: '#/components/schemas/ClientForbiddenProblem'
          https://api.twitter.com/2/problems/conflict: '#/components/schemas/ConflictProblem'
          https://api.twitter.com/2/problems/disallowed-resource: '#/components/schemas/DisallowedResourceProblem'
          https://api.twitter.com/2/problems/duplicate-rules: '#/components/schemas/DuplicateRuleProblem'
          https://api.twitter.com/2/problems/invalid-request: '#/components/schemas/InvalidRequestProblem'
          https://api.twitter.com/2/problems/invalid-rules: '#/components/schemas/InvalidRuleProblem'
          https://api.twitter.com/2/problems/noncompliant-rules: '#/components/schemas/NonCompliantRulesProblem'
          https://api.twitter.com/2/problems/not-authorized-for-field: '#/components/schemas/FieldUnauthorizedProblem'
          https://api.twitter.com/2/problems/not-authorized-for-resource: '#/components/schemas/ResourceUnauthorizedProblem'
          https://api.twitter.com/2/problems/operational-disconnect: '#/components/schemas/OperationalDisconnectProblem'
          https://api.twitter.com/2/problems/resource-not-found: '#/components/schemas/ResourceNotFoundProblem'
          https://api.twitter.com/2/problems/resource-unavailable: '#/components/schemas/ResourceUnavailableProblem'
          https://api.twitter.com/2/problems/rule-cap: '#/components/schemas/RulesCapProblem'
          https://api.twitter.com/2/problems/streaming-connection: '#/components/schemas/ConnectionExceptionProblem'
          https://api.twitter.com/2/problems/unsupported-authentication: '#/components/schemas/UnsupportedAuthenticationProblem'
          https://api.twitter.com/2/problems/usage-capped: '#/components/schemas/UsageCapExceededProblem'
    Get2UsersPersonalizedTrendsResponse:
      type: object
      properties:
        data:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/PersonalizedTrend'
        errors:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/Problem'
    Error:
      type: object
      required:
      - code
      - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
  parameters:
    TrendFieldsParameter:
      name: trend.fields
      in: query
      description: A comma separated list of Trend fields to display.
      required: false
      schema:
        type: array
        description: The fields available for a Trend object.
        minItems: 1
        uniqueItems: true
        items:
          type: string
          enum:
          - trend_name
          - tweet_count
        example:
        - trend_name
        - tweet_count
      explode: false
      style: form
    PersonalizedTrendFieldsParameter:
      name: personalized_trend.fields
      in: query
      description: A comma separated list of PersonalizedTrend fields to display.
      required: false
      schema:
        type: array
        description: The fields available for a PersonalizedTrend object.
        minItems: 1
        uniqueItems: true
        items:
          type: string
          enum:
          - category
          - post_count
          - trend_name
          - trending_since
        example:
        - category
        - post_count
        - trend_name
        - trending_since
      explode: false
      style: form
  securitySchemes:
    BearerToken:
      type: http
      scheme: bearer
    OAuth2UserToken:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://api.x.com/2/oauth2/authorize
          tokenUrl: https://api.x.com/2/oauth2/token
          scopes:
            block.read: View accounts you have blocked.
            bookmark.read: Read your bookmarked Posts.
            bookmark.write: Create and delete your bookmarks.
            dm.read: Read all your Direct Messages.
            dm.write: Send and manage your Direct Messages.
            follows.read: View accounts you follow and accounts following you.
            follows.write: Follow and unfollow accounts on your behalf.
            like.read: View Posts you have liked and likes you can see.
            like.write: Like and unlike Posts on your behalf.
            list.read: View Lists, members, and followers of Lists you created or are a member of, including private Lists.
            list.write: Create and manage Lists on your behalf.
            media.write: Upload media, such as photos and videos, on your behalf.
            mute.read: View accounts you have muted.
            mute.write: Mute and unmute accounts on your behalf.
            offline.access: Request a refresh token for the app.
            space.read: View all Spaces you have access to.
            timeline.read: View all Custom Timelines you can see, including public Custom Timelines from other developers.
            tweet.moderate.write: Hide and unhide replies to your Posts.
            tweet.read: View all Posts you can see, including those from protected accounts.
            tweet.write: Post and repost on your behalf.
            users.read: View any account you can see, including protected accounts.
    UserToken:
      type: http
      scheme: OAuth